VMware Cloud Community
ScottyW253
Contributor
Contributor
Jump to solution

vRA Tagging drop-down list

I can apply tags to deployed VM's however was looking for a way to build the functionality into the service broker form.

e.g. We have a tag that is applied to VM's called Provided Service. I was looking for a way to customize the form so that the catalog request would list all the Provided Service tags within vSphere and display them in a drop-down for the user to select.

Has anyone accomplished this or can point me in the right direction.

0 Kudos
1 Solution

Accepted Solutions
xian_
Expert
Expert
Jump to solution

With vRealize Orchestrator Plug-In for vRealize Automation 

var list = [];
var url = "/provisioning/uerp/resources/tags";
var parameters = "$filter=(key%20eq%20%27Provided%20Service%27)&expand=true";
var restResult = System.getModule("com.vmware.vra.extensibility.plugin.rest").getObjectFromUrl(vraHost, url, parameters);
Object.keys(restResult.documents).forEach(
  function (tagId) {
    list.push(restResult.documents[tagId].value);
  }
)
System.debug(list);
return list;

/iaas/api/tags should also give you the tags, but I had issues with earlier vRA8 versions when it returned only 100 tags. Have not tested since...

View solution in original post

0 Kudos
6 Replies
BrettK1
Enthusiast
Enthusiast
Jump to solution

Great question, if I'm lucky I'll be trying to tackle it myself within a couple days.

0 Kudos
xian_
Expert
Expert
Jump to solution

With vRealize Orchestrator Plug-In for vRealize Automation 

var list = [];
var url = "/provisioning/uerp/resources/tags";
var parameters = "$filter=(key%20eq%20%27Provided%20Service%27)&expand=true";
var restResult = System.getModule("com.vmware.vra.extensibility.plugin.rest").getObjectFromUrl(vraHost, url, parameters);
Object.keys(restResult.documents).forEach(
  function (tagId) {
    list.push(restResult.documents[tagId].value);
  }
)
System.debug(list);
return list;

/iaas/api/tags should also give you the tags, but I had issues with earlier vRA8 versions when it returned only 100 tags. Have not tested since...

0 Kudos
ScottyW253
Contributor
Contributor
Jump to solution

Hi Xian

Thanks for this. It works perfectly within Orchestrator however I get the following error within the Service Broker

{"message":"920002: Invoked action completed with error. Error : Action 'getTagByKey' in module 'com.vmware.vra.extensibility.rest' failed : TypeError: Cannot read property \"documents\" from undefined (com.vmware.vra.extensibility.rest/getTagByKey#5).","messageId":0,"stackTrace":null,"statusCode":400,"errorCode":920002};

Any Ideas?

0 Kudos
xian_
Expert
Expert
Jump to solution

You'll need to set vraHost variable as well within the action.

0 Kudos
krishna20july
Contributor
Contributor
Jump to solution

were you able to fix this error ?

0 Kudos
madeve2
Contributor
Contributor
Jump to solution

Were you able to fix this error?

0 Kudos