Create a VRO action to list all VM’s with a specific security tag

I wanted to populate a VRA drop down with all VM’s who have a specific security tag. So I am off to creating a action. This particular action does require that you denote the uuid of your RESTAPI connection to NSX manager. I have included mine as a reference. You can locate this via the VRO console. This action returns an array of strings.

var connection = NSXConnectionManager.findConnectionById(“a497d03f-b45c-494d-a9a2-3d8d8a3b8fe1”);

var tag = NSXSecurityTagManager.getSecurityTag(connection, ‘securitytag-12’);

var list = NSXSecurityTagManager.getTaggedVms(connection, tag);

var machines = new Array();

if (list == null) {

    members = null;

} else {

    members = new Array();

    for (i=0; i<list.length; i++) {

        var member = new Object();

        member.name = list[i].name;

                              machines.push(list[i].name);

                              System.log(list[i].name);

        member.description = list[i].description;

        member.objectId = list[i].objectId;

        member.objectType = list[i].objectTypeName;

        member.revision = list[i].revision

        members[i] = member;

    }

}

return machines;

Leave a Reply

Your email address will not be published. Required fields are marked *

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