Hi All,
I'm working on a workflow that takes an input of type VC:VirtualMachine, then runs different processes depending on the vm's vcenter / data center & resource pool values.
What I don't know is the best way to get hold of these 3 values. Can anyone help?
Thanks in advance!
Tim.
Hi Tim,
Here is some sample code (the input is variable vm of type VC:VirtualMachine):
// find resource pool
System.log("resource pool: " + vm.resourcePool);
// find datacenter
var p = vm.parent;
while (p != null) {
if (p instanceof VcDatacenter) {
System.log("datacenter: " + p);
break;
}
p = p.parent;
}
// find vCenter connection
System.log("vcenter: " + vm.sdkConnection);
Hi Tim,
Here is some sample code (the input is variable vm of type VC:VirtualMachine):
// find resource pool
System.log("resource pool: " + vm.resourcePool);
// find datacenter
var p = vm.parent;
while (p != null) {
if (p instanceof VcDatacenter) {
System.log("datacenter: " + p);
break;
}
p = p.parent;
}
// find vCenter connection
System.log("vcenter: " + vm.sdkConnection);
Perfect, thank you!