This is an automated email from the ASF dual-hosted git repository.
bhaisaab 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 2ccea13 CLOUDSTACK-10056: Fix vm details usage (#2248)
2ccea13 is described below
commit 2ccea134ae6977c6e8a8467a7ddd3c298a080974
Author: Nathan Johnson <[email protected]>
AuthorDate: Sat Sep 16 01:31:03 2017 -0500
CLOUDSTACK-10056: Fix vm details usage (#2248)
Fix bug where disk controller specified via vm details throws
a NumberFormatException, since "scsi" is not a number.
---
api/src/com/cloud/vm/VmDetailConstants.java | 3 +++
server/src/com/cloud/vm/UserVmManagerImpl.java | 12 +++++++++---
server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java | 3 ++-
3 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/api/src/com/cloud/vm/VmDetailConstants.java
b/api/src/com/cloud/vm/VmDetailConstants.java
index c3c6db7..f24c4f5 100644
--- a/api/src/com/cloud/vm/VmDetailConstants.java
+++ b/api/src/com/cloud/vm/VmDetailConstants.java
@@ -24,4 +24,7 @@ public interface VmDetailConstants {
public static final String HYPERVISOR_TOOLS_VERSION =
"hypervisortoolsversion";
public static final String DATA_DISK_CONTROLLER = "dataDiskController";
public static final String SVGA_VRAM_SIZE = "svga.vramSize";
+ public static final String CPU_NUMBER = "cpuNumber";
+ public static final String CPU_SPEED = "cpuSpeed";
+ public static final String MEMORY = "memory";
}
diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java
b/server/src/com/cloud/vm/UserVmManagerImpl.java
index c74507c..3f8a133 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -3619,8 +3619,14 @@ public class UserVmManagerImpl extends ManagerBase
implements UserVmManager, Vir
_vmDao.persist(vm);
for (String key : customParameters.keySet()) {
- //handle double byte strings.
- vm.setDetail(key,
Integer.toString(Integer.parseInt(customParameters.get(key))));
+ if( key.equalsIgnoreCase(VmDetailConstants.CPU_NUMBER) ||
+ key.equalsIgnoreCase(VmDetailConstants.CPU_SPEED)
||
+ key.equalsIgnoreCase(VmDetailConstants.MEMORY)) {
+ // handle double byte strings.
+ vm.setDetail(key,
Integer.toString(Integer.parseInt(customParameters.get(key))));
+ } else {
+ vm.setDetail(key, customParameters.get(key));
+ }
}
vm.setDetail("deployvm", "true");
_vmDao.saveDetails(vm);
@@ -4587,7 +4593,7 @@ public class UserVmManagerImpl extends ManagerBase
implements UserVmManager, Vir
if(!serviceOffering.isDynamic()) {
for(String detail: cmd.getDetails().keySet()) {
- if(detail.equalsIgnoreCase("cpuNumber") ||
detail.equalsIgnoreCase("cpuSpeed") || detail.equalsIgnoreCase("memory")) {
+ if(detail.equalsIgnoreCase(VmDetailConstants.CPU_NUMBER) ||
detail.equalsIgnoreCase(VmDetailConstants.CPU_SPEED) ||
detail.equalsIgnoreCase(VmDetailConstants.MEMORY)) {
throw new InvalidParameterValueException("cpuNumber or
cpuSpeed or memory should not be specified for static service offering");
}
}
diff --git a/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java
b/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java
index 97e46a7..a84db08 100644
--- a/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java
+++ b/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java
@@ -102,6 +102,7 @@ import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.vm.UserVmDetailVO;
import com.cloud.vm.UserVmManager;
import com.cloud.vm.UserVmVO;
+import com.cloud.vm.VmDetailConstants;
import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachine.State;
@@ -413,7 +414,7 @@ public class VMSnapshotManagerImpl extends
MutualExclusiveIdsManagerBase impleme
List<UserVmDetailVO> vmDetails =
_userVmDetailsDao.listDetails(vmId);
List<VMSnapshotDetailsVO> vmSnapshotDetails = new
ArrayList<VMSnapshotDetailsVO>();
for (UserVmDetailVO detail : vmDetails) {
- if(detail.getName().equalsIgnoreCase("cpuNumber") ||
detail.getName().equalsIgnoreCase("cpuSpeed") ||
detail.getName().equalsIgnoreCase("memory")) {
+
if(detail.getName().equalsIgnoreCase(VmDetailConstants.CPU_NUMBER) ||
detail.getName().equalsIgnoreCase(VmDetailConstants.CPU_SPEED) ||
detail.getName().equalsIgnoreCase(VmDetailConstants.MEMORY)) {
vmSnapshotDetails.add(new
VMSnapshotDetailsVO(vmSnapshotId, detail.getName(), detail.getValue(),
detail.isDisplay()));
}
}
--
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].