ADD A VMWARE NSX SECURITY TAG TO A VM IN THE SECONDARY NSX MANAGER VIA API

I recently had a coworker ask how to add a VMware NSX Security Tag to a VM that was under management of the secondary VMware NSX Manager. While NSX provides the ability to create and manage NSX Security Tags via the UI (GUI), only the API can manage Security Tags on VMs managed by the secondary NSX Manager.

After a bit of reading documentation and poking at the API, here’s the how-to:

 

ADD A VMWARE NSX SECURITY TAG TO A VM IN THE SECONDARY NSX MANAGER VIA API

API command:
POST /api/2.0/services/securitytags/tag/{tagId}/vm

*with a BODY REQUST: application.xml replacing the value for the vmname

<securityTagAssignment>
<tagParameter>
<key>vmname</key>
<value>myvmserver1</value>
</tagParameter>
</securityTagAssignment>

*don’t forget to change the solution criteria to vmname from uuid

Source: https://docs.vmware.com/en/VMware-NSX-for-vSphere/6.3/nsx_63_api.pdf (pages 75 and 76)


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  Subscribe  
Notify of