Using Global Tags with vRealize Orchestrator

I hit a problem recently where I wanted to selectively pick out REST hosts from vRealize Orchestrator, without having to rely on naming conventions (as I had in the past) to determine the type of infrastructure.

Global Tags allow us to tag objects in vRO – workflows, actions, plugin objects, configurations to group them together. This is simple through the UI, but setting/retrieving this programatically proved a little tricky to figure out.

To achieve this, I used something I have not used before in vRealize Orchestrator, something not very well documented, and as such I thought I would put a post together on how to query return a list of REST hosts based on tags.

Setting a Global Tag on a REST Host:

// tag the 'my_rest_host' RESTHost object with the global tag
// 'Rubrik' (note the colon before the tag value denotes global
// tags)
Server.tagGlobally(my_rest_host, ':Rubrik');

Retrieving REST Hosts with a specific global tag:

// get objects with global tag 'Rubrik'
var get_hosts = Server.queryByTags([{'tag':':Rubrik'}],'REST:RESTHost');
var out = [];
for(var rest_host_id in get_hosts){	
	var rest_host = get_hosts[rest_host_id];
	out.push(rest_host.name);
}
// return an array of RESTHost objects
return out;

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s