Skip to content

Commit 0436560

Browse files
author
Likitha Shetty
committed
CLOUDSTACK-8412. VM migration with storage fails.
Update MigrateWithStorageCommand to avoid JSON deserialization error.
1 parent 10a106f commit 0436560

2 files changed

Lines changed: 12 additions & 11 deletions

File tree

plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3036,7 +3036,7 @@ protected Answer execute(MigrateWithStorageCommand cmd) {
30363036
List<VolumeObjectTO> volumeToList = new ArrayList<VolumeObjectTO>();
30373037
Map<Long, Integer> volumeDeviceKey = new HashMap<Long, Integer>();
30383038

3039-
Map<VolumeTO, StorageFilerTO> volToFiler = cmd.getVolumeToFiler();
3039+
List<Pair<VolumeTO, StorageFilerTO>> volToFiler = cmd.getVolumeToFilerAsList();
30403040
String tgtHost = cmd.getTargetHost();
30413041
String tgtHostMorInfo = tgtHost.split("@")[0];
30423042
morTgtHost.setType(tgtHostMorInfo.split(":")[0]);
@@ -3064,9 +3064,9 @@ protected Answer execute(MigrateWithStorageCommand cmd) {
30643064
vmName = vmMo.getName();
30653065

30663066
// Specify destination datastore location for each volume
3067-
for (Entry<VolumeTO, StorageFilerTO> entry : volToFiler.entrySet()) {
3068-
volume = entry.getKey();
3069-
filerTo = entry.getValue();
3067+
for (Pair<VolumeTO, StorageFilerTO> entry : volToFiler) {
3068+
volume = entry.first();
3069+
filerTo = entry.second();
30703070

30713071
s_logger.debug("Preparing spec for volume : " + volume.getName());
30723072
morDsAtTarget = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(tgtHyperHost, filerTo.getUuid());
@@ -3195,8 +3195,8 @@ protected Answer execute(MigrateWithStorageCommand cmd) {
31953195
}
31963196

31973197
// Update and return volume path for every disk because that could have changed after migration
3198-
for (Entry<VolumeTO, StorageFilerTO> entry : volToFiler.entrySet()) {
3199-
volume = entry.getKey();
3198+
for (Pair<VolumeTO, StorageFilerTO> entry : volToFiler) {
3199+
volume = entry.first();
32003200
long volumeId = volume.getId();
32013201
VirtualDisk[] disks = vmMo.getAllDiskDevice();
32023202
for (VirtualDisk disk : disks) {

plugins/hypervisors/vmware/src/org/apache/cloudstack/storage/motion/VmwareStorageMotionStrategy.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
package org.apache.cloudstack.storage.motion;
2121

22-
import java.util.HashMap;
22+
import java.util.ArrayList;
2323
import java.util.List;
2424
import java.util.Map;
2525

@@ -53,6 +53,7 @@
5353
import com.cloud.storage.StoragePool;
5454
import com.cloud.storage.VolumeVO;
5555
import com.cloud.storage.dao.VolumeDao;
56+
import com.cloud.utils.Pair;
5657
import com.cloud.utils.exception.CloudRuntimeException;
5758
import com.cloud.vm.VMInstanceVO;
5859
import com.cloud.vm.dao.VMInstanceDao;
@@ -130,12 +131,12 @@ private Answer migrateVmWithVolumesAcrossCluster(VMInstanceVO vm, VirtualMachine
130131

131132
// Initiate migration of a virtual machine with it's volumes.
132133
try {
133-
Map<VolumeTO, StorageFilerTO> volumeToFilerto = new HashMap<VolumeTO, StorageFilerTO>();
134+
List<Pair<VolumeTO, StorageFilerTO>> volumeToFilerto = new ArrayList<Pair<VolumeTO, StorageFilerTO>>();
134135
for (Map.Entry<VolumeInfo, DataStore> entry : volumeToPool.entrySet()) {
135136
VolumeInfo volume = entry.getKey();
136137
VolumeTO volumeTo = new VolumeTO(volume, storagePoolDao.findById(volume.getPoolId()));
137138
StorageFilerTO filerTo = new StorageFilerTO((StoragePool)entry.getValue());
138-
volumeToFilerto.put(volumeTo, filerTo);
139+
volumeToFilerto.add(new Pair<VolumeTO, StorageFilerTO>(volumeTo, filerTo));
139140
}
140141

141142
// Migration across cluster needs to be done in three phases.
@@ -168,12 +169,12 @@ private Answer migrateVmWithVolumesWithinCluster(VMInstanceVO vm, VirtualMachine
168169

169170
// Initiate migration of a virtual machine with it's volumes.
170171
try {
171-
Map<VolumeTO, StorageFilerTO> volumeToFilerto = new HashMap<VolumeTO, StorageFilerTO>();
172+
List<Pair<VolumeTO, StorageFilerTO>> volumeToFilerto = new ArrayList<Pair<VolumeTO, StorageFilerTO>>();
172173
for (Map.Entry<VolumeInfo, DataStore> entry : volumeToPool.entrySet()) {
173174
VolumeInfo volume = entry.getKey();
174175
VolumeTO volumeTo = new VolumeTO(volume, storagePoolDao.findById(volume.getPoolId()));
175176
StorageFilerTO filerTo = new StorageFilerTO((StoragePool)entry.getValue());
176-
volumeToFilerto.put(volumeTo, filerTo);
177+
volumeToFilerto.add(new Pair<VolumeTO, StorageFilerTO>(volumeTo, filerTo));
177178
}
178179

179180
MigrateWithStorageCommand command = new MigrateWithStorageCommand(to, volumeToFilerto, destHost.getGuid());

0 commit comments

Comments
 (0)