Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,8 @@ public Map<String, String> getDetails() {
customparameterMap.put(getBootType().toString(), getBootMode().toString());
}

if (rootdisksize != null && !customparameterMap.containsKey("rootdisksize")) {
customparameterMap.put("rootdisksize", rootdisksize.toString());
if (rootdisksize != null && !customparameterMap.containsKey(VmDetailConstants.ROOT_DISK_SIZE)) {
customparameterMap.put(VmDetailConstants.ROOT_DISK_SIZE, rootdisksize.toString());
}

IoDriverPolicy ioPolicy = getIoDriverPolicy();
Expand Down
17 changes: 10 additions & 7 deletions server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -3933,7 +3933,7 @@ private UserVm createVirtualMachine(DataCenter zone, ServiceOffering serviceOffe
rootDiskOfferingId = diskOfferingId;
diskOfferingId = null;
}
if (!customParameters.containsKey(VmDetailConstants.ROOT_DISK_SIZE)) {
if (!customParameters.containsKey(VmDetailConstants.ROOT_DISK_SIZE) && diskSize != null) {
customParameters.put(VmDetailConstants.ROOT_DISK_SIZE, String.valueOf(diskSize));
}
}
Expand Down Expand Up @@ -4320,7 +4320,14 @@ public boolean checkIfDynamicScalingCanBeEnabled(VirtualMachine vm, ServiceOffer
*/
protected long configureCustomRootDiskSize(Map<String, String> customParameters, VMTemplateVO template, HypervisorType hypervisorType, DiskOfferingVO rootDiskOffering) {
verifyIfHypervisorSupportsRootdiskSizeOverride(hypervisorType);
long rootDiskSizeInBytes = verifyAndGetDiskSize(rootDiskOffering, NumbersUtil.parseLong(customParameters.get(VmDetailConstants.ROOT_DISK_SIZE), -1));
Long rootDiskSizeCustomParam = null;
if (customParameters.containsKey(VmDetailConstants.ROOT_DISK_SIZE)) {
rootDiskSizeCustomParam = NumbersUtil.parseLong(customParameters.get(VmDetailConstants.ROOT_DISK_SIZE), -1);
if (rootDiskSizeCustomParam <= 0) {
throw new InvalidParameterValueException("Root disk size should be a positive number.");
}
}
long rootDiskSizeInBytes = verifyAndGetDiskSize(rootDiskOffering, rootDiskSizeCustomParam);
if (rootDiskSizeInBytes > 0) { //if the size at DiskOffering is not zero then the Service Offering had it configured, it holds priority over the User custom size
_volumeService.validateVolumeSizeInBytes(rootDiskSizeInBytes);
long rootDiskSizeInGiB = rootDiskSizeInBytes / GiB_TO_BYTES;
Expand All @@ -4329,11 +4336,7 @@ protected long configureCustomRootDiskSize(Map<String, String> customParameters,
}

if (customParameters.containsKey(VmDetailConstants.ROOT_DISK_SIZE)) {
Long rootDiskSize = NumbersUtil.parseLong(customParameters.get(VmDetailConstants.ROOT_DISK_SIZE), -1);
if (rootDiskSize <= 0) {
throw new InvalidParameterValueException("Root disk size should be a positive number.");
}
rootDiskSize *= GiB_TO_BYTES;
Long rootDiskSize = rootDiskSizeCustomParam * GiB_TO_BYTES;
_volumeService.validateVolumeSizeInBytes(rootDiskSize);
return rootDiskSize;
} else {
Expand Down