Starting with the chassis-service and chassis rack-service examples from the SDK, I've been trying to figure out how to get information on the HostSystem Managed Object.
For example, In java, I'd like to get to HostSystem.HostHardwareInfo.HostSystemInfo.model for each attached host.
I found code in one of the examples that gets me a list of host objects attached to vCenter - but I haven't been able to find a code example or construct any code that correctly gets me to the Data Objects I need.
Here is the code that gets the hosts objects - Am I on the right track? Are there methods I can use to get to the information I want?
/**
* Returns the current Host objects in the system.
*/
private Object[] getHosts(int maxResultCount) {
// create QuerySpec
QuerySpec qs = new QuerySpec();
qs.resourceSpec = new ResourceSpec();
qs.resourceSpec.constraint = new Constraint();
// HostSystem is the targetType
qs.resourceSpec.constraint.targetType = HOST_TYPE;
// request the name property
PropertySpec pSpec = new PropertySpec();
pSpec.propertyNames = new String[]{"name"};
qs.resourceSpec.propertySpecs = new PropertySpec[]{pSpec};
qs.resultSpec = new ResultSpec();
qs.resultSpec.maxResultCount = new Integer(maxResultCount);
// use default ordering
qs.resultSpec.order = new OrderingCriteria();
qs.resultSpec.order.orderingProperties = new OrderingPropertySpec[0];
// get data from DataService
RequestSpec requestSpec = new RequestSpec();
requestSpec.querySpec = new QuerySpec[]{qs};
Response response = _dataService.getData(requestSpec);
ResultItem[] items = response.resultSet[0].items;
if (items == null) {
return new Object[0];
}
Object[] hosts = new Object[items.length];
for (int index = 0; index < items.length; ++index) {
hosts[index] = items[index].resourceObject;
}
return hosts;
}