use of com.vmware.vim25.mo.Folder in project CloudStack-archive by CloudStack-extras.
the class DatastoreMO method getOwnerDatacenter.
public Pair<DatacenterMO, String> getOwnerDatacenter() throws Exception {
if (_ownerDc != null)
return _ownerDc;
PropertySpec pSpec = new PropertySpec();
pSpec.setType("Datacenter");
pSpec.setPathSet(new String[] { "name" });
TraversalSpec folderParentTraversal = new TraversalSpec();
folderParentTraversal.setType("Folder");
folderParentTraversal.setPath("parent");
folderParentTraversal.setName("folderParentTraversal");
folderParentTraversal.setSelectSet(new SelectionSpec[] { new SelectionSpec(null, null, "folderParentTraversal") });
TraversalSpec dsParentTraversal = new TraversalSpec();
dsParentTraversal.setType("Datastore");
dsParentTraversal.setPath("parent");
dsParentTraversal.setName("dsParentTraversal");
dsParentTraversal.setSelectSet(new SelectionSpec[] { folderParentTraversal });
ObjectSpec oSpec = new ObjectSpec();
oSpec.setObj(getMor());
oSpec.setSkip(Boolean.TRUE);
oSpec.setSelectSet(new SelectionSpec[] { dsParentTraversal });
PropertyFilterSpec pfSpec = new PropertyFilterSpec();
pfSpec.setPropSet(new PropertySpec[] { pSpec });
pfSpec.setObjectSet(new ObjectSpec[] { oSpec });
ObjectContent[] ocs = _context.getService().retrieveProperties(_context.getServiceContent().getPropertyCollector(), new PropertyFilterSpec[] { pfSpec });
assert (ocs != null);
assert (ocs[0].getObj() != null);
assert (ocs[0].getPropSet() != null);
String dcName = ocs[0].getPropSet()[0].getVal().toString();
_ownerDc = new Pair<DatacenterMO, String>(new DatacenterMO(_context, ocs[0].getObj()), dcName);
return _ownerDc;
}
use of com.vmware.vim25.mo.Folder in project coprhd-controller by CoprHD.
the class VCenterAPI method getRootFolder.
/**
* Gets the root folder.
*
* @return the root folder.
*/
public Folder getRootFolder() {
checkConnected();
Folder rootFolder = service.getRootFolder();
return rootFolder;
}
use of com.vmware.vim25.mo.Folder in project photon-model by vmware.
the class GetMoRef method getVMTraversalSpec.
/**
* @return TraversalSpec specification to get to the VirtualMachine managed
* object.
*/
public TraversalSpec getVMTraversalSpec() {
// Create a traversal spec that starts from the 'root' objects
// and traverses the inventory tree to get to the VirtualMachines.
// Build the traversal specs bottoms up
// Traversal to get to the VM in a VApp
TraversalSpec vAppToVM = new TraversalSpecBuilder().name("vAppToVM").type("VirtualApp").path("vm");
// Traversal spec for VApp to VApp
TraversalSpec vAppToVApp = new TraversalSpecBuilder().name("vAppToVApp").type("VirtualApp").path("resourcePool").selectSet(// SelectionSpec for both VApp to VApp and VApp to VM
new SelectionSpecBuilder().name("vAppToVApp"), new SelectionSpecBuilder().name("vAppToVM"));
// This SelectionSpec is used for recursion for Folder recursion
SelectionSpec visitFolders = new SelectionSpecBuilder().name("VisitFolders");
// Traversal to get to the vmFolder from DataCenter
TraversalSpec dataCenterToVMFolder = new TraversalSpecBuilder().name("DataCenterToVMFolder").type("Datacenter").path("vmFolder").skip(false).selectSet(visitFolders);
// TraversalSpec to get to the DataCenter from rootFolder
return new TraversalSpecBuilder().name("VisitFolders").type("Folder").path("childEntity").skip(false).selectSet(visitFolders, dataCenterToVMFolder, vAppToVM, vAppToVApp);
}
use of com.vmware.vim25.mo.Folder 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.mo.Folder 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