Hi,
Using QuerySpec I am trying to fetch list of Hosts under a cluster
I have following code
// create QuerySpec
QuerySpec qs = new QuerySpec();
qs.resourceSpec = new ResourceSpec();
qs.resourceSpec.constraint = new Constraint();
// HostSystem is the targetType
qs.resourceSpec.constraint.targetType = "HostSystem";
// 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[] objects = new Object[items.length];
for (int index = 0; index < items.length; ++index) {
objects[index] = items[index].resourceObject;
}
return objects;
Code is same as in ChassisRack adapter , where I can specify the cluster details so only host under cluster will get fetched .