REST API allows us to programmatically control NSX, using REST API requests we can install, configure, monitor, and maintain NSX. The API calls typically use HTTP or HTTPS as the communication protocol, the payload itself is in JSON or XML format. VMware provides a beefy document that goes through all the various API calls and functionality available. If you are using NSX 6.3 like me, the guide can be found here.
There are various Rest API clients out there, in this blog post you will be using Postman which can be downloaded from here.
Once you have launched Postman, we will need to make a couple of configuration changes. Namely the Authorization type and adding a custom header which is needed for POST calls.
Launch Postman, click on Authorization, change the type to Basic, then enter your NSX Manager credentials.
Navigate to the headers menu
Add Content-Type as key and Application/xml as value
One last thing to mention here is that we will be using the https protocol to interact with the NSX manager. In my case I will be using https://192.168.0.44 to interact with my NSX Manager.
We are now ready to use Postman.
Below is a list of the requests that are possible to use, however in my experience, you will find yourself using GET, POST, PUT, DELETE more frequently than the others.
GET: To read information
PUT: To update configuration.
POST: To change configuration
DELETE: To delete
Query my NSX controllers: https://192.168.0.44/api/2.0/vdn/controller
Query my SSO configuration: https://192.168.0.44/api/2.0/services/ssconfig
Query my logical switches: https://192.168.0.44/api/2.0/vdn/virtualwires
Create a logical switch:
As we all know, a logical switch needs to belong to a transport zone, I will therefore need to find it’s scope id as it’s part of the logical switch creation call.
Query my transport zones : https://192.168.0.44/api/2.0/vdn/scopes
Now that we have our transport zone scope id vdnscope-1, let’s create our logical switch.
Body of our call
<description>REST API LS</description>
Checking in our NSX environment we can see that the logical has indeed been created.
Delete a logical switch
Let’s first find it’s object id: https://192.168.0.44/api/vdn/virtualwires <virtualWire>
Now we can delete the logical switch: https://22.214.171.124/api/2.0/vdn/virtualwires/virtualwire-59
How useful was this post?
Click on a star to rate it!
Average rating / 5. Vote count:
My name is Amine El Badaoui and I currently live in Aylesbury, a small town in the south east of England
I have been working in the IT industry for few years now and specialise in VMware virtualisation, data centre infrastructure and cloud technologies. Over the years I have obtained numerous industry certifications from Microsoft, Netapp and VMware.I currently work as a VMware Product Engineer @ https://www.rackspace.com/
This blog represents my random technical notes and thoughts. The thoughts expressed here do not reflect my current employer in anyway.