You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by mi...@apache.org on 2013/04/02 11:36:44 UTC

[2/2] git commit: updated refs/heads/master to 4edef1f

fix CLOUDSTACK-1698


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

Branch: refs/heads/master
Commit: dedec164e8cce17b861d517fe8e29bb99902e113
Parents: 8d34b58
Author: Mice Xia <mi...@tcloudcomputing.com>
Authored: Tue Apr 2 16:19:24 2013 +0800
Committer: Mice Xia <mi...@tcloudcomputing.com>
Committed: Tue Apr 2 17:36:51 2013 +0800

----------------------------------------------------------------------
 .../src/com/cloud/storage/VolumeManagerImpl.java   |   18 +++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dedec164/server/src/com/cloud/storage/VolumeManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VolumeManagerImpl.java b/server/src/com/cloud/storage/VolumeManagerImpl.java
index ff0235f..1e8edaf 100644
--- a/server/src/com/cloud/storage/VolumeManagerImpl.java
+++ b/server/src/com/cloud/storage/VolumeManagerImpl.java
@@ -169,6 +169,8 @@ import com.cloud.vm.dao.DomainRouterDao;
 import com.cloud.vm.dao.SecondaryStorageVmDao;
 import com.cloud.vm.dao.UserVmDao;
 import com.cloud.vm.dao.VMInstanceDao;
+import com.cloud.vm.snapshot.VMSnapshotVO;
+import com.cloud.vm.snapshot.dao.VMSnapshotDao;
 
 @Component
 public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
@@ -289,6 +291,8 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
     @Inject
     protected ResourceTagDao _resourceTagDao;
     @Inject
+    protected VMSnapshotDao _vmSnapshotDao;
+    @Inject
     protected List<StoragePoolAllocator> _storagePoolAllocators;
     @Inject
     ConfigurationDao _configDao;
@@ -1669,6 +1673,13 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
             }
         }
 
+        // if target VM has associated VM snapshots
+        List<VMSnapshotVO> vmSnapshots = _vmSnapshotDao.findByVm(vmId);
+        if(vmSnapshots.size() > 0){
+            throw new InvalidParameterValueException(
+                    "Unable to attach volume, please specify a VM that does not have VM snapshots");           
+        }
+        
         // permission check
         _accountMgr.checkAccess(caller, null, true, volume, vm);
 
@@ -1826,6 +1837,13 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
                     "Please specify a VM that is either running or stopped.");
         }
 
+        // Check if the VM has VM snapshots
+        List<VMSnapshotVO> vmSnapshots = _vmSnapshotDao.findByVm(vmId);
+        if(vmSnapshots.size() > 0){
+            throw new InvalidParameterValueException(
+                    "Unable to detach volume, the specified volume is attached to a VM that has VM snapshots.");           
+        }
+
         AsyncJobExecutor asyncExecutor = BaseAsyncJobExecutor
                 .getCurrentExecutor();
         if (asyncExecutor != null) {