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;
}
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;
}
Aggregations