User Statement:
As the user of the vic-machine-service I want to ensure efficient lookup of VIC appliance VMs on which the service runs.
Details:
In an effort to find an alternative to the CustomFieldValue approach we are using currently, we have been researching different, but efficient ways to look up VIC appliances. After some researches, we seem to have come to a workable solution that would permanently replace the existing approach.
The idea is to use vim.ExtensionManager.QueryManagedBy()
which returns an array list of ManagedObjectReferences that are managed by the Extension of the provided extensionKey
, in this case "com.vmware.vic". We feed the list into the vim.PropertyCollector.RetrievePropertiesEx()
call to get the fields we want for consumption by UI.
For this approach, we need to set the VIC appliance VM configuration's managedBy
field to a reference to the H5 Client plugin Extension that was registered with the vCenter Server. The ManagedByInfo
object (ref) needs to have two fields set to correctly point to the H5 Client plugin extension - extensionKey
and type
, which match the key
and type
properties in the Extension object, respectively.
Before we set the type
field, we should create and add an ExtManagedEntityInfo
object to the ExtensionManager object's managedEntityInfo
field (ref), which basically is a way for us to define custom-typed objects. Only the type
field is mandatory and the value of it needs to be unique such as VicApplianceVM
. This field will be referenced by the Extension's type
field as shown below:
Extension
managedEntityInfo
: [ ExtManagedEntityInfo{type: string - uniqueIdentifierForVicAppliance}, ... ]
type
: String - should match managedEntityInfo.type
Next, in order to actually associate the VIC appliance VM with the H5 Client plugin Extension, the VM needs to be reconfigured such that VirtualMachineConfigInfo
object's managedBy
field points to the H5 Client plugin Extension:
ManagedByInfo
managedBy
: ManagedByInfo{extensionKey: string - plugin extension key, type: string - value set in the managedEntityInfo field above}
Versioning
Now, as far as the versioning is concerned, we would like to ensure that each VIC appliance VM has the major, minor, patch and build number information available for consumption by UI so that we can later implement proper sorting/filtering mechanisms as necessary. An investigation into this led us to look into the VirtualMachine object's config.product
field which is of type VAppProductInfo
(ref). Currently the version
field does show major, minor and patch info but not build number.
Caveats
There is a chicken-and-egg problem where when a VIC appliance VM is deployed with the aforementioned configs to be set, there is a good chance that the VIC UI plugin is not installed especially when this is a fresh installation. @jzt is currently looking into this issue.
Further work
This idea could be extended to improve looking up all VCHs and Container VMs in the vSphere inventory as well as to support a custom icon. This could be considered post 1.3 work.