Hi Everyone,
The 7.2 upgrade to 7.3 'broke' some scripting I inherited designed to take input parameters of Datacenter and VM and return the best host on which to clone a VM. Here is the script (which continues to run fine in 7.2):
System.log( "The value of dataCenter is " + dataCenter);
System.log( "The value of vm is " + vm);
function getHostFromFolder( folder , vmachine ){
return folder.clusterComputeResource[0].recommendHostsForVm( vm );
}
if (!dataCenter)
{
return null;
}
if (!vm)
{
return null;
}
var searchFolder = dataCenter.hostFolder;
foundItems = getHostFromFolder( searchFolder , vm);
var max = Math.max.apply(Math,foundItems.map(function(o){return o.rating;}))
var i = 0;
for ( i=0; i< foundItems.length; i++ )
{
if (foundItems[i].rating == max)
{
return foundItems[i].host;
}
}
...in troubleshooting, I can see by virtue of writing the values of the dataCenter and vm input parameters out to System.log that the objects seem to have changed. From 7.2 (which works, the id's,names, and urls below are sanitized):
[2017-05-23 10:16:00.786] [I] The value of dataCenter is DynamicWrapper (Instance) : [VcDatacenter]-[class com.vmware.vmo.plugin.vi4.model.VimDatacenter] -- VALUE : Datacenter<datacenter-999999>'SanitizedDatacenter'
[2017-05-23 10:16:00.790] [I] The value of vm is DynamicWrapper (Instance) : [VcVirtualMachine]-[class com.vmware.vmo.plugin.vi4.model.VimVirtualMachine] -- VALUE : VirtualMachine<vm-888888>'vmSanitized'
and in 7.3 (does not work):
[2017-05-23 10:13:43.850] [I] The value of dataCenter is DynamicWrapper (Instance) : [VcDatacenter]-[class com.vmware.o11n.plugin.vsphere_gen.Datacenter_Wrapper] -- VALUE : Stub: moRef = (ManagedObjectReference: type = Datacenter, value = datacenter-999999, serverGuid = null), binding = https://sanitized.vcenterhere.com:443/sdk
[2017-05-23 10:13:43.852] [I] The value of vm is DynamicWrapper (Instance) : [VcVirtualMachine]-[class com.vmware.o11n.plugin.vsphere_gen.VirtualMachine_Wrapper] -- VALUE : Stub: moRef = (ManagedObjectReference: type = VirtualMachine, value = vm-888888, serverGuid = null), binding = https://sanitized.vcenterhere.com:443/sdk
Can anyone give me some pointers as to what I need to do to get this scripting to run in 7.3? Thank you.
7.2 version is Appliance Version: 7.2.0.19944 Build 4629837
7.3 version is Appliance Version: 7.3.0.21553 Build 5521409