shwstppr commented on code in PR #7554:
URL: https://github.com/apache/cloudstack/pull/7554#discussion_r1210037400
##########
server/src/main/java/com/cloud/vm/UserVmManagerImpl.java:
##########
@@ -6942,8 +6957,9 @@ public VirtualMachine
migrateVirtualMachineWithVolume(Long vmId, Host destinatio
Pair<Host, Host> sourceDestinationHosts =
getHostsForMigrateVmWithStorage(vm, destinationHost);
Host srcHost = sourceDestinationHosts.first();
- if (!isVMUsingLocalStorage(vm) && MapUtils.isEmpty(volumeToPool)
- &&
(destinationHost.getClusterId().equals(srcHost.getClusterId()) ||
isVmVolumesOnZoneWideStore(vm))){
+ final List<VolumeVO> volumes =
_volsDao.findCreatedByInstance(vm.getId());
+ if (!isAnyVmVolumeUsingLocalStorage(volumes) &&
MapUtils.isEmpty(volumeToPool) && destinationHost != null
+ &&
(destinationHost.getClusterId().equals(srcHost.getClusterId()) ||
isAllVmVolumesOnZoneWideStore(volumes))) {
Review Comment:
Done
##########
api/src/main/java/org/apache/cloudstack/api/command/admin/vm/MigrateVirtualMachineWithVolumeCmd.java:
##########
@@ -146,28 +152,31 @@ public ApiCommandResourceType getApiResourceType() {
@Override
public void execute() {
- if (hostId == null && MapUtils.isEmpty(migrateVolumeTo)) {
- throw new InvalidParameterValueException(String.format("Either %s
or %s must be passed for migrating the VM.", ApiConstants.HOST_ID,
ApiConstants.MIGRATE_TO));
+ if (hostId == null && MapUtils.isEmpty(migrateVolumeTo) &&
!Boolean.TRUE.equals(autoSelect)) {
+ throw new InvalidParameterValueException(String.format("Either %s
or %s must be passed or %s must be true for migrating the VM.",
ApiConstants.HOST_ID, ApiConstants.MIGRATE_TO, ApiConstants.AUTO_SELECT));
}
VirtualMachine virtualMachine =
_userVmService.getVm(getVirtualMachineId());
- if (!VirtualMachine.State.Running.equals(virtualMachine.getState()) &&
hostId != null) {
+ if (!VirtualMachine.State.Running.equals(virtualMachine.getState()) &&
(hostId != null || Boolean.TRUE.equals(autoSelect))) {
throw new InvalidParameterValueException(String.format("%s is not
in the Running state to migrate it to the new host.", virtualMachine));
}
- if (!VirtualMachine.State.Stopped.equals(virtualMachine.getState()) &&
hostId == null) {
- throw new InvalidParameterValueException(String.format("%s is not
in the Stopped state to migrate, use the %s parameter to migrate it to a new
host.",
- virtualMachine, ApiConstants.HOST_ID));
+ if (!VirtualMachine.State.Stopped.equals(virtualMachine.getState()) &&
hostId == null && Boolean.FALSE.equals(autoSelect)) {
+ throw new InvalidParameterValueException(String.format("%s is not
in the Stopped state to migrate, use the %s or %s parameter to migrate it to a
new host.",
+ virtualMachine,
ApiConstants.HOST_ID,ApiConstants.AUTO_SELECT));
}
try {
VirtualMachine migratedVm = null;
- if (hostId != null) {
- Host destinationHost = _resourceService.getHost(getHostId());
- // OfflineVmwareMigration: destination host would have to not
be a required parameter for stopped VMs
- if (destinationHost == null) {
- s_logger.error(String.format("Unable to find the host with
ID [%s].", getHostId()));
- throw new InvalidParameterValueException("Unable to find
the specified host to migrate the VM.");
+ if (getHostId() != null || Boolean.TRUE.equals(autoSelect)) {
+ Host destinationHost = null;
+ if (!Boolean.TRUE.equals(autoSelect)) {
Review Comment:
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]