use of com.vmware.vim25.RetrieveOptions in project photon-model by vmware.
the class GetMoRef method entityProps.
/**
* Method to retrieve properties of a {@link ManagedObjectReference}
*
* @param entityMor {@link ManagedObjectReference} of the entity
* @param props Array of properties to be looked up
* @return Map of the property name and its corresponding value
* @throws InvalidPropertyFaultMsg If a property does not exist
* @throws RuntimeFaultFaultMsg
*/
public Map<String, Object> entityProps(ManagedObjectReference entityMor, String... props) throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {
init();
final HashMap<String, Object> retVal = new HashMap<>();
// Create PropertyFilterSpec using the PropertySpec and ObjectPec
PropertyFilterSpec[] propertyFilterSpecs = { new PropertyFilterSpecBuilder().propSet(// Create Property Spec
new PropertySpecBuilder().all(Boolean.FALSE).type(entityMor.getType()).pathSet(props)).objectSet(// Now create Object Spec
new ObjectSpecBuilder().obj(entityMor)) };
List<ObjectContent> oCont = this.vimPort.retrievePropertiesEx(this.serviceContent.getPropertyCollector(), Arrays.asList(propertyFilterSpecs), new RetrieveOptions()).getObjects();
if (oCont != null) {
for (ObjectContent oc : oCont) {
List<DynamicProperty> dps = oc.getPropSet();
for (DynamicProperty dp : dps) {
retVal.put(dp.getName(), dp.getVal());
}
}
}
return retVal;
}
Aggregations