Hello, I'm trying to figure out the best way to get the vCenter UUID for a vCloud VIM object (in my case a resource pool for which I have the MoRef) in order to identify the corresponding vCenter object. I want to use a given resource pool reference (backing a pvDC) to find the actual resource pool object in vCenter, out of many vCenters registered to vCO/vCD since the MoRef isn't unique between vCenters. There is an article by William Lam (http://blogs.vmware.com/vsphere/2012/02/uniquely-identifying-virtual-machines-in-vsphere-and-vcloud-...) which describes the relationships, however an example of resolving this with vCO would be appreciated.
The following should return the UUID of your vCenter Server assuming the input object is a vCloud:ProviderVdc object named "providerVdc"
var vcdHost = providerVdc.getHost();
var pool = providerVdc.toAdminExtensionObject().getResourcePools()[0]; // get the first resource pool (VclVMWProviderVdcResourcePool)
var vimObjectRef = pool.resourcePoolVimObjectRef;
var vimServer = vcdHost.getEntityByReference(VclFinderType.VIM_SERVER,vimObjectRef.vimServerRef);
System.log("VimServer uuid: "+vimServer.uuid);
The following should return the UUID of your vCenter Server assuming the input object is a vCloud:ProviderVdc object named "providerVdc"
var vcdHost = providerVdc.getHost();
var pool = providerVdc.toAdminExtensionObject().getResourcePools()[0]; // get the first resource pool (VclVMWProviderVdcResourcePool)
var vimObjectRef = pool.resourcePoolVimObjectRef;
var vimServer = vcdHost.getEntityByReference(VclFinderType.VIM_SERVER,vimObjectRef.vimServerRef);
System.log("VimServer uuid: "+vimServer.uuid);