Repository: cloudstack
Updated Branches:
  refs/heads/master 10a106f5d -> 04365601d


CLOUDSTACK-8412. VM migration with storage fails.
Update MigrateWithStorageCommand to avoid JSON deserialization error.


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

Branch: refs/heads/master
Commit: 04365601dac6d4dfa396e5c86ab7e698906dfb44
Parents: 10a106f
Author: Likitha Shetty <likitha.she...@citrix.com>
Authored: Fri Apr 3 15:47:07 2015 +0530
Committer: Likitha Shetty <likitha.she...@citrix.com>
Committed: Tue Apr 28 10:22:00 2015 +0530

----------------------------------------------------------------------
 .../hypervisor/vmware/resource/VmwareResource.java      | 12 ++++++------
 .../storage/motion/VmwareStorageMotionStrategy.java     | 11 ++++++-----
 2 files changed, 12 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/04365601/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
----------------------------------------------------------------------
diff --git 
a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
 
b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
index b30a572..8726412 100644
--- 
a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
+++ 
b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
@@ -3036,7 +3036,7 @@ public class VmwareResource implements 
StoragePoolResource, ServerResource, Vmwa
         List<VolumeObjectTO> volumeToList =  new ArrayList<VolumeObjectTO>();
         Map<Long, Integer> volumeDeviceKey = new HashMap<Long, Integer>();
 
-        Map<VolumeTO, StorageFilerTO> volToFiler = cmd.getVolumeToFiler();
+        List<Pair<VolumeTO, StorageFilerTO>> volToFiler = 
cmd.getVolumeToFilerAsList();
         String tgtHost = cmd.getTargetHost();
         String tgtHostMorInfo = tgtHost.split("@")[0];
         morTgtHost.setType(tgtHostMorInfo.split(":")[0]);
@@ -3064,9 +3064,9 @@ public class VmwareResource implements 
StoragePoolResource, ServerResource, Vmwa
             vmName = vmMo.getName();
 
             // Specify destination datastore location for each volume
-            for (Entry<VolumeTO, StorageFilerTO> entry : 
volToFiler.entrySet()) {
-                volume = entry.getKey();
-                filerTo = entry.getValue();
+            for (Pair<VolumeTO, StorageFilerTO> entry : volToFiler) {
+                volume = entry.first();
+                filerTo = entry.second();
 
                 s_logger.debug("Preparing spec for volume : " + 
volume.getName());
                 morDsAtTarget = 
HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(tgtHyperHost, 
filerTo.getUuid());
@@ -3195,8 +3195,8 @@ public class VmwareResource implements 
StoragePoolResource, ServerResource, Vmwa
             }
 
             // Update and return volume path for every disk because that could 
have changed after migration
-            for (Entry<VolumeTO, StorageFilerTO> entry : 
volToFiler.entrySet()) {
-                volume = entry.getKey();
+            for (Pair<VolumeTO, StorageFilerTO> entry : volToFiler) {
+                volume = entry.first();
                 long volumeId = volume.getId();
                 VirtualDisk[] disks = vmMo.getAllDiskDevice();
                 for (VirtualDisk disk : disks) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/04365601/plugins/hypervisors/vmware/src/org/apache/cloudstack/storage/motion/VmwareStorageMotionStrategy.java
----------------------------------------------------------------------
diff --git 
a/plugins/hypervisors/vmware/src/org/apache/cloudstack/storage/motion/VmwareStorageMotionStrategy.java
 
b/plugins/hypervisors/vmware/src/org/apache/cloudstack/storage/motion/VmwareStorageMotionStrategy.java
index 24efde7..da9764d 100644
--- 
a/plugins/hypervisors/vmware/src/org/apache/cloudstack/storage/motion/VmwareStorageMotionStrategy.java
+++ 
b/plugins/hypervisors/vmware/src/org/apache/cloudstack/storage/motion/VmwareStorageMotionStrategy.java
@@ -19,7 +19,7 @@
 
 package org.apache.cloudstack.storage.motion;
 
-import java.util.HashMap;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
@@ -53,6 +53,7 @@ import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.storage.StoragePool;
 import com.cloud.storage.VolumeVO;
 import com.cloud.storage.dao.VolumeDao;
+import com.cloud.utils.Pair;
 import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.vm.VMInstanceVO;
 import com.cloud.vm.dao.VMInstanceDao;
@@ -130,12 +131,12 @@ public class VmwareStorageMotionStrategy implements 
DataMotionStrategy {
 
         // Initiate migration of a virtual machine with it's volumes.
         try {
-            Map<VolumeTO, StorageFilerTO> volumeToFilerto = new 
HashMap<VolumeTO, StorageFilerTO>();
+            List<Pair<VolumeTO, StorageFilerTO>> volumeToFilerto = new 
ArrayList<Pair<VolumeTO, StorageFilerTO>>();
             for (Map.Entry<VolumeInfo, DataStore> entry : 
volumeToPool.entrySet()) {
                 VolumeInfo volume = entry.getKey();
                 VolumeTO volumeTo = new VolumeTO(volume, 
storagePoolDao.findById(volume.getPoolId()));
                 StorageFilerTO filerTo = new 
StorageFilerTO((StoragePool)entry.getValue());
-                volumeToFilerto.put(volumeTo, filerTo);
+                volumeToFilerto.add(new Pair<VolumeTO, 
StorageFilerTO>(volumeTo, filerTo));
             }
 
             // Migration across cluster needs to be done in three phases.
@@ -168,12 +169,12 @@ public class VmwareStorageMotionStrategy implements 
DataMotionStrategy {
 
         // Initiate migration of a virtual machine with it's volumes.
         try {
-            Map<VolumeTO, StorageFilerTO> volumeToFilerto = new 
HashMap<VolumeTO, StorageFilerTO>();
+            List<Pair<VolumeTO, StorageFilerTO>> volumeToFilerto = new 
ArrayList<Pair<VolumeTO, StorageFilerTO>>();
             for (Map.Entry<VolumeInfo, DataStore> entry : 
volumeToPool.entrySet()) {
                 VolumeInfo volume = entry.getKey();
                 VolumeTO volumeTo = new VolumeTO(volume, 
storagePoolDao.findById(volume.getPoolId()));
                 StorageFilerTO filerTo = new 
StorageFilerTO((StoragePool)entry.getValue());
-                volumeToFilerto.put(volumeTo, filerTo);
+                volumeToFilerto.add(new Pair<VolumeTO, 
StorageFilerTO>(volumeTo, filerTo));
             }
 
             MigrateWithStorageCommand command = new 
MigrateWithStorageCommand(to, volumeToFilerto, destHost.getGuid());

Reply via email to