Enable Disable HA on Edge GW via NSX Rest API

In this post I will be demonstrating how to enable and disable high availability on NSX edge gateway using Rest API.

If you are new to NSX and do not know what edge gateway high availability means then I would recommend to read this Blog by Gabe Rosas.

We can enable disable high availability on edge gateway from vSphere Web Client by navigating to Home  > Networking & Security > NSX Edges > Selecting Edge > Manage > HA Configuration

Enabling HA on edge gateway will create a new vse vm in vCenter and both VM start exchanging heartbeat and exchanging other configuration etc.

Now we will see how to achieve this via NSX Rest API.

Step 1: Query HA Status

# curl -k -u “admin:passwd” -X GET https://nsxmgr.alex.local/api/4.0/edges/edge-2/highavailability/config | xmllint –format –

From the above output we can see HA ha snot been enabled on edge gateway yet.

Step 2: Enable HA

To enable HA on edge gateway, we need to supply few parameter in the request body of the API call. If you are using curl you can create an xml file as shown below and can supply it with API query with -d option. 

Firing below API call will enable HA the edge gateway. 

# curl -k -u “admin:passwd” -H “Content-Type:application/xml”  -X PUT https://nsxmgr.alex.local/api/4.0/edges/edge-2/highavailability/config -d @enable-ha.xml

You can watch the progress in vCenter.

You will see a couple of edge backing vm’s in vCenter post enabling HA

Step 3: Verify HA has been enabled

# curl -k -u “admin:passwd” -X GET https://nsxmgr.alex.local/api/4.0/edges/edge-2/highavailability/config | xmllint –format –

Step 4: Query Edge Appliance

# curl -k -u “admin:passwd” -X GET https://nsxmgr.alex.local/api/4.0/edges/edge-2/appliances

Step 5:Disable HA

To disable HA on edge gateway, again we need to supply an xml file with the API call. We just need to flag enabled=false in the xml file as shown below. 

# curl -k -u “admin:AdminPWD” -H “Content-Type:application/xml” -d @disable-ha.xml -X PUT https://nsxmgr.alex.local/api/4.0/edges/edge-2/highavailability/config

This will delete the extra edge VM that was deployed in step 2

And that’s it, we have now successfully enabled/disabled high availability on edge gateway.

Sources and Additional Reading

NSX Rest API Guide

NSX Edge vs vShield Edge

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

Leave a Reply