VRO code to apply a NSX security tag

I recently created an environment that had a VRA XaaS to apply a security tag to individual virtual machines. I wanted to share the code I wrote to speed up your adoption. In this case we have a scriptable task to do the work. We have one parameter:

Parameters (it’s the string name of the server)

We have two attributes:

tag ( array of names selected because you have VRO integrated with NSX endpoint) RestAPI endpoint for NSX

Here is the code:

Here is the scriptable task and code

Here is the code for cut and paste usage:

//name = ‘dev-214’;

vms = VcPlugin.getAllVirtualMachines();

for each (vm in vms) {

    if (vm.Name == name) {

        System.log(“VM name: ” + vm.name + ” MOID: ” + vm.id);

                              machineMOID = vm.id;



// Apply the tag

               NSXSecurityTagManager.applySecurityTagOnVMs(connection, machineMOID, tag);

Leave a Reply

Your email address will not be published.

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