CLOUDSTACK-8412. VM migration with storage fails.

Update MigrateWithStorageCommand to avoid JSON deserialization error.
This commit is contained in:
Likitha Shetty 2015-04-03 15:47:07 +05:30
parent 10a106f5d8
commit 04365601da
2 changed files with 12 additions and 11 deletions

View File

@ -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) {

View File

@ -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());