Skip to content

Commit e213cea

Browse files
author
Pavan Kumar Aravapalli
committed
NPE fix for System VM's start Command
1 parent 36efbfc commit e213cea

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/guru/VMwareGuru.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ public VirtualMachineTO implement(VirtualMachineProfile vm) {
294294
}
295295
}
296296

297-
details.put(VmDetailConstants.BOOT_MODE, to.getBootType());
297+
details.put(VmDetailConstants.BOOT_MODE, to.getBootMode());
298298
String diskDeviceType = details.get(VmDetailConstants.ROOT_DISK_CONTROLLER);
299299
if (userVm) {
300300
if (diskDeviceType == null) {

plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1724,7 +1724,7 @@ protected StartAnswer execute(StartCommand cmd) {
17241724
String dataDiskController = vmSpec.getDetails().get(VmDetailConstants.DATA_DISK_CONTROLLER);
17251725
String rootDiskController = vmSpec.getDetails().get(VmDetailConstants.ROOT_DISK_CONTROLLER);
17261726
DiskTO rootDiskTO = null;
1727-
String bootMode = ApiConstants.BootType.BIOS.toString();
1727+
String bootMode = "bios";
17281728
if (vmSpec.getDetails().containsKey(VmDetailConstants.BOOT_MODE)) {
17291729
bootMode = vmSpec.getDetails().get(VmDetailConstants.BOOT_MODE);
17301730
}
@@ -2286,7 +2286,7 @@ protected StartAnswer execute(StartCommand cmd) {
22862286
}
22872287
}
22882288

2289-
if (!bootMode.equalsIgnoreCase(ApiConstants.BootType.BIOS.toString())) {
2289+
if (StringUtils.isNotBlank(bootMode) && !bootMode.equalsIgnoreCase("bios")) {
22902290
vmConfigSpec.setFirmware("efi");
22912291
if (vmSpec.getDetails().containsKey(ApiConstants.BootType.UEFI.toString()) && "secure".equalsIgnoreCase(vmSpec.getDetails().get(ApiConstants.BootType.UEFI.toString()))) {
22922292
VirtualMachineBootOptions bootOptions = new VirtualMachineBootOptions();

server/src/main/java/com/cloud/hypervisor/HypervisorGuruBase.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.apache.cloudstack.backup.Backup;
2727
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
2828
import org.apache.commons.collections.CollectionUtils;
29+
import org.apache.commons.collections.MapUtils;
2930
import org.apache.log4j.Logger;
3031

3132
import com.cloud.agent.api.Command;
@@ -172,9 +173,19 @@ protected VirtualMachineTO toVirtualMachineTO(VirtualMachineProfile vmProfile) {
172173
offering.getRamSize() * 1024l * 1024l, null, null, vm.isHaEnabled(), vm.limitCpuUse(), vm.getVncPassword());
173174
to.setBootArgs(vmProfile.getBootArgs());
174175

175-
String bootType = (String)vmProfile.getParameter(new VirtualMachineProfile.Param("BootType"));
176-
if (StringUtils.isNotBlank(bootType)) {
177-
to.setBootType(bootType);
176+
Map<VirtualMachineProfile.Param, Object> map = vmProfile.getParameters();
177+
if (MapUtils.isNotEmpty(map)) {
178+
if (map.containsKey(VirtualMachineProfile.Param.BootMode)) {
179+
if (StringUtils.isNotBlank((String) map.get(VirtualMachineProfile.Param.BootMode))) {
180+
to.setBootMode((String) map.get(VirtualMachineProfile.Param.BootMode));
181+
}
182+
}
183+
184+
if (map.containsKey(VirtualMachineProfile.Param.BootType)) {
185+
if (StringUtils.isNotBlank((String) map.get(VirtualMachineProfile.Param.BootType))) {
186+
to.setBootType((String) map.get(VirtualMachineProfile.Param.BootType));
187+
}
188+
}
178189
}
179190

180191
List<NicProfile> nicProfiles = vmProfile.getNics();

0 commit comments

Comments
 (0)