use of com.vmware.vim25.mo.Datacenter in project photon-model by vmware.
the class VSphereAdapterImageEnumerationService method refreshResourcesOnce.
private void refreshResourcesOnce(Set<String> oldImages, ImageEnumerateRequest request, ComputeStateWithDescription parent, Connection connection, TaskManager mgr) {
DatacenterLister lister = new DatacenterLister(connection);
try {
for (Element element : lister.listAllDatacenters()) {
ManagedObjectReference datacenter = element.object;
try {
EnumerationClient client = new EnumerationClient(connection, parent, datacenter);
processAllTemplates(oldImages, request.resourceLink(), request.taskLink(), client, parent.tenantLinks);
} catch (Throwable e) {
mgr.patchTaskToFailure("Error processing vm templates in " + element.path, e);
return;
}
}
} catch (InvalidPropertyFaultMsg | RuntimeFaultFaultMsg e) {
mgr.patchTaskToFailure("Error getting datacenters", e);
return;
}
VapiConnection vapi = VapiConnection.createFromVimConnection(connection);
try {
vapi.login();
LibraryClient libraryClient = vapi.newLibraryClient();
processAllLibraries(oldImages, request.resourceLink(), request.taskLink(), libraryClient, parent.tenantLinks);
mgr.patchTask(TaskStage.FINISHED);
} catch (Throwable t) {
mgr.patchTaskToFailure("Error processing library items", t);
return;
} finally {
vapi.close();
}
// garbage collection runs async
garbageCollectUntouchedImages(oldImages);
}
use of com.vmware.vim25.mo.Datacenter in project CloudStack-archive by CloudStack-extras.
the class DatacenterMO method getHostPropertiesOnDatacenterHostFolder.
public ObjectContent[] getHostPropertiesOnDatacenterHostFolder(String[] propertyPaths) throws Exception {
PropertySpec pSpec = new PropertySpec();
pSpec.setType("HostSystem");
pSpec.setPathSet(propertyPaths);
TraversalSpec computeResource2HostTraversal = new TraversalSpec();
computeResource2HostTraversal.setType("ComputeResource");
computeResource2HostTraversal.setPath("host");
computeResource2HostTraversal.setName("computeResource2HostTraversal");
SelectionSpec recurseFolders = new SelectionSpec();
recurseFolders.setName("folder2childEntity");
TraversalSpec folder2childEntity = new TraversalSpec();
folder2childEntity.setType("Folder");
folder2childEntity.setPath("childEntity");
folder2childEntity.setName(recurseFolders.getName());
folder2childEntity.setSelectSet(new SelectionSpec[] { recurseFolders, computeResource2HostTraversal });
TraversalSpec dc2HostFolderTraversal = new TraversalSpec();
dc2HostFolderTraversal.setType("Datacenter");
dc2HostFolderTraversal.setPath("hostFolder");
dc2HostFolderTraversal.setName("dc2HostFolderTraversal");
dc2HostFolderTraversal.setSelectSet(new SelectionSpec[] { folder2childEntity });
ObjectSpec oSpec = new ObjectSpec();
oSpec.setObj(_mor);
oSpec.setSkip(Boolean.TRUE);
oSpec.setSelectSet(new SelectionSpec[] { dc2HostFolderTraversal });
PropertyFilterSpec pfSpec = new PropertyFilterSpec();
pfSpec.setPropSet(new PropertySpec[] { pSpec });
pfSpec.setObjectSet(new ObjectSpec[] { oSpec });
return _context.getService().retrieveProperties(_context.getServiceContent().getPropertyCollector(), new PropertyFilterSpec[] { pfSpec });
}
use of com.vmware.vim25.mo.Datacenter 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.Datacenter in project cloudstack by apache.
the class DatacenterMO method getDvPortGroupSpec.
public DVPortgroupConfigInfo getDvPortGroupSpec(String dvPortGroupName) throws Exception {
DVPortgroupConfigInfo configSpec = null;
String nameProperty = null;
PropertySpec pSpec = new PropertySpec();
pSpec.setType("DistributedVirtualPortgroup");
pSpec.getPathSet().add("name");
pSpec.getPathSet().add("config");
TraversalSpec datacenter2DvPortGroupTraversal = new TraversalSpec();
datacenter2DvPortGroupTraversal.setType("Datacenter");
datacenter2DvPortGroupTraversal.setPath("network");
datacenter2DvPortGroupTraversal.setName("datacenter2DvPortgroupTraversal");
ObjectSpec oSpec = new ObjectSpec();
oSpec.setObj(_mor);
oSpec.setSkip(Boolean.TRUE);
oSpec.getSelectSet().add(datacenter2DvPortGroupTraversal);
PropertyFilterSpec pfSpec = new PropertyFilterSpec();
pfSpec.getPropSet().add(pSpec);
pfSpec.getObjectSet().add(oSpec);
List<PropertyFilterSpec> pfSpecArr = new ArrayList<PropertyFilterSpec>();
pfSpecArr.add(pfSpec);
List<ObjectContent> ocs = _context.getService().retrieveProperties(_context.getPropertyCollector(), pfSpecArr);
if (ocs != null) {
for (ObjectContent oc : ocs) {
List<DynamicProperty> props = oc.getPropSet();
if (props != null) {
assert (props.size() == 2);
for (DynamicProperty prop : props) {
if (prop.getName().equals("config")) {
configSpec = (DVPortgroupConfigInfo) prop.getVal();
} else {
nameProperty = prop.getVal().toString();
}
}
if (nameProperty.equalsIgnoreCase(dvPortGroupName)) {
return configSpec;
}
}
}
}
return null;
}
use of com.vmware.vim25.mo.Datacenter in project cloudstack by apache.
the class DatacenterMO method getDatastorePropertiesOnDatacenter.
public List<ObjectContent> getDatastorePropertiesOnDatacenter(String[] propertyPaths) throws Exception {
PropertySpec pSpec = new PropertySpec();
pSpec.setType("Datastore");
pSpec.getPathSet().addAll(Arrays.asList(propertyPaths));
TraversalSpec dc2DatastoreTraversal = new TraversalSpec();
dc2DatastoreTraversal.setType("Datacenter");
dc2DatastoreTraversal.setPath("datastore");
dc2DatastoreTraversal.setName("dc2DatastoreTraversal");
ObjectSpec oSpec = new ObjectSpec();
oSpec.setObj(_mor);
oSpec.setSkip(Boolean.TRUE);
oSpec.getSelectSet().add(dc2DatastoreTraversal);
PropertyFilterSpec pfSpec = new PropertyFilterSpec();
pfSpec.getPropSet().add(pSpec);
pfSpec.getObjectSet().add(oSpec);
List<PropertyFilterSpec> pfSpecArr = new ArrayList<PropertyFilterSpec>();
pfSpecArr.add(pfSpec);
return _context.getService().retrieveProperties(_context.getPropertyCollector(), pfSpecArr);
}
Aggregations