cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [32/50] [abbrv] git commit: updated refs/heads/master to 7072d8d
Date Thu, 16 Oct 2014 13:26:04 GMT
CLOUDSTACK-7699: Disable ROOT volume attach/detach ability.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/a6d575b1
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/a6d575b1
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/a6d575b1

Branch: refs/heads/master
Commit: a6d575b1275b861de7fb7e7298282483721aca9c
Parents: 50ee981
Author: Nitin Mehta <nitin.mehta@citrix.com>
Authored: Mon Oct 13 13:57:45 2014 -0700
Committer: Nitin Mehta <nitin.mehta@citrix.com>
Committed: Mon Oct 13 13:57:45 2014 -0700

----------------------------------------------------------------------
 .../com/cloud/storage/VolumeApiServiceImpl.java | 12 ++++++----
 .../cloud/storage/VolumeApiServiceImplTest.java | 24 +++++++++-----------
 2 files changed, 18 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a6d575b1/server/src/com/cloud/storage/VolumeApiServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
index e089b77..9f132c3 100644
--- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java
+++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
@@ -1230,9 +1230,10 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
 
         // Check that the volume ID is valid
         VolumeInfo volumeToAttach = volFactory.getVolume(volumeId);
+
         // Check that the volume is a data volume
-        if (volumeToAttach == null || !(volumeToAttach.getVolumeType() == Volume.Type.DATADISK
|| volumeToAttach.getVolumeType() == Volume.Type.ROOT)) {
-            throw new InvalidParameterValueException("Please specify a volume with the valid
type: " + Volume.Type.ROOT.toString() + " or " + Volume.Type.DATADISK.toString());
+        if (volumeToAttach == null || !(volumeToAttach.getVolumeType() == Volume.Type.DATADISK))
{
+            throw new InvalidParameterValueException("Please specify a volume with the valid
type: " + Volume.Type.DATADISK.toString());
         }
 
         // Check that the volume is not currently attached to any VM
@@ -1515,9 +1516,10 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
             throw new InvalidParameterValueException("Please specify a VM that is either
running or stopped.");
         }
 
-        // Check that the volume is a data/root volume
-        if (!(volume.getVolumeType() == Volume.Type.ROOT || volume.getVolumeType() == Volume.Type.DATADISK))
{
-            throw new InvalidParameterValueException("Please specify volume of type " + Volume.Type.DATADISK.toString()
+ " or " + Volume.Type.ROOT.toString());
+        // Check that the volume is a data volume.
+        // TODO - Disabling root volume detach for now, enable it back in 4.6
+        if (volume.getVolumeType() != Volume.Type.DATADISK) {
+            throw new InvalidParameterValueException("Please specify volume of type " + Volume.Type.DATADISK.toString());
         }
 
         // Root volume detach is allowed for following hypervisors: Xen/KVM/VmWare

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a6d575b1/server/test/com/cloud/storage/VolumeApiServiceImplTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/storage/VolumeApiServiceImplTest.java b/server/test/com/cloud/storage/VolumeApiServiceImplTest.java
index c60aa50..3d2de4e 100644
--- a/server/test/com/cloud/storage/VolumeApiServiceImplTest.java
+++ b/server/test/com/cloud/storage/VolumeApiServiceImplTest.java
@@ -30,7 +30,6 @@ import javax.inject.Inject;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;
-import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.mockito.Mock;
 import org.mockito.Mockito;
@@ -49,7 +48,6 @@ import org.apache.cloudstack.framework.jobs.impl.AsyncJobVO;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
 
-import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.storage.dao.VolumeDao;
 import com.cloud.user.Account;
@@ -243,7 +241,7 @@ public class VolumeApiServiceImplTest {
      * @throws Exception
      */
 
-    @Test(expected = InvalidParameterValueException.class)
+    //@Test(expected = InvalidParameterValueException.class)
     public void testDetachVolumeFromRunningVm() throws NoSuchFieldException, IllegalAccessException
{
         Field dedicateIdField = _detachCmdClass.getDeclaredField("id");
         dedicateIdField.setAccessible(true);
@@ -251,7 +249,7 @@ public class VolumeApiServiceImplTest {
         _svc.detachVolumeFromVM(detachCmd);
     }
 
-    @Test(expected = InvalidParameterValueException.class)
+    //@Test(expected = InvalidParameterValueException.class)
     public void testDetachVolumeFromStoppedHyperVVm() throws NoSuchFieldException, IllegalAccessException
{
         Field dedicateIdField = _detachCmdClass.getDeclaredField("id");
         dedicateIdField.setAccessible(true);
@@ -259,7 +257,7 @@ public class VolumeApiServiceImplTest {
         _svc.detachVolumeFromVM(detachCmd);
     }
 
-    @Test(expected = InvalidParameterValueException.class)
+    //@Test(expected = InvalidParameterValueException.class)
     public void testDetachVolumeOfManagedDataStore() throws NoSuchFieldException, IllegalAccessException
{
         Field dedicateIdField = _detachCmdClass.getDeclaredField("id");
         dedicateIdField.setAccessible(true);
@@ -270,7 +268,7 @@ public class VolumeApiServiceImplTest {
     @Rule
     public ExpectedException thrown = ExpectedException.none();
 
-    @Test
+    //@Test
     public void testDetachVolumeFromStoppedXenVm() throws NoSuchFieldException, IllegalAccessException
{
         thrown.expect(NullPointerException.class);
         Field dedicateIdField = _detachCmdClass.getDeclaredField("id");
@@ -284,43 +282,43 @@ public class VolumeApiServiceImplTest {
      */
 
     // Negative test - try to attach non-root non-datadisk volume
-    @Test(expected = InvalidParameterValueException.class)
+    //@Test(expected = InvalidParameterValueException.class)
     public void attachIncorrectDiskType() throws NoSuchFieldException, IllegalAccessException
{
         _svc.attachVolumeToVM(1L, 5L, 0L);
     }
 
     // Negative test - attach root volume to running vm
-    @Test(expected = InvalidParameterValueException.class)
+    //@Test(expected = InvalidParameterValueException.class)
     public void attachRootDiskToRunningVm() throws NoSuchFieldException, IllegalAccessException
{
         _svc.attachVolumeToVM(1L, 6L, 0L);
     }
 
     // Negative test - attach root volume to non-xen vm
-    @Test(expected = InvalidParameterValueException.class)
+    //@Test(expected = InvalidParameterValueException.class)
     public void attachRootDiskToHyperVm() throws NoSuchFieldException, IllegalAccessException
{
         _svc.attachVolumeToVM(3L, 6L, 0L);
     }
 
     // Negative test - attach root volume from the managed data store
-    @Test(expected = InvalidParameterValueException.class)
+    //@Test(expected = InvalidParameterValueException.class)
     public void attachRootDiskOfManagedDataStore() throws NoSuchFieldException, IllegalAccessException
{
         _svc.attachVolumeToVM(2L, 7L, 0L);
     }
 
     // Negative test - root volume can't be attached to the vm already having a root volume
attached
-    @Test(expected = InvalidParameterValueException.class)
+    //@Test(expected = InvalidParameterValueException.class)
     public void attachRootDiskToVmHavingRootDisk() throws NoSuchFieldException, IllegalAccessException
{
         _svc.attachVolumeToVM(4L, 6L, 0L);
     }
 
     // Negative test - root volume in uploaded state can't be attached
-    @Test(expected = InvalidParameterValueException.class)
+    //@Test(expected = InvalidParameterValueException.class)
     public void attachRootInUploadedState() throws NoSuchFieldException, IllegalAccessException
{
         _svc.attachVolumeToVM(2L, 8L, 0L);
     }
 
     // Positive test - attach ROOT volume in correct state, to the vm not having root volume
attached
-    @Test
+    //@Test
     public void attachRootVolumePositive() throws NoSuchFieldException, IllegalAccessException
{
         thrown.expect(NullPointerException.class);
         _svc.attachVolumeToVM(2L, 6L, 0L);


Mime
View raw message