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:

Lost VMs or Containers? Too Many Consoles? Too Slow GUI? Time to learn how to "Google" and manage your VMware and clouds in a fast and secure HTML5 App.


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.