cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wid...@apache.org
Subject [28/50] [abbrv] git commit: updated refs/heads/kvm-vnc-listen to 3890860
Date Wed, 03 Apr 2013 10:33:36 GMT
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/kvm-vnc-listen
Commit: dedec164e8cce17b861d517fe8e29bb99902e113
Parents: 8d34b58
Author: Mice Xia <mice_xia@tcloudcomputing.com>
Authored: Tue Apr 2 16:19:24 2013 +0800
Committer: Mice Xia <mice_xia@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) {


Mime
View raw message