cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From devd...@apache.org
Subject git commit: updated refs/heads/4.2 to 0760a51
Date Tue, 23 Jul 2013 05:16:20 GMT
Updated Branches:
  refs/heads/4.2 ec3466b27 -> 0760a5197


CLOUDSTACK-3708, Migration of a volume attached to a running instance isn't working (Storage
motion).
The request to migrate was coming till ancient data motion strategy but wasn't worked on and
forwarded
to the resource. The code probably got removed by a bad merge. Bringing it back.


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

Branch: refs/heads/4.2
Commit: 0760a5197b47a66ec5fbf77419d88922279c7138
Parents: ec3466b
Author: Devdeep Singh <devdeep@gmail.com>
Authored: Mon Jul 22 15:46:43 2013 +0530
Committer: Devdeep Singh <devdeep@gmail.com>
Committed: Tue Jul 23 10:37:10 2013 +0530

----------------------------------------------------------------------
 .../motion/AncientDataMotionStrategy.java       | 34 +++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0760a519/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java
----------------------------------------------------------------------
diff --git a/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java
b/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java
index 00c693f..e17306a 100644
--- a/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java
+++ b/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java
@@ -49,6 +49,8 @@ import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
 
 import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.storage.MigrateVolumeAnswer;
+import com.cloud.agent.api.storage.MigrateVolumeCommand;
 import com.cloud.agent.api.to.DataObjectType;
 import com.cloud.agent.api.to.DataStoreTO;
 import com.cloud.agent.api.to.DataTO;
@@ -64,6 +66,7 @@ import com.cloud.storage.DataStoreRole;
 import com.cloud.storage.StorageManager;
 import com.cloud.storage.StoragePool;
 import com.cloud.storage.VolumeManager;
+import com.cloud.storage.VolumeVO;
 import com.cloud.storage.dao.DiskOfferingDao;
 import com.cloud.storage.dao.SnapshotDao;
 import com.cloud.storage.dao.VMTemplateDao;
@@ -330,6 +333,30 @@ public class AncientDataMotionStrategy implements DataMotionStrategy
{
 
     }
 
+    protected Answer migrateVolumeToPool(DataObject srcData, DataObject destData) {
+        VolumeInfo volume = (VolumeInfo)srcData;
+        StoragePool destPool = (StoragePool)this.dataStoreMgr.getDataStore(destData.getDataStore().getId(),
DataStoreRole.Primary);
+        MigrateVolumeCommand command = new MigrateVolumeCommand(volume.getId(), volume.getPath(),
destPool);
+        EndPoint ep = selector.select(volume.getDataStore());
+        MigrateVolumeAnswer answer = (MigrateVolumeAnswer) ep.sendMessage(command);
+
+        if (answer == null || !answer.getResult()) {
+            throw new CloudRuntimeException("Failed to migrate volume " + volume + " to storage
pool " + destPool);
+        } else {
+            // Update the volume details after migration.
+            VolumeVO volumeVo = this.volDao.findById(volume.getId());
+            Long oldPoolId = volume.getPoolId();
+            volumeVo.setPath(answer.getVolumePath());
+            volumeVo.setFolder(destPool.getPath());
+            volumeVo.setPodId(destPool.getPodId());
+            volumeVo.setPoolId(destPool.getId());
+            volumeVo.setLastPoolId(oldPoolId);
+            this.volDao.update(volume.getId(), volumeVo);
+        }
+
+        return answer;
+    }
+
     @Override
     public Void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback<CopyCommandResult>
callback) {
         Answer answer = null;
@@ -347,7 +374,12 @@ public class AncientDataMotionStrategy implements DataMotionStrategy
{
             } else if (destData.getType() == DataObjectType.VOLUME && srcData.getType()
== DataObjectType.VOLUME
                     && srcData.getDataStore().getRole() == DataStoreRole.Primary
                     && destData.getDataStore().getRole() == DataStoreRole.Primary)
{
-                answer = copyVolumeBetweenPools(srcData, destData);
+                if (srcData.getId() == destData.getId()) {
+                    // The volume has to be migrated across storage pools.
+                    answer = migrateVolumeToPool(srcData, destData);
+                } else {
+                    answer = copyVolumeBetweenPools(srcData, destData);
+                }
             } else if (srcData.getType() == DataObjectType.SNAPSHOT && destData.getType()
== DataObjectType.SNAPSHOT) {
                 answer = copySnapshot(srcData, destData);
             } else {


Mime
View raw message