Exploring HCX API

VMware Hybrid Cloud Extension is a powerful product for datacenter migration/replacement (On-Prem or from On-Prem to Cloud) and disaster recovery.  VMware HCX supports 3 major cloud at the moment namely VMware Cloud on AWS, OVH Cloud and IBM Cloud.

Although HCX interface for workload migration is very simple and even the first times can migrate workloads without much difficulty, but it is always good to know about the API offering of any product so that you can automate stuffs via scripting.

HCX API allows customers to automate all aspects of HCX including the HCX VAMI UI for initial configuration as well as consuming the HCX services which are exposed in the vSphere UI.

HCX have its own API explorer (similar to the vSphere swagger interface). You can use additional tools like Postman or curl to explore the capabilities of HCX API.

Method 1: Using HCX API Interface

HCX API interface can be accessed by typing https://<HCX-Manager-fqdn>/hybridity/docs/index.html and it will bring you to the initial interface.:

 

To start with, you can select HCX Enterprise, and now you will be presented with all the options associated with HCX Enterprise.

First we have to authenticate against the HCX Manager to obtain the auth token so that we can use that token while firing up subsequent API calls. To do so, click on Platform and expand the /api/sessions link.

Click on “Try it out” button and it will allow you to punch in your HCX manager username/password. 

Note: You have to use your vSphere User/Group that you have authorized access to HCX (during HCX initial configuration)

Note: Make sure to set Content-Type to application/json

Once you have entered your vSphere user/group credentials, click on execute button.

On hitting execute button, you will get back a token called x-hm-authorization which needs to be included in all subsequent HCX API calls. 

Method 2: Using Postman to explore HCX API

I am a big fan of Postman when it comes to exploring API of any product. 

To use postman for exploring HCX API, please follow below steps:

1: Launch your Postman instance and specify following:

Switch to the Body tab and select type as text and paste punch in your vSphere credentials that you have configured in HCX. 

Clicking on Send button will provide you “x-hm-authorization” token value.

Once you have the auth token handy, it’s time to play with GET commands to start with.

Example 1: Querying HCX-vCenter Registration

API Output:

Example 2: Querying HCX-NSX Registration

Output:

Example 3: Querying HCX- vSphere SSO Integration

Output:

Example 4: Querying HCX Interconnect (Fleet Appliances)

And that’s it for this post. In future post on this topic, I will demonstrate how to use POST/PUT API calls in HCX.

I hope you enjoyed reading this post. Feel free to share this on social media if it is worth sharing :)