use of com.vmware.vim25.ObjectSpec in project photon-model by vmware.
the class WaitForValues method propertyFilterSpec.
private PropertyFilterSpec propertyFilterSpec(ManagedObjectReference objmor, String[] filterProps, String[] propsToMatch) {
PropertyFilterSpec spec = new PropertyFilterSpec();
ObjectSpec oSpec = new ObjectSpec();
oSpec.setObj(objmor);
oSpec.setSkip(Boolean.FALSE);
spec.getObjectSet().add(oSpec);
Set<String> uniqPropSet = new HashSet<>(Arrays.asList(filterProps));
uniqPropSet.addAll(Arrays.asList(propsToMatch));
PropertySpec pSpec = new PropertySpec();
pSpec.getPathSet().addAll(new ArrayList<>(uniqPropSet));
pSpec.setType(objmor.getType());
spec.getPropSet().add(pSpec);
return spec;
}
use of com.vmware.vim25.ObjectSpec in project photon-model by vmware.
the class Finder method ancestrySet.
private List<ObjectContent> ancestrySet(ManagedObjectReference ref) throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {
ObjectSpec ospec = new ObjectSpec();
ospec.setObj(ref);
ospec.setSkip(false);
TraversalSpec tspec = new TraversalSpec();
tspec.setSkip(false);
tspec.setPath("parent");
tspec.setType("ManagedEntity");
tspec.setName("traverseParent");
SelectionSpec selSpec = new SelectionSpec();
selSpec.setName("traverseParent");
tspec.getSelectSet().add(selSpec);
ospec.getSelectSet().add(tspec);
PropertySpec pspec = new PropertySpec();
pspec.setType("ManagedEntity");
pspec.getPathSet().add("name");
pspec.getPathSet().add("parent");
PropertyFilterSpec filter = new PropertyFilterSpec();
filter.getObjectSet().add(ospec);
filter.getPropSet().add(pspec);
return this.connection.getVimPort().retrieveProperties(this.connection.getServiceContent().getPropertyCollector(), Collections.singletonList(filter));
}
use of com.vmware.vim25.ObjectSpec in project photon-model by vmware.
the class Lister method listFolder.
private List<Element> listFolder() throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg, FinderException {
PropertyFilterSpec spec = new PropertyFilterSpec();
ObjectSpec objSpec = new ObjectSpec();
objSpec.setObj(this.start);
TraversalSpec selectionSpec = new TraversalSpec();
selectionSpec.setPath("childEntity");
selectionSpec.setType("Folder");
selectionSpec.setSkip(false);
objSpec.getSelectSet().add(selectionSpec);
spec.getObjectSet().add(objSpec);
// Retrieve all objects that we can deal with
String[] childTypes = { "Folder", "Datacenter", "VirtualMachine", "Network", "ComputeResource", "ClusterComputeResource", "Datastore" };
for (String t : childTypes) {
PropertySpec pspec = new PropertySpec();
pspec.setType(t);
pspec.getPathSet().add("name");
// Additional basic properties.
if (t.equals("ComputeResource") || t.equals("ClusterComputeResource")) {
// The ComputeResource and ClusterComputeResource are dereferenced in
// the ResourcePoolFlag. Make sure they always have their resourcePool
// field populated.
pspec.getPathSet().add("resourcePool");
}
spec.getPropSet().add(pspec);
}
return callPropertyCollectorAndConvert(spec);
}
use of com.vmware.vim25.ObjectSpec in project photon-model by vmware.
the class Lister method listComputeResource.
private List<Element> listComputeResource() throws FinderException, InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {
ObjectSpec ospec = new ObjectSpec();
ospec.setSkip(true);
ospec.setObj(this.start);
for (String f : new String[] { "host", "resourcePool" }) {
TraversalSpec tspec = new TraversalSpec();
tspec.setPath(f);
tspec.setType("ComputeResource");
tspec.setSkip(false);
ospec.getSelectSet().add(tspec);
}
PropertyFilterSpec filter = new PropertyFilterSpec();
filter.getObjectSet().add(ospec);
for (String t : new String[] { "HostSystem", "ResourcePool" }) {
PropertySpec pspec = new PropertySpec();
pspec.setType(t);
pspec.getPathSet().add("name");
filter.getPropSet().add(pspec);
}
return callPropertyCollectorAndConvert(filter);
}
use of com.vmware.vim25.ObjectSpec in project photon-model by vmware.
the class Lister method listDatacenter.
private List<Element> listDatacenter() throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg, FinderException {
ObjectSpec ospec = new ObjectSpec();
ospec.setObj(this.start);
ospec.setSkip(true);
// Include every datastore folder in the select set
String[] fields = { "vmFolder", "hostFolder", "datastoreFolder", "networkFolder", "datastore" };
for (String f : fields) {
TraversalSpec tspec = new TraversalSpec();
tspec.setPath(f);
tspec.setSkip(false);
tspec.setType(VimNames.TYPE_DATACENTER);
ospec.getSelectSet().add(tspec);
}
PropertySpec pspec = new PropertySpec();
pspec.setType(VimNames.TYPE_FOLDER);
pspec.getPathSet().add(VimNames.PROPERTY_NAME);
PropertySpec dcspec = new PropertySpec();
dcspec.setType(VimNames.TYPE_DATACENTER);
dcspec.getPathSet().add(VimNames.PROPERTY_NAME);
PropertySpec dsspec = new PropertySpec();
dsspec.setType(VimNames.TYPE_DATASTORE);
dsspec.getPathSet().add(VimNames.PROPERTY_NAME);
PropertyFilterSpec spec = new PropertyFilterSpec();
spec.getObjectSet().add(ospec);
spec.getPropSet().add(pspec);
spec.getPropSet().add(dcspec);
spec.getPropSet().add(dsspec);
return callPropertyCollectorAndConvert(spec);
}
Aggregations