Skip to content

Instantly share code, notes, and snippets.

@trisharia
Last active March 25, 2017 01:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trisharia/b9907c2e039c35ed03c6820217701f54 to your computer and use it in GitHub Desktop.
Save trisharia/b9907c2e039c35ed03c6820217701f54 to your computer and use it in GitHub Desktop.
Get the VM of a vRA Catalog Resource
// VMware vRealize Orchestrator action sample
//
// Get the vRA IaaS VM of a Catalog Resource
//
// For vRO/VRA 7.0+
//
// Action Inputs:
// host - vCAC:VCACHost - vRA CAFE Host
// catalogResource - vCACCAFE:CatalogResource - the vRA Catalog Resource
//
// Return type: vCAC:VirtualMachine - vRA IaaS VM
var machineId = catalogResource.providerBinding.getBindingId();
var vm;
try {
vm = getVmByMachineId(host, machineId);
} catch (e) {
System.warn("Virtual machine not found for given Catalog Resource. " + e);
}
return vm;
function getVmByMachineId(host,machineId) {
var vm;
var filter = new Properties( {
"VirtualMachineID" : machineId
});
var entity = vCACEntityManager.readModelEntity(host.id, "ManagementModelEntities.svc", "VirtualMachines", filter, null);
vm = entity.getInventoryObject();
if (!vm) {
throw "Virtual machine ID is invalid";
}
return vm;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment