You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ko...@apache.org on 2013/07/25 13:53:46 UTC

git commit: updated refs/heads/4.2 to f062fd4

Updated Branches:
  refs/heads/4.2 026be3015 -> f062fd4fc


CLOUDSTACK-3493: [storage ref] Attach volume to VM is failing in case of Primary-Localstorage .
Some existing scenarios for root and data volume combination was not working. These are
a. Local root + Shared data
b. Shared root + Local data

Enabled these scenarios as part of this fix

Conflicts:
	server/src/com/cloud/storage/VolumeManagerImpl.java


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

Branch: refs/heads/4.2
Commit: f062fd4fc132f7cac462d10b7c1dc79854d3e807
Parents: 026be30
Author: Koushik Das <ko...@apache.org>
Authored: Thu Jul 25 17:10:20 2013 +0530
Committer: Koushik Das <ko...@apache.org>
Committed: Thu Jul 25 17:23:21 2013 +0530

----------------------------------------------------------------------
 .../engine/subsystem/api/storage/HostScope.java     |  9 +++++++--
 .../engine/subsystem/api/storage/ScopeTest.java     |  6 +++---
 .../storage/datastore/PrimaryDataStoreImpl.java     |  2 +-
 .../src/com/cloud/storage/StorageManagerImpl.java   |  2 +-
 server/src/com/cloud/storage/VolumeManagerImpl.java | 16 ++++++++++++++++
 5 files changed, 28 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f062fd4f/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/HostScope.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/HostScope.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/HostScope.java
index 1ff3818..6e0bc61 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/HostScope.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/HostScope.java
@@ -22,11 +22,13 @@ import com.cloud.storage.ScopeType;
 
 public class HostScope extends AbstractScope {
     private Long hostId;
+    private Long clusterId;
     private Long zoneId;
 
-    public HostScope(Long hostId, Long zoneId) {
+    public HostScope(Long hostId, Long clusterId, Long zoneId) {
         super();
         this.hostId = hostId;
+        this.clusterId = clusterId;
         this.zoneId = zoneId;
     }
 
@@ -40,8 +42,11 @@ public class HostScope extends AbstractScope {
         return this.hostId;
     }
 
+    public Long getClusterId() {
+        return clusterId;
+    }
+
     public Long getZoneId() {
         return zoneId;
     }
-
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f062fd4f/engine/api/test/org/apache/cloudstack/engine/subsystem/api/storage/ScopeTest.java
----------------------------------------------------------------------
diff --git a/engine/api/test/org/apache/cloudstack/engine/subsystem/api/storage/ScopeTest.java b/engine/api/test/org/apache/cloudstack/engine/subsystem/api/storage/ScopeTest.java
index 4b6b361..473877f 100644
--- a/engine/api/test/org/apache/cloudstack/engine/subsystem/api/storage/ScopeTest.java
+++ b/engine/api/test/org/apache/cloudstack/engine/subsystem/api/storage/ScopeTest.java
@@ -48,9 +48,9 @@ public class ScopeTest {
 
     @Test
     public void testHostScope() {
-        HostScope hostScope = new HostScope(1L, 1L);
-        HostScope hostScope2 = new HostScope(1L, 1L);
-        HostScope hostScope3 = new HostScope(2L, 1L);
+        HostScope hostScope = new HostScope(1L, 1L, 1L);
+        HostScope hostScope2 = new HostScope(1L, 1L, 1L);
+        HostScope hostScope3 = new HostScope(2L, 1L, 1L);
 
         Assert.assertTrue(hostScope.isSameScope(hostScope2));
         Assert.assertFalse(hostScope.isSameScope(hostScope3));

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f062fd4f/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreImpl.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreImpl.java
index 55057d0..0432381 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreImpl.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreImpl.java
@@ -159,7 +159,7 @@ public class PrimaryDataStoreImpl implements PrimaryDataStore {
         } else if (vo.getScope() == ScopeType.HOST) {
             List<StoragePoolHostVO> poolHosts = poolHostDao.listByPoolId(vo.getId());
             if (poolHosts.size() > 0) {
-                return new HostScope(poolHosts.get(0).getHostId(), vo.getDataCenterId());
+                return new HostScope(poolHosts.get(0).getHostId(), vo.getClusterId(), vo.getDataCenterId());
             }
             s_logger.debug("can't find a local storage in pool host table: " + vo.getId());
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f062fd4f/server/src/com/cloud/storage/StorageManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java
index b290a57..0c586ab 100755
--- a/server/src/com/cloud/storage/StorageManagerImpl.java
+++ b/server/src/com/cloud/storage/StorageManagerImpl.java
@@ -624,7 +624,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
                 store = dataStoreMgr.getDataStore(pool.getId(), DataStoreRole.Primary);
             }
 
-            HostScope scope = new HostScope(host.getId(), host.getDataCenterId());
+            HostScope scope = new HostScope(host.getId(), host.getClusterId(), host.getDataCenterId());
             lifeCycle.attachHost(store, scope, pInfo);
         } catch (Exception e) {
             s_logger.warn("Unable to setup the local storage pool for " + host, e);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f062fd4f/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 016fa9e..d7d62b0 100644
--- a/server/src/com/cloud/storage/VolumeManagerImpl.java
+++ b/server/src/com/cloud/storage/VolumeManagerImpl.java
@@ -31,6 +31,9 @@ import java.util.concurrent.ExecutionException;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
 import org.apache.cloudstack.api.BaseCmd;
 import org.apache.cloudstack.api.command.user.volume.AttachVolumeCmd;
 import org.apache.cloudstack.api.command.user.volume.CreateVolumeCmd;
@@ -44,6 +47,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.ChapInfo;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProviderManager;
+import org.apache.cloudstack.engine.subsystem.api.storage.HostScope;
 import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
 import org.apache.cloudstack.engine.subsystem.api.storage.Scope;
 import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory;
@@ -1590,6 +1594,18 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
         }
 
         if (storeForRootStoreScope.getScopeType() != storeForDataStoreScope.getScopeType()) {
+            if (storeForDataStoreScope.getScopeType() == ScopeType.CLUSTER && storeForRootStoreScope.getScopeType() == ScopeType.HOST) {
+                HostScope hs = (HostScope)storeForRootStoreScope;
+                if (storeForDataStoreScope.getScopeId().equals(hs.getClusterId())) {
+                    return false;
+                }
+            }
+            if (storeForRootStoreScope.getScopeType() == ScopeType.CLUSTER && storeForDataStoreScope.getScopeType() == ScopeType.HOST) {
+                HostScope hs = (HostScope)storeForDataStoreScope;
+                if (storeForRootStoreScope.getScopeId().equals(hs.getClusterId())) {
+                    return false;
+                }
+            }
             throw new CloudRuntimeException("Can't move volume between scope: " + storeForDataStoreScope.getScopeType() + " and " + storeForRootStoreScope.getScopeType());
         }