cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wid...@apache.org
Subject [13/50] [abbrv] git commit: updated refs/heads/disk-cache to 99d67cb
Date Mon, 02 Sep 2013 20:04:59 GMT
CLOUDSTACK-4005: Do not allow snapshot on zone wide primary storage when KVM.snapshot.enabled
is set to false


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

Branch: refs/heads/disk-cache
Commit: 536fd0e8a1d215d9a6fcb460cf946558d00bfe44
Parents: 65370f3
Author: Kishan Kavala <kishan@cloud.com>
Authored: Fri Aug 2 18:03:54 2013 +0530
Committer: Kishan Kavala <kishan@cloud.com>
Committed: Fri Aug 2 18:04:28 2013 +0530

----------------------------------------------------------------------
 .../storage/snapshot/SnapshotManagerImpl.java   | 37 +++++++++++++-------
 1 file changed, 25 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/536fd0e8/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
index 512aaf9..935bfaa 100755
--- a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
+++ b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
@@ -929,21 +929,34 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
 	}
 
     private boolean supportedByHypervisor(VolumeInfo volume) {
-    	StoragePool storagePool = (StoragePool)volume.getDataStore();
-        ClusterVO cluster = _clusterDao.findById(storagePool.getClusterId());
-        if (cluster != null && cluster.getHypervisorType() == HypervisorType.Ovm)
{
+        HypervisorType hypervisorType;
+        StoragePoolVO storagePool = _storagePoolDao.findById(volume.getDataStore().getId());
+        ScopeType scope = storagePool.getScope();
+        if (scope.equals(ScopeType.ZONE)) {
+            hypervisorType = storagePool.getHypervisor();
+        } else {
+            hypervisorType = volume.getHypervisorType();
+        }
+
+        if (hypervisorType.equals(HypervisorType.Ovm)) {
             throw new InvalidParameterValueException("Ovm won't support taking snapshot");
         }
 
-		if (volume.getHypervisorType().equals(HypervisorType.KVM)) {
-			List<HostVO> hosts = _resourceMgr.listAllHostsInCluster(cluster.getId());
-			if (hosts != null && !hosts.isEmpty()) {
-				HostVO host = hosts.get(0);
-				if (!hostSupportSnapsthot(host)) {
-					throw new CloudRuntimeException("KVM Snapshot is not supported on cluster: " + host.getId());
-				}
-			}
-		}
+        if (hypervisorType.equals(HypervisorType.KVM)) {
+            List<HostVO> hosts = null;
+            if(scope.equals(ScopeType.CLUSTER)){
+                ClusterVO cluster = _clusterDao.findById(storagePool.getClusterId());
+                hosts = _resourceMgr.listAllHostsInCluster(cluster.getId());
+            } else if (scope.equals(ScopeType.ZONE)){
+                hosts = _resourceMgr.listAllUpAndEnabledHostsInOneZoneByHypervisor(hypervisorType,
volume.getDataCenterId());
+            }
+            if (hosts != null && !hosts.isEmpty()) {
+                HostVO host = hosts.get(0);
+                if (!hostSupportSnapsthot(host)) {
+                    throw new CloudRuntimeException("KVM Snapshot is not supported: " + host.getId());
+                }
+            }
+        }
 
 		// if volume is attached to a vm in destroyed or expunging state; disallow
 		if (volume.getInstanceId() != null) {


Mime
View raw message