weizhouapache commented on a change in pull request #4378:
URL: https://github.com/apache/cloudstack/pull/4378#discussion_r658756669
##########
File path: server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
##########
@@ -5895,8 +5897,46 @@ public VirtualMachine migrateVirtualMachine(Long vmId,
Host destinationHost) thr
throw new InvalidParameterValueException("Cannot migrate VM, host
with id: " + srcHostId + " for VM not found");
}
+ DeployDestination dest = null;
+ if (destinationHost == null) {
+ vm.setLastHostId(null); // Last host does not have higher priority
in vm migration
+ final ServiceOfferingVO offering =
_offeringDao.findById(vm.getId(), vm.getServiceOfferingId());
+ final VirtualMachineProfile profile = new
VirtualMachineProfileImpl(vm, null, offering, null, null);
+ final Host host = _hostDao.findById(srcHostId);
+ final DataCenterDeployment plan = new
DataCenterDeployment(host.getDataCenterId(), host.getPodId(),
host.getClusterId(), null, null, null);
+ ExcludeList excludes = new ExcludeList();
+ excludes.addHost(srcHostId);
+ try {
+ dest = _planningMgr.planDeployment(profile, plan, excludes,
null);
+ } catch (final AffinityConflictException e2) {
+ s_logger.warn("Unable to create deployment, affinity rules
associted to the VM conflict", e2);
+ throw new CloudRuntimeException("Unable to create deployment,
affinity rules associted to the VM conflict");
+ } catch (final InsufficientServerCapacityException e3) {
+ throw new CloudRuntimeException("Unable to find a server to
migrate the vm to");
+ }
+ } else {
+ dest = checkVmMigrationDestination(vm, srcHost, destinationHost);
+ }
Review comment:
@DaanHoogland done.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]