sandeep15
Contributor
Contributor

List all tags of virtual machine using vrealize orchestrator

Hello all,

can any one help me with tags which are associated with virtual machine.

I want to list tags of a virtual machine using vrealize orchestrator

Thanks in advance.

Appriciate your help.

Thanks.

2 Replies
tschoergez
Leadership
Leadership

Find here some examples around tag management: https://oliverleach.wordpress.com/2016/07/19/vrealize-orchestrator-7-vapi-vsphere-tags-workflow/

vRealize Orchestrator 7 VAPI vSphere tags workflow | virtual devops

Here's some javascript example:

var vmsWithSpecificTag = new Array();

var client = vApiEndpoint.client();

var tagging = new com_vmware_cis_tagging_tag__association(client);

var tagMgr = new com_vmware_cis_tagging_tag(client);

var objId = new com_vmware_vapi_std_dynamic__ID() ;

objId.id = vm.id;

objId.type = vm.vimType;

var tagList = tagging.list_attached_tags(objId);

//System.debug("Taglist: " + tagList);

for each (var tagId in tagList) {

var theTag = tagMgr.get(tagId);

// System.debug("theTag: " + theTag);

var tagName=theTag.name;

//System.debug("tagName: " + tagName);

if (tagName == tagNameToMatch) {

//Do something if the tag matches...

vmsWithSpecificTag .push(vm);

break;

}

}

It takes the vApiEndpoint and the VirtualMachine object vm, and a tagNameToMatch string as inputs, and returns all the associated tags into the variable tagList. Then it loops through the list and compares the tags to the given tagName.

Regards,

Joerg

www.vcoportal.de - Orchestrate. Your Cloud.
sandeep15
Contributor
Contributor

Thank you:)

That's works...

0 Kudos