mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-8412. VM migration with storage fails.
Update MigrateWithStorageCommand to avoid JSON deserialization error.
This commit is contained in:
parent
10a106f5d8
commit
04365601da
@ -3036,7 +3036,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||||||
List<VolumeObjectTO> volumeToList = new ArrayList<VolumeObjectTO>();
|
List<VolumeObjectTO> volumeToList = new ArrayList<VolumeObjectTO>();
|
||||||
Map<Long, Integer> volumeDeviceKey = new HashMap<Long, Integer>();
|
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 tgtHost = cmd.getTargetHost();
|
||||||
String tgtHostMorInfo = tgtHost.split("@")[0];
|
String tgtHostMorInfo = tgtHost.split("@")[0];
|
||||||
morTgtHost.setType(tgtHostMorInfo.split(":")[0]);
|
morTgtHost.setType(tgtHostMorInfo.split(":")[0]);
|
||||||
@ -3064,9 +3064,9 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||||||
vmName = vmMo.getName();
|
vmName = vmMo.getName();
|
||||||
|
|
||||||
// Specify destination datastore location for each volume
|
// Specify destination datastore location for each volume
|
||||||
for (Entry<VolumeTO, StorageFilerTO> entry : volToFiler.entrySet()) {
|
for (Pair<VolumeTO, StorageFilerTO> entry : volToFiler) {
|
||||||
volume = entry.getKey();
|
volume = entry.first();
|
||||||
filerTo = entry.getValue();
|
filerTo = entry.second();
|
||||||
|
|
||||||
s_logger.debug("Preparing spec for volume : " + volume.getName());
|
s_logger.debug("Preparing spec for volume : " + volume.getName());
|
||||||
morDsAtTarget = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(tgtHyperHost, filerTo.getUuid());
|
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
|
// Update and return volume path for every disk because that could have changed after migration
|
||||||
for (Entry<VolumeTO, StorageFilerTO> entry : volToFiler.entrySet()) {
|
for (Pair<VolumeTO, StorageFilerTO> entry : volToFiler) {
|
||||||
volume = entry.getKey();
|
volume = entry.first();
|
||||||
long volumeId = volume.getId();
|
long volumeId = volume.getId();
|
||||||
VirtualDisk[] disks = vmMo.getAllDiskDevice();
|
VirtualDisk[] disks = vmMo.getAllDiskDevice();
|
||||||
for (VirtualDisk disk : disks) {
|
for (VirtualDisk disk : disks) {
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package org.apache.cloudstack.storage.motion;
|
package org.apache.cloudstack.storage.motion;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -53,6 +53,7 @@ import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
|||||||
import com.cloud.storage.StoragePool;
|
import com.cloud.storage.StoragePool;
|
||||||
import com.cloud.storage.VolumeVO;
|
import com.cloud.storage.VolumeVO;
|
||||||
import com.cloud.storage.dao.VolumeDao;
|
import com.cloud.storage.dao.VolumeDao;
|
||||||
|
import com.cloud.utils.Pair;
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
import com.cloud.vm.VMInstanceVO;
|
import com.cloud.vm.VMInstanceVO;
|
||||||
import com.cloud.vm.dao.VMInstanceDao;
|
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.
|
// Initiate migration of a virtual machine with it's volumes.
|
||||||
try {
|
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()) {
|
for (Map.Entry<VolumeInfo, DataStore> entry : volumeToPool.entrySet()) {
|
||||||
VolumeInfo volume = entry.getKey();
|
VolumeInfo volume = entry.getKey();
|
||||||
VolumeTO volumeTo = new VolumeTO(volume, storagePoolDao.findById(volume.getPoolId()));
|
VolumeTO volumeTo = new VolumeTO(volume, storagePoolDao.findById(volume.getPoolId()));
|
||||||
StorageFilerTO filerTo = new StorageFilerTO((StoragePool)entry.getValue());
|
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.
|
// 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.
|
// Initiate migration of a virtual machine with it's volumes.
|
||||||
try {
|
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()) {
|
for (Map.Entry<VolumeInfo, DataStore> entry : volumeToPool.entrySet()) {
|
||||||
VolumeInfo volume = entry.getKey();
|
VolumeInfo volume = entry.getKey();
|
||||||
VolumeTO volumeTo = new VolumeTO(volume, storagePoolDao.findById(volume.getPoolId()));
|
VolumeTO volumeTo = new VolumeTO(volume, storagePoolDao.findById(volume.getPoolId()));
|
||||||
StorageFilerTO filerTo = new StorageFilerTO((StoragePool)entry.getValue());
|
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());
|
MigrateWithStorageCommand command = new MigrateWithStorageCommand(to, volumeToFilerto, destHost.getGuid());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user