Exploring HCX API

VMware Hybrid Cloud Extension is a powerful product for data center migration, replacement, and disaster recovery. VMware HCX supports 3 major clouds at the moment: VMware Cloud on AWS, OVH Cloud, and IBM Cloud.

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

The 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 that are exposed in the vSphere UI.

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

Method 1: Using HCX API Interface

The 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, you have to authenticate against the HCX Manager to obtain the auth token so that we can use that token while executing subsequent API calls. To do so, click on Platform and expand the /api/sessions link.

Click on the “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 or group that you have authorized access to HCX (during the initial configuration of HCX)

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

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

On hitting the 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 the API of any product. 

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

1: Launch your Postman instance and specify the following:

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

Clicking on the 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

Response Output:

Example 2: Querying HCX-NSX Registration

Response Output:

Example 3: Querying HCX- vSphere SSO Integration

Response Output:

Example 4: Querying HCX Interconnect (Fleet Appliances)

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

I hope you find this post informative. Feel free to share it on social media if it is worth sharing.

Leave a Reply