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:45:27 UTC
git commit: updated refs/heads/master to deb701b
Updated Branches:
refs/heads/master 76e283687 -> deb701b7e
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
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/deb701b7
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/deb701b7
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/deb701b7
Branch: refs/heads/master
Commit: deb701b7e09f486b233bba6372878fa4a9f0d93b
Parents: 76e2836
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:10:20 2013 +0530
----------------------------------------------------------------------
.../engine/subsystem/api/storage/HostScope.java | 9 +++++++--
.../engine/subsystem/api/storage/ScopeTest.java | 6 +++---
.../storage/datastore/PrimaryDataStoreImpl.java | 2 +-
server/src/com/cloud/storage/StorageManagerImpl.java | 2 +-
server/src/com/cloud/storage/VolumeManagerImpl.java | 14 +++++++++++++-
5 files changed, 25 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/deb701b7/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/deb701b7/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/deb701b7/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 420fd29..b20d534 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/deb701b7/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 cd966cd..4011751 100755
--- a/server/src/com/cloud/storage/StorageManagerImpl.java
+++ b/server/src/com/cloud/storage/StorageManagerImpl.java
@@ -625,7 +625,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/deb701b7/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 c4ffc1b..c2d581b 100644
--- a/server/src/com/cloud/storage/VolumeManagerImpl.java
+++ b/server/src/com/cloud/storage/VolumeManagerImpl.java
@@ -34,7 +34,6 @@ 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;
@@ -49,6 +48,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;
@@ -1589,6 +1589,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());
}