-
Notifications
You must be signed in to change notification settings - Fork 89
Configure DHCP Relay for Logical Router #602
Comments
Hi @F3rC, there is not a lot of active dev on PowerNSX But about configure DHCP Relay Agent on Edge, you can look nsx_64_api.pdf (Google can help for found file) |
Hi @alagoutte. Thanks for your reply. I found the document and the section you mentioned. I will take a look. Thanks for the help. |
@alagoutte I have no experience with API calls. Can I use the 'Invoke-NsxRestMethod' function to configure the DHCP Relay Agents? |
Yes, it is the idea You can look on PowerNSX.psm1 for example Get-NsxSSLVpn or Set-NsxSslVpn for example |
Thanks. I accomplished what I needed using the API guide you suggested and the 'Invoke-NsxWebRequest' function and by pulling the existing xml configuration file.
|
@alagoutte Sorry for the multiple questions. Is the POST method not allowed / available for DHCP Relay Agents? It is not documented in the API and when I tried running the same script I got the following error: `Invoke-NsxWebRequest : Invoke-NsxWebRequest : The NSX API response received indicates a failure. 405 : Method Not Allowed : HTTP Status 405 – Method Not AllowedType Status Report Message Request method 'POST' not Description The method received in the request-line is known by the origin server but not supported by At line:22 char:1
|
Do you have try to use PUT ? (Do you plan to try to include direclty on powernsx), can be reuse by some other people... |
Yes, I tried PUT and it works but that means I need to include the whole XML in the body as opposed to just adding the new / additional required entries. With my basic understanding of the REST methods I thought that with POST I would be able to add just the new DHCP Relay Agents I needed but I might be wrong. I did run the script with PowerNSX using the Invoke-NsxWebRequest function. But not sure how I understand your question regarding including it directly in PowerNSX. First I got the XML content using GET:
Then I edited the XML content and finally I used the edited XML with PUT method. Worked like a charm but again, I had to completely replace the XML instead of being able to add just some additional entries (DHCP Relay Agents). The actual script I used is the following:
I may be confused about what POST actually does, maybe I need to do some more reading about REST. |
the NSX(-V) API work only with this method... need to extract actually body and PUT edited body... Only some API call support to add... |
Got it. Thanks for the clarification. Despite not being able to add entries, I still got the task done so I am happy. I really appreciate your help with this. I will definitely keep exploring NSX (and probably vSphere) API as it seems the most powerful way of automating tasks. |
Thanks for feedback a good idea, it will be to add missing cmdlet for DHCP Relay (can be usefull for other...) |
I have tried using the New-NsxLogicalSwitch function as a reference to build one that adds a new DHCP Relay. I noticed 'New-NsxLogicalSwitch' uses the 'Add-XmlElement' function to add a new logical switch to the 'virtualWireCreateSpec' resource. However, this function uses the POST method which is not allowed/supported by the API for DHCP Relays (relay resource). I did build a function and tried both POST and PUT but with POST I always get the 'HTTP Status 405 – Method Not Allowed' message and with PUT I get the following:
I am more than glad to continue working on a function that works but may need some guidance as I haven't worked with APIs and XMLs before. If you or anyone else has the availability to work on this I can do the "legwork", may only need someone to point me in the right direction. Since POST is not an option, the first and most important question I may need an answer for is how can the PUT method be used to update a resource as it is supposed to replace the whole thing? One option would be getting the existing resource, locally updating it and using PUT to replace it on the server side. But I am pretty there must be a better approach. |
hi @F3rC, do you have found how to fix the issue ? There is some internal function for add field or XML body |
I was looking for a way to configure DHCP Relay Agents via PowerNSX but there doesn't seem to be one at the moment. Can this be added in a future version? Thanks.
The text was updated successfully, but these errors were encountered: