Archive

Posts Tagged ‘metadata’

How to Get Metadata of VMware vSphere API?

September 7th, 2010 No comments

VMware vSphere API is defined by WSDL. As discussed in my previous blog REST or SOAP, Web Services is by nature procedural, and it does not support OO (object oriented). This contributes to the learning curve of vSphere Web Service API which is modeled with OO.

What if you want to find out what properties are supported by a particular managed object type in vSphere API? There was a specific question recently in blog comment: how to get valid/supported property paths like summary.hardware.numNics with HostSystem type.

Currently there is no systematically way to get this metadata which is not defined in WSDL. You have to manually read through vSphere API Reference.

Since vSphere Java API 1.0 (a.k.a. VI Java API by then), I have manually added a getter method for every property in the Java API. So the metadata is built in vSphere Java API from the beginning. Whenever there is a manual process, it could be error-prone. As much carefully as I liked, I made mistakes with properties ignored in vSphere Java API occasionally. These mistakes have been immediately patched up upon bug reports or self reviewing.

To get exactly what you want programmatically, you have to do something extra with Java reflection API. Let’s pick HostSystem as an example here.