mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
Allow changing disk offering of VMs' root volume (#2607)
Currently, users are not able to change the disk offering of VMs' root volumes. It might be interesting to allow such changes, so users would be able to move a VM initially deployed in shared storage to local storage and vice versa. It is also interesting to enable changing the quality of service offered to root disks. We are allowing only administrators to execute the change of root volumes disk offerings during volume migration between storage. Therefore, we perform all at once, the migration of storage and the disk offering to reflect the new place.
This commit is contained in:
parent
ffe86e1c17
commit
55f45e75aa
@ -2125,9 +2125,6 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
||||
if (newDiskOffering == null) {
|
||||
return;
|
||||
}
|
||||
if (Volume.Type.ROOT.equals(volume.getVolumeType())) {
|
||||
throw new InvalidParameterValueException(String.format("Cannot change the disk offering of a ROOT volume [id=%s].", volume.getUuid()));
|
||||
}
|
||||
if ((destPool.isShared() && newDiskOffering.getUseLocalStorage()) || destPool.isLocal() && newDiskOffering.isShared()) {
|
||||
throw new InvalidParameterValueException("You cannot move the volume to a shared storage and assing a disk offering for local storage and vice versa.");
|
||||
}
|
||||
@ -2142,7 +2139,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
||||
"You are migrating a volume [id=%s] and changing the disk offering[from id=%s to id=%s] to reflect this migration. However, the sizes of the volume and the new disk offering are different.",
|
||||
volume.getUuid(), oldDiskOffering.getUuid(), newDiskOffering.getUuid()));
|
||||
}
|
||||
|
||||
s_logger.info(String.format("Changing disk offering to [uuid=%s] while migrating volume [uuid=%s, name=%s].", newDiskOffering.getUuid(), volume.getUuid(), volume.getName()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -516,7 +516,7 @@ public class VolumeApiServiceImplTest {
|
||||
Mockito.verify(volumeVOMock, times(0)).getVolumeType();
|
||||
}
|
||||
|
||||
@Test(expected = InvalidParameterValueException.class)
|
||||
@Test
|
||||
public void validateConditionsToReplaceDiskOfferingOfVolumeTestRootVolume() {
|
||||
Mockito.when(volumeVOMock.getVolumeType()).thenReturn(Type.ROOT);
|
||||
|
||||
@ -575,7 +575,6 @@ public class VolumeApiServiceImplTest {
|
||||
volumeApiServiceImpl.validateConditionsToReplaceDiskOfferingOfVolume(volumeVOMock, newDiskOfferingMock, storagePoolMock);
|
||||
|
||||
InOrder inOrder = Mockito.inOrder(volumeVOMock, newDiskOfferingMock, storagePoolMock, volumeApiServiceImpl);
|
||||
inOrder.verify(volumeVOMock).getVolumeType();
|
||||
inOrder.verify(storagePoolMock).isShared();
|
||||
inOrder.verify(newDiskOfferingMock).getUseLocalStorage();
|
||||
inOrder.verify(storagePoolMock).isLocal();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user