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.
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...
Great question, if I'm lucky I'll be trying to tackle it myself within a couple days.
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...
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?
You'll need to set vraHost variable as well within the action.
were you able to fix this error ?
Were you able to fix this error?