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:
Rafael Weingärtner 2018-05-08 09:40:58 -03:00 committed by GitHub
parent ffe86e1c17
commit 55f45e75aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 6 deletions

View File

@ -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()));
}
/**

View File

@ -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();