@@ -5796,6 +5796,7 @@ public Pair<UserVmVO, Map<VirtualMachineProfile.Param, Object>> startVirtualMach
57965796
57975797 // Set parameters
57985798 Map<VirtualMachineProfile.Param, Object> params = new HashMap<>();
5799+ params.putAll(additionalParams);
57995800 if (vm.isUpdateParameters()) {
58005801 _vmDao.loadDetails(vm);
58015802
@@ -5809,18 +5810,19 @@ public Pair<UserVmVO, Map<VirtualMachineProfile.Param, Object>> startVirtualMach
58095810 // use it to encrypt & save the vm password
58105811 encryptAndStorePassword(vm, password);
58115812
5812- params = createParameterInParameterMap(params, additionalParams, VirtualMachineProfile.Param.VmPassword, password);
5813+ // overwrite VmPassword
5814+ params = createParameterInParameterMap(params, VirtualMachineProfile.Param.VmPassword, password);
58135815 }
58145816
58155817 if(additionalParams.containsKey(VirtualMachineProfile.Param.BootIntoSetup)) {
58165818 if (! HypervisorType.VMware.equals(vm.getHypervisorType())) {
58175819 throw new InvalidParameterValueException(ApiConstants.BOOT_INTO_SETUP + " makes no sense for " + vm.getHypervisorType());
58185820 }
5821+
5822+ //overwrite BootIntoSetup
58195823 Object paramValue = additionalParams.get(VirtualMachineProfile.Param.BootIntoSetup);
5820- if (logger.isTraceEnabled()) {
5821- logger.trace("It was specified whether to enter setup mode: " + paramValue.toString());
5822- }
5823- params = createParameterInParameterMap(params, additionalParams, VirtualMachineProfile.Param.BootIntoSetup, paramValue);
5824+ logger.trace("It was specified whether to enter setup mode: {}", paramValue.toString());
5825+ params = createParameterInParameterMap(params, VirtualMachineProfile.Param.BootIntoSetup, paramValue);
58245826 }
58255827
58265828 VirtualMachineEntity vmEntity = _orchSrvc.getVirtualMachine(vm.getUuid());
@@ -5888,20 +5890,18 @@ protected String getCurrentVmPasswordOrDefineNewPassword(String newPassword, Use
58885890 return password;
58895891 }
58905892
5891- private Map<VirtualMachineProfile.Param, Object> createParameterInParameterMap(Map<VirtualMachineProfile.Param, Object> params, Map<VirtualMachineProfile.Param, Object> parameterMap, VirtualMachineProfile.Param parameter,
5893+ /**
5894+ * Create or overwrite a parameter in the list
5895+ * @param params the list of parameters
5896+ * @param parameter the parameter to creat/overwrite
5897+ * @param parameterValue the value to give to the parameter
5898+ * @return the resulting updated list of parameters
5899+ */
5900+ private Map<VirtualMachineProfile.Param, Object> createParameterInParameterMap(
5901+ Map<VirtualMachineProfile.Param, Object> params,
5902+ VirtualMachineProfile.Param parameter,
58925903 Object parameterValue) {
5893- if (logger.isTraceEnabled()) {
5894- logger.trace(String.format("createParameterInParameterMap(%s, %s)", parameter, parameterValue));
5895- }
5896- if (params == null) {
5897- if (logger.isTraceEnabled()) {
5898- logger.trace("creating new Parameter map");
5899- }
5900- params = new HashMap<>();
5901- if (parameterMap != null) {
5902- params.putAll(parameterMap);
5903- }
5904- }
5904+ logger.trace("createParameterInParameterMap({}, {})", parameter, parameterValue);
59055905 params.put(parameter, parameterValue);
59065906 return params;
59075907 }
0 commit comments