Search in sources :

Example 1 with ServiceUtil

use of com.vmware.apputils.vim25.ServiceUtil in project CloudStack-archive by CloudStack-extras.

the class HostMO method getHyperHostOwnerResourcePool.

@Override
public ManagedObjectReference getHyperHostOwnerResourcePool() throws Exception {
    ServiceUtil serviceUtil = _context.getServiceUtil();
    ManagedObjectReference morComputerResource = (ManagedObjectReference) serviceUtil.getDynamicProperty(_mor, "parent");
    return (ManagedObjectReference) serviceUtil.getDynamicProperty(morComputerResource, "resourcePool");
}
Also used : ServiceUtil(com.vmware.apputils.vim25.ServiceUtil) ManagedObjectReference(com.vmware.vim25.ManagedObjectReference)

Example 2 with ServiceUtil

use of com.vmware.apputils.vim25.ServiceUtil in project CloudStack-archive by CloudStack-extras.

the class HostMO method getHostLocalDatastore.

public ManagedObjectReference[] getHostLocalDatastore() throws Exception {
    ServiceUtil serviceUtil = _context.getServiceUtil();
    ManagedObjectReference[] datastores = (ManagedObjectReference[]) serviceUtil.getDynamicProperty(_mor, "datastore");
    List<ManagedObjectReference> l = new ArrayList<ManagedObjectReference>();
    if (datastores != null) {
        for (ManagedObjectReference mor : datastores) {
            DatastoreSummary summary = (DatastoreSummary) serviceUtil.getDynamicProperty(mor, "summary");
            if (summary.getType().equalsIgnoreCase("VMFS") && !summary.getMultipleHostAccess())
                l.add(mor);
        }
    }
    return l.toArray(new ManagedObjectReference[1]);
}
Also used : DatastoreSummary(com.vmware.vim25.DatastoreSummary) ArrayList(java.util.ArrayList) ServiceUtil(com.vmware.apputils.vim25.ServiceUtil) ManagedObjectReference(com.vmware.vim25.ManagedObjectReference)

Example 3 with ServiceUtil

use of com.vmware.apputils.vim25.ServiceUtil 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)

Example 4 with ServiceUtil

use of com.vmware.apputils.vim25.ServiceUtil in project CloudStack-archive by CloudStack-extras.

the class DatacenterMO method registerTemplate.

public void registerTemplate(ManagedObjectReference morHost, String datastoreName, String templateName, String templateFileName) throws Exception {
    ServiceUtil serviceUtil = _context.getServiceUtil();
    ManagedObjectReference morFolder = (ManagedObjectReference) serviceUtil.getDynamicProperty(_mor, "vmFolder");
    assert (morFolder != null);
    ManagedObjectReference morTask = _context.getService().registerVM_Task(morFolder, String.format("[%s] %s/%s", datastoreName, templateName, templateFileName), templateName, true, null, morHost);
    String result = serviceUtil.waitForTask(morTask);
    if (!result.equalsIgnoreCase("Sucess")) {
        throw new Exception("Unable to register template due to " + TaskMO.getTaskFailureInfo(_context, morTask));
    } else {
        _context.waitForTaskProgressDone(morTask);
    }
}
Also used : ServiceUtil(com.vmware.apputils.vim25.ServiceUtil) ManagedObjectReference(com.vmware.vim25.ManagedObjectReference)

Aggregations

ServiceUtil (com.vmware.apputils.vim25.ServiceUtil)4 ManagedObjectReference (com.vmware.vim25.ManagedObjectReference)4 DatastoreSummary (com.vmware.vim25.DatastoreSummary)1 ArrayList (java.util.ArrayList)1