There was recently a question in the open source VI Java API forum regarding the OptionManager. As you may have known, the OptionManager is used to manage key value pairs, for example, the “VMFS3.HardwareAcceleratedLocking” is a key as shown in the code included in the question. Somehow the code to set the key, as shown below, doesn’t work with com.vmware.vim25.InvalidArgument exception.
OptionManager optionmanager = host.getOptionManager(); OptionValue changedValue = new OptionValue; changedValue = new OptionValue(); changedValue.setKey("VMFS3.HardwareAcceleratedLocking"); changedValue.setValue(0); optionmanager.updateOptions(changedValue);
As it turns out, one character change solved the problem. Monsrud who raised the question also figured out the solution – just change parameter to the setValue() method as follows:
Bothered by SLOW Web UI to manage vSphere? Want to manage ALL your VMware vCenters, AWS, Azure, Openstack, container behind a SINGLE pane of glass? Want to search, analyze, report, visualize VMs, hosts, networks, datastores, events as easily as Google the Web? Find out more about vSearch 3.0: the search engine for all your private and public clouds.
The solution seems a little too magical to believe. What happens is that the value in the OptionValue is xsd:anyType, therefore java.lang.Object in Java. When it gets serialized, a type is included. In the case without L, it’s declared as xsd:int; with L, xsd:long. Therefore there is a difference in the SOAP request when you change the type.
Going beyond this particular issue, you may have other similar cases. When you get cases like this, you can try this trick.
Thanks to Monsrud for not only raising the question but also sharing the solution! That is truly a community spirit.