A Trick With OptionManager in vSphere API

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[1];
changedValue[0] = new OptionValue();

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.

This entry was posted in vSphere API and tagged , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *


You may use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


    My company has created products like vSearch ("Super vCenter"), vijavaNG APIs, EAM APIs, ICE tool. We also help clients with virtualization and cloud computing on customized development, training. Should you, or someone you know, need these products and services, please feel free to contact me: steve __AT__ doublecloud.org.

    Me: Steve Jin, VMware vExpert who authored the VMware VI and vSphere SDK by Prentice Hall, and created the de factor open source vSphere Java API while working at VMware engineering. Companies like Cisco, EMC, NetApp, HP, Dell, VMware, are among the users of the API and other tools I developed for their products, internal IT orchestration, and test automation.