Seems like this would be something simple to do, but for some reason I'm not connecting the dots. If I
have an Array of VC:VirtualMachine objects and a vCAC:VCACHost object, how can I easily/quickly get
the vCAC:VirtualMachine objects for those VMs? Thanks.
You might already have an action to do that called "getvCACvmFromVCvm" In case you do not have this action here is the code for your review.
var vCACvms = Server.findAllForType("vCAC:VirtualMachine");
var uuid = vcvm.config.uuid
var vcName = vcvm.name
for each (var vCACvm in vCACvms){
//System.log(vCACvm)
if (vcName == vCACvm.VirtualMachineName){
System.log("Resolved vCAC VM: " + vCACvm.VirtualMachineName);
System.log(vCACvm);
return vCACvm;
break;
}
}
This is how I do it:
var Uuid = vCenterVm.config.instanceUuid;
var vCACVms = Server.findAllForType("vCAC:VirtualMachine", "VMUniqueID eq '" + Uuid + "'");
System.log(vCACVms.length + " match uuid: " + Uuid);
for each (var vCACVm in vCACVms) {
System.log("Resolved vCAC VM: " + vCACVm.virtualMachineName);
}
if (vCACVms.length > 1 ) throw "Too many matches for UUID: " + Uuid + ", there can be only one!";
return vCACVms[0];
Thanks Steve! I'll give it a shot. I figured it was something as simple as that.
Thanks Paul. I'll give this a shot as well. Appreciate the quick response!