Search in sources :

Example 31 with ManagedObjectReference

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

the class VirtualMachineMO method getDvPortGroupName.

public String getDvPortGroupName(VirtualEthernetCard nic) throws Exception {
    VirtualEthernetCardDistributedVirtualPortBackingInfo dvpBackingInfo = (VirtualEthernetCardDistributedVirtualPortBackingInfo) ((VirtualEthernetCard) nic).getBacking();
    DistributedVirtualSwitchPortConnection dvsPort = (DistributedVirtualSwitchPortConnection) dvpBackingInfo.getPort();
    String dvPortGroupKey = dvsPort.getPortgroupKey();
    ManagedObjectReference dvPortGroupMor = new ManagedObjectReference();
    dvPortGroupMor.set_value(dvPortGroupKey);
    dvPortGroupMor.setType("DistributedVirtualPortgroup");
    return (String) _context.getServiceUtil().getDynamicProperty(dvPortGroupMor, "name");
}
Also used : VirtualEthernetCardDistributedVirtualPortBackingInfo(com.vmware.vim25.VirtualEthernetCardDistributedVirtualPortBackingInfo) DistributedVirtualSwitchPortConnection(com.vmware.vim25.DistributedVirtualSwitchPortConnection) ArrayOfManagedObjectReference(com.vmware.vim25.ArrayOfManagedObjectReference) ManagedObjectReference(com.vmware.vim25.ManagedObjectReference)

Example 32 with ManagedObjectReference

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

the class VirtualMachineMO method configureVm.

public boolean configureVm(Ternary<VirtualDevice, VirtualDeviceConfigSpecOperation, VirtualDeviceConfigSpecFileOperation>[] devices) throws Exception {
    assert (devices != null);
    VirtualMachineConfigSpec configSpec = new VirtualMachineConfigSpec();
    VirtualDeviceConfigSpec[] deviceConfigSpecArray = new VirtualDeviceConfigSpec[devices.length];
    int i = 0;
    for (Ternary<VirtualDevice, VirtualDeviceConfigSpecOperation, VirtualDeviceConfigSpecFileOperation> deviceTernary : devices) {
        VirtualDeviceConfigSpec deviceConfigSpec = new VirtualDeviceConfigSpec();
        deviceConfigSpec.setDevice(deviceTernary.first());
        deviceConfigSpec.setOperation(deviceTernary.second());
        deviceConfigSpec.setFileOperation(deviceTernary.third());
        deviceConfigSpecArray[i++] = deviceConfigSpec;
    }
    configSpec.setDeviceChange(deviceConfigSpecArray);
    ManagedObjectReference morTask = _context.getService().reconfigVM_Task(_mor, configSpec);
    String result = _context.getServiceUtil().waitForTask(morTask);
    if (result.equals("sucess")) {
        _context.waitForTaskProgressDone(morTask);
        return true;
    } else {
        s_logger.error("VMware reconfigVM_Task failed due to " + TaskMO.getTaskFailureInfo(_context, morTask));
    }
    return false;
}
Also used : VirtualDeviceConfigSpecFileOperation(com.vmware.vim25.VirtualDeviceConfigSpecFileOperation) VirtualMachineConfigSpec(com.vmware.vim25.VirtualMachineConfigSpec) VirtualDeviceConfigSpec(com.vmware.vim25.VirtualDeviceConfigSpec) VirtualDeviceConfigSpecOperation(com.vmware.vim25.VirtualDeviceConfigSpecOperation) VirtualDevice(com.vmware.vim25.VirtualDevice) ArrayOfManagedObjectReference(com.vmware.vim25.ArrayOfManagedObjectReference) ManagedObjectReference(com.vmware.vim25.ManagedObjectReference)

Example 33 with ManagedObjectReference

use of com.vmware.vim25.ManagedObjectReference 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 34 with ManagedObjectReference

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

the class HostMO method getHostFirewallSystemMO.

public HostFirewallSystemMO getHostFirewallSystemMO() throws Exception {
    HostConfigManager configMgr = getHostConfigManager();
    ManagedObjectReference morFirewall = configMgr.getFirewallSystem();
    // only ESX hosts have firewall manager
    if (morFirewall != null)
        return new HostFirewallSystemMO(_context, morFirewall);
    return null;
}
Also used : HostConfigManager(com.vmware.vim25.HostConfigManager) ManagedObjectReference(com.vmware.vim25.ManagedObjectReference)

Example 35 with ManagedObjectReference

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

the class HostMO method getLocalDatastoreOnHost.

public List<Pair<ManagedObjectReference, String>> getLocalDatastoreOnHost() throws Exception {
    List<Pair<ManagedObjectReference, String>> dsList = new ArrayList<Pair<ManagedObjectReference, String>>();
    ObjectContent[] ocs = getDatastorePropertiesOnHyperHost(new String[] { "name", "summary" });
    if (ocs != null) {
        for (ObjectContent oc : ocs) {
            DatastoreSummary dsSummary = (DatastoreSummary) VmwareHelper.getPropValue(oc, "summary");
            if (dsSummary.getMultipleHostAccess() == false && dsSummary.isAccessible() && dsSummary.getType().equalsIgnoreCase("vmfs")) {
                ManagedObjectReference morDs = oc.getObj();
                String name = (String) VmwareHelper.getPropValue(oc, "name");
                dsList.add(new Pair<ManagedObjectReference, String>(morDs, name));
            }
        }
    }
    return dsList;
}
Also used : ObjectContent(com.vmware.vim25.ObjectContent) DatastoreSummary(com.vmware.vim25.DatastoreSummary) ArrayList(java.util.ArrayList) ManagedObjectReference(com.vmware.vim25.ManagedObjectReference) Pair(com.cloud.utils.Pair)

Aggregations

ManagedObjectReference (com.vmware.vim25.ManagedObjectReference)236 ArrayOfManagedObjectReference (com.vmware.vim25.ArrayOfManagedObjectReference)62 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)57 Pair (com.cloud.utils.Pair)49 RemoteException (java.rmi.RemoteException)48 ArrayList (java.util.ArrayList)45 UnsupportedEncodingException (java.io.UnsupportedEncodingException)39 VmwareHypervisorHost (com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost)35 VmwareContext (com.cloud.hypervisor.vmware.util.VmwareContext)32 IOException (java.io.IOException)31 CloudException (com.cloud.exception.CloudException)30 DatastoreMO (com.cloud.hypervisor.vmware.mo.DatastoreMO)30 VirtualMachineConfigSpec (com.vmware.vim25.VirtualMachineConfigSpec)29 ObjectContent (com.vmware.vim25.ObjectContent)28 VirtualDeviceConfigSpec (com.vmware.vim25.VirtualDeviceConfigSpec)27 VirtualMachineMO (com.cloud.hypervisor.vmware.mo.VirtualMachineMO)25 ConfigurationException (javax.naming.ConfigurationException)24 InternalErrorException (com.cloud.exception.InternalErrorException)23 VirtualDisk (com.vmware.vim25.VirtualDisk)23 ConnectException (java.net.ConnectException)23