Skip to content
Merged
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
17 changes: 13 additions & 4 deletions server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -2042,13 +2042,25 @@ private void changeDiskOfferingForRootVolume(Long vmId, DiskOfferingVO newDiskOf

for (final VolumeVO rootVolumeOfVm : vols) {
DiskOfferingVO currentRootDiskOffering = _diskOfferingDao.findById(rootVolumeOfVm.getDiskOfferingId());
Long rootDiskSize= null;
Long rootDiskSizeBytes = null;
if (customParameters.containsKey(ApiConstants.ROOT_DISK_SIZE)) {
rootDiskSize = Long.parseLong(customParameters.get(ApiConstants.ROOT_DISK_SIZE));
rootDiskSizeBytes = rootDiskSize << 30;
}
if (currentRootDiskOffering.getId() == newDiskOffering.getId() &&
(!newDiskOffering.isCustomized() || (newDiskOffering.isCustomized() && Objects.equals(rootVolumeOfVm.getSize(), rootDiskSizeBytes)))) {
if (s_logger.isDebugEnabled()) {
s_logger.debug(String.format("Volume %s is already having disk offering %s", rootVolumeOfVm, newDiskOffering.getUuid()));
}
continue;
}
HypervisorType hypervisorType = _volsDao.getHypervisorType(rootVolumeOfVm.getId());
if (HypervisorType.Simulator != hypervisorType) {
Long minIopsInNewDiskOffering = null;
Long maxIopsInNewDiskOffering = null;
boolean autoMigrate = false;
boolean shrinkOk = false;
Long rootDiskSize = null;
if (customParameters.containsKey(ApiConstants.MIN_IOPS)) {
minIopsInNewDiskOffering = Long.parseLong(customParameters.get(ApiConstants.MIN_IOPS));
}
Expand All @@ -2061,9 +2073,6 @@ private void changeDiskOfferingForRootVolume(Long vmId, DiskOfferingVO newDiskOf
if (customParameters.containsKey(ApiConstants.SHRINK_OK)) {
shrinkOk = Boolean.parseBoolean(customParameters.get(ApiConstants.SHRINK_OK));
}
if (customParameters.containsKey(ApiConstants.ROOT_DISK_SIZE)) {
rootDiskSize = Long.parseLong(customParameters.get(ApiConstants.ROOT_DISK_SIZE));
}
ChangeOfferingForVolumeCmd changeOfferingForVolumeCmd = new ChangeOfferingForVolumeCmd(rootVolumeOfVm.getId(), newDiskOffering.getId(), minIopsInNewDiskOffering, maxIopsInNewDiskOffering, autoMigrate, shrinkOk);
if (rootDiskSize != null) {
changeOfferingForVolumeCmd.setSize(rootDiskSize);
Expand Down