Search in sources :

Example 16 with ClusterComputeResource

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;
}
Also used : ClusterComputeResource(com.vmware.vim25.mo.ClusterComputeResource) Datastore(com.vmware.vim25.mo.Datastore) InventoryNavigator(com.vmware.vim25.mo.InventoryNavigator)

Example 17 with ClusterComputeResource

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);
    }
}
Also used : ManagedObjectReference(com.vmware.vim25.ManagedObjectReference)

Example 18 with ClusterComputeResource

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()]);
}
Also used : PropertyFilterSpec(com.vmware.vim25.PropertyFilterSpec) ObjectContent(com.vmware.vim25.ObjectContent) ObjectSpec(com.vmware.vim25.ObjectSpec) PropertySpec(com.vmware.vim25.PropertySpec) TraversalSpec(com.vmware.vim25.TraversalSpec) ArrayList(java.util.ArrayList) Gson(com.google.gson.Gson)

Example 19 with ClusterComputeResource

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()]);
}
Also used : PropertyFilterSpec(com.vmware.vim25.PropertyFilterSpec) ObjectContent(com.vmware.vim25.ObjectContent) ObjectSpec(com.vmware.vim25.ObjectSpec) PropertySpec(com.vmware.vim25.PropertySpec) TraversalSpec(com.vmware.vim25.TraversalSpec) ArrayList(java.util.ArrayList) Gson(com.google.gson.Gson)

Example 20 with ClusterComputeResource

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");
}
Also used : ServiceUtil(com.vmware.apputils.vim25.ServiceUtil) ManagedObjectReference(com.vmware.vim25.ManagedObjectReference)

Aggregations

ClusterComputeResource (com.vmware.vim25.mo.ClusterComputeResource)14 HostSystem (com.vmware.vim25.mo.HostSystem)13 ManagedObjectReference (com.vmware.vim25.ManagedObjectReference)10 VcenterObjectConnectionException (com.emc.storageos.vcentercontroller.exceptions.VcenterObjectConnectionException)9 VcenterObjectNotFoundException (com.emc.storageos.vcentercontroller.exceptions.VcenterObjectNotFoundException)9 ObjectSpec (com.vmware.vim25.ObjectSpec)9 PropertyFilterSpec (com.vmware.vim25.PropertyFilterSpec)9 PropertySpec (com.vmware.vim25.PropertySpec)9 TraversalSpec (com.vmware.vim25.TraversalSpec)9 ObjectContent (com.vmware.vim25.ObjectContent)8 VcenterServerConnectionException (com.emc.storageos.vcentercontroller.exceptions.VcenterServerConnectionException)7 VcenterSystemException (com.emc.storageos.vcentercontroller.exceptions.VcenterSystemException)7 ArrayList (java.util.ArrayList)7 HostScsiDisk (com.vmware.vim25.HostScsiDisk)6 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)5 Datastore (com.vmware.vim25.mo.Datastore)5 Pair (com.cloud.utils.Pair)4 ExpandVmfsDatastore (com.emc.sa.service.vmware.block.tasks.ExpandVmfsDatastore)4 ExtendVmfsDatastore (com.emc.sa.service.vmware.block.tasks.ExtendVmfsDatastore)4 VcenterDataCenter (com.emc.storageos.db.client.model.VcenterDataCenter)4