You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ra...@apache.org on 2018/05/08 12:41:11 UTC

[cloudstack] branch master updated: Allow changing disk offering of VMs' root volume (#2607)

This is an automated email from the ASF dual-hosted git repository.

rafael pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/master by this push:
     new 55f45e7  Allow changing disk offering of VMs' root volume (#2607)
55f45e7 is described below

commit 55f45e75aa52ac8cbc31ec3766ef54c75a0df868
Author: Rafael Weingärtner <ra...@gmail.com>
AuthorDate: Tue May 8 09:40:58 2018 -0300

    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.
---
 server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java     | 5 +----
 server/src/test/java/com/cloud/storage/VolumeApiServiceImplTest.java | 3 +--
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java
index 7889c65..78a009c 100644
--- a/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java
+++ b/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java
@@ -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()));
     }
 
     /**
diff --git a/server/src/test/java/com/cloud/storage/VolumeApiServiceImplTest.java b/server/src/test/java/com/cloud/storage/VolumeApiServiceImplTest.java
index 28937ec..55dda53 100644
--- a/server/src/test/java/com/cloud/storage/VolumeApiServiceImplTest.java
+++ b/server/src/test/java/com/cloud/storage/VolumeApiServiceImplTest.java
@@ -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();

-- 
To stop receiving notification emails like this one, please contact
rafael@apache.org.