Skip to content

Commit f22c5a9

Browse files
committed
fix conflicts
1 parent bf62661 commit f22c5a9

File tree

1 file changed

+27
-9
lines changed

1 file changed

+27
-9
lines changed

engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2419,10 +2419,9 @@ private void migrateThroughHypervisorOrStorage(VMInstanceVO vm, Map<Volume, Stor
24192419
final Long sourceClusterId = vmClusterAndHost.first();
24202420
final Long sourceHostId = vmClusterAndHost.second();
24212421
Answer[] hypervisorMigrationResults = attemptHypervisorMigration(vm, volumeToPool, sourceHostId);
2422-
boolean migrationResult = false;
24232422
if (hypervisorMigrationResults == null) {
24242423
// OfflineVmwareMigration: if the HypervisorGuru can't do it, let the volume manager take care of it.
2425-
migrationResult = volumeMgr.storageMigration(profile, volumeToPool);
2424+
boolean migrationResult = volumeMgr.storageMigration(profile, volumeToPool);
24262425
if (migrationResult) {
24272426
postStorageMigrationCleanup(vm, volumeToPool, _hostDao.findById(sourceHostId), sourceClusterId);
24282427
} else {
@@ -2550,13 +2549,32 @@ private void setDestinationPoolAndReallocateNetwork(StoragePool destPool, VMInst
25502549

25512550
private void afterStorageMigrationVmwareVMCleanup(StoragePool destPool, VMInstanceVO vm, HostVO srcHost, Long srcClusterId) {
25522551
// OfflineVmwareMigration: this should only happen on storage migration, else the guru would already have issued the command
2553-
final Long destClusterId = destPool.getClusterId();
2554-
if (srcClusterId != null && destClusterId != null && ! srcClusterId.equals(destClusterId) && srcHost != null) {
2555-
final String srcDcName = _clusterDetailsDao.getVmwareDcName(srcClusterId);
2556-
final String destDcName = _clusterDetailsDao.getVmwareDcName(destClusterId);
2557-
if (srcDcName != null && destDcName != null && !srcDcName.equals(destDcName)) {
2558-
removeStaleVmFromSource(vm, srcHost);
2559-
}
2552+
Long destClusterId = destPool.getClusterId();
2553+
if (destClusterId == null ) {
2554+
s_logger.debug(String.format("No Cluster destination ID was found when doing cleanup after Vmware"));
2555+
return;
2556+
}
2557+
Long srcHostId = vm.getHostId() != null ? vm.getHostId() : vm.getLastHostId();
2558+
if (srcHostId == null) {
2559+
s_logger.debug(String.format("No Host ID was found when doing cleanup after Vmware migration for VM with ID = [%d] and Cluster destination ID = [%d]", vm.getId(), destClusterId));
2560+
return;
2561+
}
2562+
if (srcHost == null) {
2563+
s_logger.debug(String.format("When doing cleanup after Vmware migration could not find a host for the given ID = [%d]", srcHostId));
2564+
return;
2565+
}
2566+
if (srcClusterId == null ) {
2567+
s_logger.debug(String.format("No Cluster ID was found when doing cleanup after Vmware"));
2568+
return;
2569+
}
2570+
if (srcClusterId.equals(destClusterId)) {
2571+
s_logger.debug("Since the Source cluster ID [%s] is equal to the Destination cluster ID [%s] we do not need to proceed with the clean up after migration");
2572+
return;
2573+
}
2574+
String srcDcName = _clusterDetailsDao.getVmwareDcName(srcClusterId);
2575+
String destDcName = _clusterDetailsDao.getVmwareDcName(destClusterId);
2576+
if (StringUtils.isNotBlank(srcDcName) && StringUtils.isNotBlank(destDcName)) {
2577+
removeStaleVmFromSource(vm, srcHost);
25602578
}
25612579
}
25622580

0 commit comments

Comments
 (0)