Advanced VMware VI Virtualization Topics
- Managing Global Settings with OptionManager
- Collecting Logs Using DiagnosticManager
- Sharing Sessions Among Different Applications
- Using Single Sign-On from the VI SDK to CIM
- Downloading and Uploading Files Using HTTP Access
- Multithreading with the VI SDK
- Versioning
- Following Best Practices for Performance and Scalability
- Considering Internationalization
- Summary
This chapter discusses several topics that do not quite fit into the previous chapters. However, you may find them useful in your application development:
- Managing global settings with OptionManager
- Collecting logs using DiagnosticManager
- Sharing sessions with multiple clients
- Using single sign-on from the VI SDK to CIM
- Downloading and uploading files using HTTP access
- Versioning VI SDKs
- Multithreading with the VI SDK
- Following best practices for performance and scalability
- Considering internationalization
Managed Objects: OptionManager, DiagnosticManager, HostSystem
Managing Global Settings with OptionManager
OptionManager manages key/value pairs as a mechanism for flexible settings. It can be reached from both ServiceInstance and HostSystem.
When connecting directly to an ESX server, you can get the OptionManager object from the ServiceInstance, but it doesn't have much information. The OptionManager object from the HostSystem has a real data setting that you can find and modify from the Advanced Setting dialog box of the ESX system in the VI Client.
When connecting to a VirtualCenter server, you can get an OptionManager object from the ServiceInstance with VirtualCenter server settings. You can find and change these settings in the VirtualCenter Management Server Configuration dialog box in the VI Client. The OptionManager object from a HostSystem is the same that you would get from the HostSystem on ESX.
The OptionManager type has two properties defined:
supportedOption—List of OptionDef objects. The OptionDef data object, whose UML diagram is shown in Figure 18-1, is extended from ElementDescription. The ElementDescription has a string property key, which normally uses a dot-separated notation to indicate its position in the whole hierarchy, such as mail.smtp.port for the SMTP port option under the Mail section.
Figure 18-1 The OptionDef and its subtypes
OptionDef includes OptionType, which has one property indicating whether the option is read-only. OptionType has six subtypes, each of which represents a data type of the option. Most of them include defaultValue for the option. FloatOption, IntOption, and LongOption have the same structure but different data types for the properties.
- Setting—List of OptionValue data objects to hold real key/value pairs. The key is one of the keys in the OptionDef objects in supportedOption. The value, as you expect, is defined as xsd:anyType because it can be any value as defined in the six types in OptionDef.
The optionManager defines two methods:
- queryOption() retrieves a specific node or nodes in the option hierarchy. It takes in a string parameter name as the key to the OptionDef. You can provide a full key, or the starting part of the key ending with dot, such as snmp, which returns all the OptionValue objects under the snmp node. You must include the dot for the parameter to be valid.
- updateOptions() updates one or more options specified by the OptionValue[] parameter. The changes are done atomically; they are all changed, or none are changed.
For both methods, the option key must be valid, or the InvalidName fault is thrown. For updateOptions(), you must provide a valid value for the option as required in the OptionDef; otherwise, the InvalidArgument fault is thrown.
These two methods do not change the available OptionDef objects. In fact, you cannot add a new OptionDef or remove an existing OptionDef. You can add a new OptionValue without matching OptionDef, but that is not a typical use case.
In the VirtualCenter Management Server Configuration dialog box of the VI Client, you can add more key/value pairs when you select Advanced Settings. Whatever key you enter in is prefixed with config in the OptionManager object. Just use the Managed Object Browser (MOB) to check it out. Awkwardly, the next time you bring back the same dialog box, the newly added key/value pair doesn't display.