mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
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.
This commit is contained in:
parent
c7a55eb812
commit
2ccea134ae
@ -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";
|
||||
}
|
||||
|
||||
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
@ -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()));
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user