Helloooo & welcome to our blog!
Today I would like to give you 2 quick tips for troubleshooting & testing / developing in your vRA environment:
- Telnet on the vRA Appliances
- Postman for executing vRA API calls
Telnet on vRA Appliances
We all know how to check whether a remote machine is listening on specific ports for requests, or if a certain port can be reached on the network passing through firewalls and more network magic: telnet.
Well how can we use telnet on the vRA appliances? With one simple command:
curl -v telnet://<target ip address>:<desired port number>
All you have to do is open an SSH connection to one of your appliances and execute the above command. Here’s an example:
curl -v telnet://externalvRO.some.domain:8281
A successful connection is shown as:
* Rebuilt URL to: telnet://externalvRO.some.domain:8281/ * Trying 192.168.1.35... * TCP_NODELAY set * Connected to externalvRO.some.domain (192.168.1.35) port 8281 (#0)
If the machine you’re trying to reach is denying connections on that port, you might see something similar to this:
* Rebuilt URL to: telnet://externalvRO.some.domain:8289/ * Trying 192.168.1.35... * TCP_NODELAY set * connect to 192.168.1.35 port 8289 failed: Connection refused * Failed to connect to externalvRO.some.domain port 8289: Connection refused * Closing connection 0 curl: (7) Failed to connect to externalvRO.some.domain port 8289: Connection refused
If a firewall is blocking your request, you might see something similar to this:
* Rebuilt URL to: telnet://8.8.8.8:443/ * Trying 8.8.8.8... * TCP_NODELAY set *
Happy connection troubleshooting vRA chiefs!
Postman – vRA API Calls
The vRA API works in the following way:
- First you need to authenticate against the vRA API to retieve a Bearer Token
- With that Bearer Token you can execute other API calls against vRA’s API.
A very useful tool to execute REST API calls & do some API development is Postman. Postman is available in different downloads:
- Windows Application
- MacOS Application
- Google Chrome Plugin
- …
Some Postman links below:
The vRA API Documentation can be found here
Well, how do we authenticate with the vRA API? With a simple API call:
URL = https://<Your-vRA-Appliance>/identity/api/tokens Method = POST Headers = Content-Type : application/json Body = { "username": "<your_vra_account>@vsphere.local", "password": "<your_vra_account's_password>", "tenant": "<tenantName>" }
This will give us an Authorization Bearer Token to use in our future API calls!
How does that look in Postman? Well like this:
And the response looks like this, the Bearer Token can be found in the ‘id‘ field of the response’s body:
And now you can use this Bearer Token to execute other API calls! All you have to do is include this Bearer Token in the header of your API call.
Let’s say you want to get all the Reservations in vRA via an API call, that can be achieved by doing this:
URL = https://<Your-vRA-Appliance>/reservation-service/api/reservations Method = GET Header values = Accept : application/json Content-Type : application/json Authorization : Bearer <your_bearer_token_here>
This is how that looks in Postman:
And the response looks like this:
Hopefully you’re now all settled to play around with vRA’s API!
Happy developing!