Get Access to the vCloud API with Performance Cloud VMware (NSX-T)
TABLE OF CONTENTS
- Notes
- Requirements
- Procedure
- References
Notes
In the example below, we are using a software named Postman and the CAN URL for Performance Cloud VMware, but you could use any compatible API platform. The USA URL would work the same way too.
Sherweb will not provide any type of support for the use of the mentioned tool or any other 3rd party software. Please refer to the software vendor's support website for any support requests.
Requirements
Have Postman installed
Procedure
Step 1 – Create a new collection & Authenticate to the API
- In Postman, create a new collection.
- Give a name to the new collection and change the authorization type to Basic Auth.
- Enter the username and password and click on Save.
The username to enter is your [Sherweb Cloud username] + [@] + [Performance Cloud VMware organisation]
Example: john@domain.com@orgname - Create a new request.
- Execute the folowing query:
GET https://performancecloud-vdc.sherweb.com/api/versions
- Confirm you properly authenticated with the authorization value in Headers tab.
Step 2 - Discover the supported API versions
With the GET call previously performed, validate the API versions supported to make sure your API calls are supported.
Step 3 - Establish a session
In the Headers section, create a new key like this:
Key: Accept
Value: Application/*+xml;version=35.2
Note: version should be the latest version available from Step 2
Create a session to vCloud Director using basic auth
Note: Using this method with the x-vcloud-authorization value, the session will be reset after few hours.
Execute the following query to confirm you have successfully created a session to vcloud director:
POST https://performancecloud-vdc.sherweb.com/api/sessions
You should receive a "200 OK" response to confirm it is successful.
Take note of the x-vcloud-authorization value
Create a new key in the Headers section
Key: x-vcloud-authorization
Value: value from previous step
Create a session to vCloud Director using bearer token
In Tests tab, enter the following lines and click on Send:
var bearer = postman.getResponseHeader("X-VMWARE-VCLOUD-ACCESS-TOKEN")
pm.environment.set("X-VMWARE-VCLOUD-ACCESS-TOKEN",bearer)
Get the X-VMWARE-VCLOUD-ACCESS-TOKEN value.
Go to the Authorization tab. Change the authorization type from Inherit from parent to Bearer Token.
Set the value from previous step and click on Save.
Test query to get org information
Execute the following query:
GET https://performancecloud-vdc.sherweb.com/api/org
The result should look like this:
Step 4 - Perform queries
Here are some queries as examples.
- To get when the VM State changes (Power off / Power on):
GET https://performancecloud-vdc.sherweb.com/api/query?type=event&filter=eventType==com/vmware/vcloud/event/vm/change_state
- To get tasks about a particular virtual machine named WEB:
GET https://performancecloud-vdc.sherweb.com/api/query?type=task&filter=objectName==WEB
- If metadata was put in place on virtual machines, you can query the metadata.
- To get all virtual machines in the Production environment:
GET https://performancecloud-vdc.sherweb.com/api/query?type=vm&filter=metadata:Environnement==STRING:Production
- To get all virtual machines in the Sales department:
GET https://performancecloud-vdc.sherweb.com/api/query?type=vm&filter=metadata:Department==STRING:Sales
- To get all virtual machines in the Production environment:
References
https://developer.broadcom.com/