This is an automated email from the ASF dual-hosted git repository.

dahn pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/master by this push:
     new 08699aa  NPE fix for System VM's start Command (#3985)
08699aa is described below

commit 08699aa69076b6479bf9544f1375917e51be6a36
Author: pavanaravapalli <pavankuma...@accelerite.com>
AuthorDate: Wed Mar 25 14:31:13 2020 +0530

    NPE fix for System VM's start Command (#3985)
    
    Co-authored-by: Pavan Kumar Aravapalli <pavan_aravapa...@accelerite.com>
---
 .../main/java/com/cloud/hypervisor/guru/VMwareGuru.java |  2 +-
 .../hypervisor/vmware/resource/VmwareResource.java      |  4 ++--
 .../java/com/cloud/hypervisor/HypervisorGuruBase.java   | 17 ++++++++++++++---
 3 files changed, 17 insertions(+), 6 deletions(-)

diff --git 
a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/guru/VMwareGuru.java
 
b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/guru/VMwareGuru.java
index 4e8acad..59b27bd 100644
--- 
a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/guru/VMwareGuru.java
+++ 
b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/guru/VMwareGuru.java
@@ -294,7 +294,7 @@ public class VMwareGuru extends HypervisorGuruBase 
implements HypervisorGuru, Co
             }
         }
 
-        details.put(VmDetailConstants.BOOT_MODE, to.getBootType());
+        details.put(VmDetailConstants.BOOT_MODE, to.getBootMode());
         String diskDeviceType = 
details.get(VmDetailConstants.ROOT_DISK_CONTROLLER);
         if (userVm) {
             if (diskDeviceType == null) {
diff --git 
a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java
 
b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java
index 5a1459d..cc732f4 100644
--- 
a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java
+++ 
b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java
@@ -1724,7 +1724,7 @@ public class VmwareResource implements 
StoragePoolResource, ServerResource, Vmwa
         String dataDiskController = 
vmSpec.getDetails().get(VmDetailConstants.DATA_DISK_CONTROLLER);
         String rootDiskController = 
vmSpec.getDetails().get(VmDetailConstants.ROOT_DISK_CONTROLLER);
         DiskTO rootDiskTO = null;
-        String bootMode = ApiConstants.BootType.BIOS.toString();
+        String bootMode = "bios";
         if (vmSpec.getDetails().containsKey(VmDetailConstants.BOOT_MODE)) {
             bootMode = vmSpec.getDetails().get(VmDetailConstants.BOOT_MODE);
         }
@@ -2286,7 +2286,7 @@ public class VmwareResource implements 
StoragePoolResource, ServerResource, Vmwa
                 }
             }
 
-            if 
(!bootMode.equalsIgnoreCase(ApiConstants.BootType.BIOS.toString())) {
+            if (StringUtils.isNotBlank(bootMode) && 
!bootMode.equalsIgnoreCase("bios")) {
                 vmConfigSpec.setFirmware("efi");
                 if 
(vmSpec.getDetails().containsKey(ApiConstants.BootType.UEFI.toString()) && 
"secure".equalsIgnoreCase(vmSpec.getDetails().get(ApiConstants.BootType.UEFI.toString())))
 {
                     VirtualMachineBootOptions bootOptions = new 
VirtualMachineBootOptions();
diff --git a/server/src/main/java/com/cloud/hypervisor/HypervisorGuruBase.java 
b/server/src/main/java/com/cloud/hypervisor/HypervisorGuruBase.java
index 0c3263a..2ae35fc 100644
--- a/server/src/main/java/com/cloud/hypervisor/HypervisorGuruBase.java
+++ b/server/src/main/java/com/cloud/hypervisor/HypervisorGuruBase.java
@@ -26,6 +26,7 @@ import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.backup.Backup;
 import 
org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
 import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.collections.MapUtils;
 import org.apache.log4j.Logger;
 
 import com.cloud.agent.api.Command;
@@ -172,9 +173,19 @@ public abstract class HypervisorGuruBase extends 
AdapterBase implements Hypervis
                 offering.getRamSize() * 1024l * 1024l, null, null, 
vm.isHaEnabled(), vm.limitCpuUse(), vm.getVncPassword());
         to.setBootArgs(vmProfile.getBootArgs());
 
-        String bootType = (String)vmProfile.getParameter(new 
VirtualMachineProfile.Param("BootType"));
-        if (StringUtils.isNotBlank(bootType)) {
-            to.setBootType(bootType);
+        Map<VirtualMachineProfile.Param, Object> map = 
vmProfile.getParameters();
+        if (MapUtils.isNotEmpty(map)) {
+            if (map.containsKey(VirtualMachineProfile.Param.BootMode)) {
+                if (StringUtils.isNotBlank((String) 
map.get(VirtualMachineProfile.Param.BootMode))) {
+                    to.setBootMode((String) 
map.get(VirtualMachineProfile.Param.BootMode));
+                }
+            }
+
+            if (map.containsKey(VirtualMachineProfile.Param.BootType)) {
+                if (StringUtils.isNotBlank((String) 
map.get(VirtualMachineProfile.Param.BootType))) {
+                    to.setBootType((String) 
map.get(VirtualMachineProfile.Param.BootType));
+                }
+            }
         }
 
         List<NicProfile> nicProfiles = vmProfile.getNics();

Reply via email to