Fix Vmware to KVM migration (#8485)

This PR fixes the Vmware to KVM migration issue on main branch

Fixes: #8473
This commit is contained in:
Nicolas Vazquez 2024-01-11 03:32:02 -03:00 committed by GitHub
parent c43b7c04f4
commit 64f4480ef4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1064,7 +1064,7 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager {
final VirtualMachineTemplate template, final String displayName, final String hostName, final Account caller, final Account owner, final Long userId, final VirtualMachineTemplate template, final String displayName, final String hostName, final Account caller, final Account owner, final Long userId,
final ServiceOfferingVO serviceOffering, final Map<String, Long> dataDiskOfferingMap, final ServiceOfferingVO serviceOffering, final Map<String, Long> dataDiskOfferingMap,
final Map<String, Long> nicNetworkMap, final Map<String, Network.IpAddresses> callerNicIpAddressMap, final Map<String, Long> nicNetworkMap, final Map<String, Network.IpAddresses> callerNicIpAddressMap,
final Map<String, String> details, final boolean migrateAllowed, final boolean forced) { final Map<String, String> details, final boolean migrateAllowed, final boolean forced, final boolean isImportUnmanagedFromSameHypervisor) {
LOGGER.debug(LogUtils.logGsonWithoutException("Trying to import VM [%s] with name [%s], in zone [%s], cluster [%s], and host [%s], using template [%s], service offering [%s], disks map [%s], NICs map [%s] and details [%s].", LOGGER.debug(LogUtils.logGsonWithoutException("Trying to import VM [%s] with name [%s], in zone [%s], cluster [%s], and host [%s], using template [%s], service offering [%s], disks map [%s], NICs map [%s] and details [%s].",
unmanagedInstance, instanceName, zone, cluster, host, template, serviceOffering, dataDiskOfferingMap, nicNetworkMap, details)); unmanagedInstance, instanceName, zone, cluster, host, template, serviceOffering, dataDiskOfferingMap, nicNetworkMap, details));
UserVm userVm = null; UserVm userVm = null;
@ -1112,7 +1112,7 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager {
} }
} }
allDetails.put(VmDetailConstants.ROOT_DISK_CONTROLLER, rootDisk.getController()); allDetails.put(VmDetailConstants.ROOT_DISK_CONTROLLER, rootDisk.getController());
if (cluster.getHypervisorType() != Hypervisor.HypervisorType.VMware) { if (cluster.getHypervisorType() == Hypervisor.HypervisorType.KVM && isImportUnmanagedFromSameHypervisor) {
allDetails.put(VmDetailConstants.ROOT_DISK_SIZE, String.valueOf(rootDisk.getCapacity() / Resource.ResourceType.bytesToGiB)); allDetails.put(VmDetailConstants.ROOT_DISK_SIZE, String.valueOf(rootDisk.getCapacity() / Resource.ResourceType.bytesToGiB));
} }
@ -1512,7 +1512,7 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager {
template, displayName, hostName, CallContext.current().getCallingAccount(), owner, userId, template, displayName, hostName, CallContext.current().getCallingAccount(), owner, userId,
serviceOffering, dataDiskOfferingMap, serviceOffering, dataDiskOfferingMap,
nicNetworkMap, nicIpAddressMap, nicNetworkMap, nicIpAddressMap,
details, migrateAllowed, forced); details, migrateAllowed, forced, true);
break; break;
} }
if (userVm != null) { if (userVm != null) {
@ -1582,7 +1582,7 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager {
template, displayName, hostName, caller, owner, userId, template, displayName, hostName, caller, owner, userId,
serviceOffering, dataDiskOfferingMap, serviceOffering, dataDiskOfferingMap,
nicNetworkMap, nicIpAddressMap, nicNetworkMap, nicIpAddressMap,
details, false, forced); details, false, forced, false);
LOGGER.debug(String.format("VM %s imported successfully", sourceVM)); LOGGER.debug(String.format("VM %s imported successfully", sourceVM));
return userVm; return userVm;
} catch (CloudRuntimeException e) { } catch (CloudRuntimeException e) {