As has been purported many times it is possible to create objects via a RESTful API. Lets first look at the logical network segments in my environment. Whilst I show the GUI creation here this post highlights the the GUI method.
There are none. This is a fresh instance. Now I am going to open up my web browser, in this case it is Mozilla, and click on my RESTClient plugin.
The REST client requires some details first. Authentication so it can communicate against the NSX manager and the Content-Type. It needs to know that it is posting XML data.
Okay so now I want to use the API to POST the attached XML snipper to create a virtual wire. The URL to access the virtual wire is https:///api/2.0/vdn/scopes//virtualwires.
This requires me to put in based on my environment POST:https://nsxmgr-l-01a.corp.local/api/2.0/vdn/scopes/vdnscopes-1/virtualwires
The XML required for the creation of my switch is as follows:
web-01 Web Tier LS Pandom Systems UNICAST_MODE
We can see confirmation of the creation of our logical switch with the following output.
Status Code: 201 Created Cache-Control: no-cache Content-Length: 13 Content-Type: text/html Date: Mon, 02 Jun 2014 23:07:25 GMT Location: /api/2.0/vdn/virtualwires/virtualwire-1 Server: vShield Manager
Time to confirm this against the webGUI.
There we are. It is simple to use POST or GET to retrieve and deploy environments. It is possible, depending on your ability to use an API at scale to manager and run your environment based on the API! Pretty cool stuff.
3 thoughts on “Creating NSX objects with REST API”