use of com.vmware.vim25.mo.ClusterComputeResource in project vsphere-cloud-plugin by jenkinsci.
the class VSphere method getDatastoreByName.
private Datastore getDatastoreByName(final String datastoreName, ManagedEntity rootEntity) throws RemoteException, MalformedURLException {
if (rootEntity == null) {
rootEntity = getServiceInstance().getRootFolder();
}
Datastore datastore = (Datastore) new InventoryNavigator(rootEntity).searchManagedEntity("Datastore", datastoreName);
if (datastore != null) {
return datastore;
}
if (rootEntity == null || !(rootEntity instanceof ClusterComputeResource)) {
return null;
}
// try to fetch data store directly from cluster if above approach doesn't work
ClusterComputeResource clusterResource = (ClusterComputeResource) rootEntity;
for (Datastore dataStore : clusterResource.getDatastores()) {
if (dataStore.getName().equals(datastoreName)) {
return dataStore;
}
}
return null;
}
use of com.vmware.vim25.mo.ClusterComputeResource in project cloudstack by apache.
the class HostMO method setRestartPriorityForVM.
@Override
public void setRestartPriorityForVM(VirtualMachineMO vmMo, String priority) throws Exception {
ManagedObjectReference morParent = getParentMor();
if (morParent.getType().equals("ClusterComputeResource")) {
ClusterMO clusterMo = new ClusterMO(_context, morParent);
clusterMo.setRestartPriorityForVM(vmMo, priority);
}
}
use of com.vmware.vim25.mo.ClusterComputeResource in project cloudstack by apache.
the class ClusterMO method getHostPropertiesOnCluster.
public ObjectContent[] getHostPropertiesOnCluster(String[] propertyPaths) throws Exception {
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - retrieveProperties() on Host properties. target MOR: " + _mor.getValue() + ", properties: " + new Gson().toJson(propertyPaths));
PropertySpec pSpec = new PropertySpec();
pSpec.setType("HostSystem");
pSpec.getPathSet().addAll(Arrays.asList(propertyPaths));
TraversalSpec cluster2HostTraversal = new TraversalSpec();
cluster2HostTraversal.setType("ClusterComputeResource");
cluster2HostTraversal.setPath("host");
cluster2HostTraversal.setName("cluster2HostTraversal");
ObjectSpec oSpec = new ObjectSpec();
oSpec.setObj(_mor);
oSpec.setSkip(Boolean.TRUE);
oSpec.getSelectSet().add(cluster2HostTraversal);
PropertyFilterSpec pfSpec = new PropertyFilterSpec();
pfSpec.getPropSet().add(pSpec);
pfSpec.getObjectSet().add(oSpec);
List<PropertyFilterSpec> pfSpecArr = new ArrayList<PropertyFilterSpec>();
pfSpecArr.add(pfSpec);
List<ObjectContent> properties = _context.getService().retrieveProperties(_context.getPropertyCollector(), pfSpecArr);
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - retrieveProperties() done");
return properties.toArray(new ObjectContent[properties.size()]);
}
use of com.vmware.vim25.mo.ClusterComputeResource in project cloudstack by apache.
the class ClusterMO method getDatastorePropertiesOnHyperHost.
@Override
public ObjectContent[] getDatastorePropertiesOnHyperHost(String[] propertyPaths) throws Exception {
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - retrieveProperties() on Datastore properties. target MOR: " + _mor.getValue() + ", properties: " + new Gson().toJson(propertyPaths));
PropertySpec pSpec = new PropertySpec();
pSpec.setType("Datastore");
pSpec.getPathSet().addAll(Arrays.asList(propertyPaths));
TraversalSpec cluster2DatastoreTraversal = new TraversalSpec();
cluster2DatastoreTraversal.setType("ClusterComputeResource");
cluster2DatastoreTraversal.setPath("datastore");
cluster2DatastoreTraversal.setName("cluster2DatastoreTraversal");
ObjectSpec oSpec = new ObjectSpec();
oSpec.setObj(_mor);
oSpec.setSkip(Boolean.TRUE);
oSpec.getSelectSet().add(cluster2DatastoreTraversal);
PropertyFilterSpec pfSpec = new PropertyFilterSpec();
pfSpec.getPropSet().add(pSpec);
pfSpec.getObjectSet().add(oSpec);
List<PropertyFilterSpec> pfSpecArr = new ArrayList<PropertyFilterSpec>();
pfSpecArr.add(pfSpec);
List<ObjectContent> properties = _context.getService().retrieveProperties(_context.getPropertyCollector(), pfSpecArr);
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - retrieveProperties() done");
return properties.toArray(new ObjectContent[properties.size()]);
}
use of com.vmware.vim25.mo.ClusterComputeResource in project CloudStack-archive by CloudStack-extras.
the class HostMO method getHyperHostCluster.
@Override
public ManagedObjectReference getHyperHostCluster() throws Exception {
ServiceUtil serviceUtil = _context.getServiceUtil();
ManagedObjectReference morParent = (ManagedObjectReference) serviceUtil.getDynamicProperty(_mor, "parent");
if (morParent.getType().equalsIgnoreCase("ClusterComputeResource")) {
return morParent;
}
assert (false);
throw new Exception("Standalone host is not supported");
}
Aggregations