FINDING ALL ITEMS IN A BUSINESS GROUP

I recently needed to figure out how many items are deployed for a specific vRA Business Group. Items include virtual machines but also anything else a user can deploy. That seemed an easy task but finding all items in a business group turned out to be a bit harder than expected.

So to save others the trouble of figuring out how this works I’ll share my code here. You can copy-paste the code below directly to a vRO action.


var cafeHost = vCACCAFEEntitiesFinder.getHostForEntity(businessGroup);
service = cafeHost.createCatalogClient().getCatalogConsumerResourceService();
var filter = new Array();
filter[0] = vCACCAFEFilterParam.substringOf("organization/subTenant/id", vCACCAFEFilterParam.string(businessGroup.id));
var query = vCACCAFEOdataQuery.query().addFilter(filter);
var odataRequest = new vCACCAFEPageOdataRequest(1, 10000, query);
resources = service.getResourcesList(odataRequest);


return resources;

Comments

Popular posts from this blog

Creating Snapshots for Unmanaged VMs in Aria Automation (vRealize Automation)

Bulk import security policies into Palo Alto Networks firewalls

Automating Tag Creation & Assignment to VMs with vRA + vRO