Fix migrateVMwithVolumes API in case of multiple volumes on VMware (#4480)

Problem:
When migrateVMwithVolumes API is tried on a VM with two volumes to migrate to a different host and tried to migrate only one volume, Cloudstack migrates both the Volumes but then marks only one of them migrated. This makes volume inaccessible due to inconsitency in path of volume in cloudstack and vsphere

Solution:
Set the target datastore in relocate spec properly for each volume
This commit is contained in:
Harikrishna 2020-11-20 18:08:06 +05:30 committed by GitHub
parent 492962238e
commit 51034be270
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 4 deletions

View File

@ -4694,7 +4694,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
}
diskLocator = new VirtualMachineRelocateSpecDiskLocator();
diskLocator.setDatastore(morDsAtSource);
diskLocator.setDatastore(morTgtDatastore);
Pair<VirtualDisk, String> diskInfo = getVirtualDiskInfo(vmMo, appendFileType(volume.getPath(), VMDK_EXTENSION));
String vmdkAbsFile = getAbsoluteVmdkFile(diskInfo.first());
if (vmdkAbsFile != null && !vmdkAbsFile.isEmpty()) {
@ -4717,9 +4717,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
diskLocators.add(diskLocator);
}
}
if (srcHyperHost.getHyperHostCluster().equals(tgtHyperHost.getHyperHostCluster())) {
relocateSpec.getDisk().addAll(diskLocators);
}
relocateSpec.getDisk().addAll(diskLocators);
// Prepare network at target before migration
NicTO[] nics = vmTo.getNics();