Skip to content

Instantly share code, notes, and snippets.

@trisharia
Last active June 2, 2017 04:17
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save trisharia/337e2df485aa78a507700a53db8b7718 to your computer and use it in GitHub Desktop.
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