pages

Thursday, October 4, 2012

vCO - VcOptionValue which value type?

Got some tricky task this week: Change the advanced parameter "NFS.MaxVolumes" of a ESX host to 256. First thought was: my post for VcOptionValue on the virtual machine. So I searched for the scripting class and wrote some like this:



var configMgr = myHost.configManager;

for(i in configMgr.advancedOption.queryOptions("NFS.MaxVolumes")){
            System.debug(configMgr.advancedOption.queryOptions("NFS.MaxVolumes")[0].key);
}

var oValues = new Array();
oValues[0] = new VcOptionValue() ;
oValues[0].key = "NFS.MaxVolumes";
oValues[0].value = 256;


try {
            configMgr.advancedOption.updateOptions(oValues);
}catch (e){

           System.log("Could not setAdvanced Settings. Error: " + e);
}



which should be run. But after firing this in vCO there comes an error message like: "wrong parameter" and "internal error". I looked into the vCO logs, the vSphere client and the vpxd.log but all messages didn´t show the exact problem.









After some investigation i found out that the type definition of the value is necessary! So there are some like int, float or long. In my case "long" was the answer. So the code has to look like this:




var configMgr = myHost.configManager;

for(i in configMgr.advancedOption.queryOptions("NFS.MaxVolumes")){
            System.debug(configMgr.advancedOption.queryOptions("NFS.MaxVolumes")[0].key);
}

var oValues = new Array();
oValues[0] = new VcOptionValue() ;
oValues[0].key = "NFS.MaxVolumes";
oValues[0].value_LongValue = 256;


try {
            configMgr.advancedOption.updateOptions(oValues);
}catch (e){

           System.log("Could not setAdvanced Settings. Error: " + e);
}














So, after the next test everything was fine :)