Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get the Reservation of a vRA VM
// VMware vRealize Orchestrator action sample
//
// Get the Reservation of a vRA VM
//
// For vRO/VRA 7.0+
//
// Action Inputs:
// host - vCAC:VCACHost - vRA IaaS Host
// virtualMachine - vCAC:VirtualMachine - vRA IaaS VM
//
// Return type: vCAC:Reservation - the IaaS Reservation of the VM
var id = virtualMachine.getEntity().getProperty("HostReservationID");
var entity;
var idprop = new Properties( {
"HostReservationID" : id
});
if (!id || id == "") throw "Error getting Reservation ID of VM.";
if (host != null) {
entity = vCACEntityManager.readModelEntity(host.id, "ManagementModelEntities.svc", "HostReservations", idprop, null);
} else {
var hosts = Server.findAllForType("vCAC:VCACHost");
System.debug("hosts: " + hosts);
for each (var host in hosts) {
try {
entity = vCACEntityManager.readModelEntity(host.id, "ManagementModelEntities.svc", "HostReservations", idprop, null);
} catch (e) {
throw "Error reading model entity.";
}
}
}
var reservation = entity.getInventoryObject();
if (!reservation) throw "Reservation with ID '" + id + "' not found";
return reservation;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment