Skip to content

Instantly share code, notes, and snippets.

@trisharia
Last active March 25, 2017 01:24
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/fd3519fb4b6e3952f9eff6882d30fdbf to your computer and use it in GitHub Desktop.
Save trisharia/fd3519fb4b6e3952f9eff6882d30fdbf to your computer and use it in GitHub Desktop.
Get the ID of the Catalog Request of a vRA VM
// VMware vRealize Orchestrator action sample
//
// Get the ID of the Catalog Request for a vRA IaaS VM
//
// For vRO/VRA 7.0+
//
// Action Inputs:
// host - vCAC:VCACHost - vRA IaaS Host
// virtualMachine - vCAC:VirtualMachine - vRA IaaS VM
//
// Return type: string - the ID of the Catalog Request of a VM
var vmEntity = System.getModule("com.vmware.library.vcac").getVirtualMachineEntity(host,virtualMachine);
var requestId = getVmEntityPropertyValue(host, vmEntity, "__Cafe.Root.Request.Id");
return requestId;
function getVmEntityPropertyValue(host, vmEntity, propertyName) {
var virtualMachinePropertiesEntities = vmEntity.getLink(host, "VirtualMachineProperties");
for each (var virtualMachinePropertiesEntity in virtualMachinePropertiesEntities) {
if (virtualMachinePropertiesEntity.getProperty("PropertyName") == propertyName) {
return virtualMachinePropertiesEntity.getProperty("PropertyValue");
}
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment