Uridium454
Enthusiast
Enthusiast

Return all of the VMs owned by a particular business group

Just a quick note to help anyone out there that may be looking for a list of VMs owned by a particular business group.  May you find it useful.

Inputs:

vCACCAFE:VCACHost

BusinessGroupName (note: the BG name has been hardcoded below for testing as seen "MyBusinessGroupName")

   

Script:

var service = host.createCatalogClient().getCatalogConsumerResourceService();

var businessGroupObject = vCACCAFEEntitiesFinder.findBusinessGroups(host,"MyBusinessGroupName")[0];

var businessGroupID = businessGroupObject.getId();

System.log("BusinessGroup ID: " + businessGroupID);

var filter = new Array();

filter[0] = vCACCAFEFilterParam.substringOf("organization/subTenant/id", vCACCAFEFilterParam.string(businessGroupID));

var query = vCACCAFEOdataQuery.query().addFilter(filter);

var items = service.getResourcesList(new vCACCAFEPageOdataRequest(query));

//Removing all deployments, as I was only interested in the VM name. Can parse as needed from this point.

for each( var item in items){

     if(item.hasChildren == false){

          System.log("name:" + item.name);

     }

}