Search in sources :

Example 1 with VirtualMachineGuestOsIdentifier

use of com.vmware.vim25.VirtualMachineGuestOsIdentifier in project cloudstack by apache.

the class VmwareResource method translateGuestOsIdentifier.

private VirtualMachineGuestOsIdentifier translateGuestOsIdentifier(String cpuArchitecture, String guestOs, String cloudGuestOs) {
    if (cpuArchitecture == null) {
        s_logger.warn("CPU arch is not set, default to i386. guest os: " + guestOs);
        cpuArchitecture = "i386";
    }
    if (cloudGuestOs == null) {
        s_logger.warn("Guest OS mapping name is not set for guest os: " + guestOs);
    }
    VirtualMachineGuestOsIdentifier identifier = null;
    try {
        if (cloudGuestOs != null) {
            identifier = VirtualMachineGuestOsIdentifier.fromValue(cloudGuestOs);
            s_logger.debug("Using mapping name : " + identifier.toString());
        }
    } catch (IllegalArgumentException e) {
        s_logger.warn("Unable to find Guest OS Identifier in VMware for mapping name: " + cloudGuestOs + ". Continuing with defaults.");
    }
    if (identifier != null) {
        return identifier;
    }
    if (cpuArchitecture.equalsIgnoreCase("x86_64")) {
        return VirtualMachineGuestOsIdentifier.OTHER_GUEST_64;
    }
    return VirtualMachineGuestOsIdentifier.OTHER_GUEST;
}
Also used : VirtualMachineGuestOsIdentifier(com.vmware.vim25.VirtualMachineGuestOsIdentifier)

Example 2 with VirtualMachineGuestOsIdentifier

use of com.vmware.vim25.VirtualMachineGuestOsIdentifier in project cloudstack by apache.

the class VmwareResource method getUnmanagedInstance.

private UnmanagedInstanceTO getUnmanagedInstance(VmwareHypervisorHost hyperHost, VirtualMachineMO vmMo) {
    UnmanagedInstanceTO instance = null;
    try {
        instance = new UnmanagedInstanceTO();
        instance.setName(vmMo.getVmName());
        instance.setInternalCSName(vmMo.getInternalCSName());
        instance.setCpuCores(vmMo.getConfigSummary().getNumCpu());
        instance.setCpuCoresPerSocket(vmMo.getCoresPerSocket());
        instance.setCpuSpeed(vmMo.getConfigSummary().getCpuReservation());
        instance.setMemory(vmMo.getConfigSummary().getMemorySizeMB());
        instance.setOperatingSystemId(vmMo.getVmGuestInfo().getGuestId());
        if (StringUtils.isEmpty(instance.getOperatingSystemId())) {
            instance.setOperatingSystemId(vmMo.getConfigSummary().getGuestId());
        }
        VirtualMachineGuestOsIdentifier osIdentifier = VirtualMachineGuestOsIdentifier.OTHER_GUEST;
        try {
            osIdentifier = VirtualMachineGuestOsIdentifier.fromValue(instance.getOperatingSystemId());
        } catch (IllegalArgumentException iae) {
            if (StringUtils.isNotEmpty(instance.getOperatingSystemId()) && instance.getOperatingSystemId().contains("64")) {
                osIdentifier = VirtualMachineGuestOsIdentifier.OTHER_GUEST_64;
            }
        }
        instance.setOperatingSystem(vmMo.getGuestInfo().getGuestFullName());
        if (StringUtils.isEmpty(instance.getOperatingSystem())) {
            instance.setOperatingSystem(vmMo.getConfigSummary().getGuestFullName());
        }
        UnmanagedInstanceTO.PowerState powerState = UnmanagedInstanceTO.PowerState.PowerUnknown;
        if (vmMo.getPowerState().toString().equalsIgnoreCase("POWERED_ON")) {
            powerState = UnmanagedInstanceTO.PowerState.PowerOn;
        }
        if (vmMo.getPowerState().toString().equalsIgnoreCase("POWERED_OFF")) {
            powerState = UnmanagedInstanceTO.PowerState.PowerOff;
        }
        instance.setPowerState(powerState);
        instance.setDisks(getUnmanageInstanceDisks(vmMo));
        instance.setNics(getUnmanageInstanceNics(hyperHost, vmMo));
    } catch (Exception e) {
        s_logger.info("Unable to retrieve unmanaged instance info. " + e.getMessage());
    }
    return instance;
}
Also used : UnmanagedInstanceTO(org.apache.cloudstack.vm.UnmanagedInstanceTO) VirtualMachineGuestOsIdentifier(com.vmware.vim25.VirtualMachineGuestOsIdentifier) ConnectException(java.net.ConnectException) IOException(java.io.IOException) RemoteException(java.rmi.RemoteException) InternalErrorException(com.cloud.exception.InternalErrorException) CloudException(com.cloud.exception.CloudException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ConfigurationException(javax.naming.ConfigurationException)

Aggregations

VirtualMachineGuestOsIdentifier (com.vmware.vim25.VirtualMachineGuestOsIdentifier)2 CloudException (com.cloud.exception.CloudException)1 InternalErrorException (com.cloud.exception.InternalErrorException)1 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ConnectException (java.net.ConnectException)1 RemoteException (java.rmi.RemoteException)1 ConfigurationException (javax.naming.ConfigurationException)1 UnmanagedInstanceTO (org.apache.cloudstack.vm.UnmanagedInstanceTO)1