Last active
March 25, 2017 01:27
-
-
Save trisharia/b9907c2e039c35ed03c6820217701f54 to your computer and use it in GitHub Desktop.
Get the VM of a vRA Catalog Resource
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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