use of com.vmware.vim.binding.vmodl.DynamicProperty in project flowgate by vmware.
the class InventoryService method listByType.
public List<ManagedObjectReference> listByType(PropertyCollector propertyCollector, ManagedObjectReference containerView, String typeName) {
PropertySpec propertySpec = new PropertySpec();
propertySpec.setType(new TypeNameImpl(typeName));
propertySpec.setAll(true);
// PropertySpec networkPropertySpec = new PropertySpec();
// networkPropertySpec.setType(new TypeNameImpl("Network"));
// networkPropertySpec.setAll(true);
// TraversalSpec traversalSpec = new TraversalSpec();
// traversalSpec.setType(new TypeNameImpl("HostSystem"));
// traversalSpec.setPath("network");
// traversalSpec.setSkip(false);
// traversalSpec.setSelectSet(null);
TraversalSpec traversalSpec = new TraversalSpec();
traversalSpec.setName(TRAVERSE_ENTITIES);
traversalSpec.setPath(VIEW);
traversalSpec.setSkip(false);
traversalSpec.setType(new TypeNameImpl(CONTAINER_VIEW));
ObjectSpec objectSpec = new ObjectSpec();
objectSpec.setObj(containerView);
objectSpec.setSelectSet(new SelectionSpec[] { traversalSpec });
FilterSpec filterSpec = new FilterSpec();
filterSpec.setObjectSet(new ObjectSpec[] { objectSpec });
filterSpec.setPropSet(new PropertySpec[] { propertySpec });
RetrieveOptions retrieveOptions = new RetrieveOptions();
RetrieveResult retrieveResult = null;
try {
retrieveResult = propertyCollector.retrievePropertiesEx(new FilterSpec[] { filterSpec }, retrieveOptions);
} catch (InvalidProperty invalidProperty) {
logger.error("Invalid property", invalidProperty);
}
ObjectContent[] objects = null;
if (null != retrieveResult) {
objects = retrieveResult.getObjects();
}
List<ManagedObjectReference> targets = new ArrayList<ManagedObjectReference>();
if (null != objects) {
for (ObjectContent object : objects) {
targets.add(object.getObj());
DynamicProperty[] properties = object.getPropSet();
if (null != properties) {
for (DynamicProperty property : properties) {
switch(property.getName()) {
case NAME:
break;
default:
break;
}
}
}
}
}
// logger.debug("RetrieveResult \n{}", retrieveResult);
return targets;
}
Aggregations