-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[Vmware to KVM Migration] Preserve boot type and boot mode of instances to be migrated #10975
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nvazquez
wants to merge
4
commits into
apache:4.20
Choose a base branch
from
shapeblue:420-vmware2kvm-preserve-boot
base: 4.20
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1113,7 +1113,8 @@ | |
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 Map<String, Long> nicNetworkMap, final Map<String, Network.IpAddresses> callerNicIpAddressMap, | ||
final Map<String, String> details, final boolean migrateAllowed, final boolean forced, final boolean isImportUnmanagedFromSameHypervisor) { | ||
final Map<String, String> details, final boolean migrateAllowed, final boolean forced, final boolean isImportUnmanagedFromSameHypervisor, | ||
final String bootType, final String bootMode) { | ||
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)); | ||
UserVm userVm = null; | ||
|
@@ -1188,6 +1189,8 @@ | |
allDetails.put(VmDetailConstants.KVM_VNC_PASSWORD, unmanagedInstance.getVncPassword()); | ||
} | ||
|
||
addImportingVMBootTypeAndModeDetails(bootType, bootMode, allDetails); | ||
|
||
VirtualMachine.PowerState powerState = VirtualMachine.PowerState.PowerOff; | ||
if (unmanagedInstance.getPowerState().equals(UnmanagedInstanceTO.PowerState.PowerOn)) { | ||
powerState = VirtualMachine.PowerState.PowerOn; | ||
|
@@ -1259,6 +1262,12 @@ | |
return userVm; | ||
} | ||
|
||
private void addImportingVMBootTypeAndModeDetails(String bootType, String bootMode, Map<String, String> allDetails) { | ||
if (StringUtils.isNotBlank(bootType) && bootType.equalsIgnoreCase("uefi") && StringUtils.isNotBlank(bootMode)) { | ||
allDetails.put("UEFI", bootMode); | ||
} | ||
} | ||
|
||
private HashMap<String, UnmanagedInstanceTO> getUnmanagedInstancesForHost(HostVO host, String instanceName, List<String> managedVms) { | ||
HashMap<String, UnmanagedInstanceTO> unmanagedInstances = new HashMap<>(); | ||
if (host.isInMaintenanceStates()) { | ||
|
@@ -1564,7 +1573,8 @@ | |
template, displayName, hostName, CallContext.current().getCallingAccount(), owner, userId, | ||
serviceOffering, dataDiskOfferingMap, | ||
nicNetworkMap, nicIpAddressMap, | ||
details, migrateAllowed, forced, true); | ||
details, migrateAllowed, forced, true, | ||
unmanagedInstance.getBootType(), unmanagedInstance.getBootMode()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @nvazquez do we need to pass them here as they are already returned by |
||
break; | ||
} | ||
if (userVm != null) { | ||
|
@@ -1684,7 +1694,8 @@ | |
template, displayName, hostName, caller, owner, userId, | ||
serviceOffering, dataDiskOfferingMap, | ||
nicNetworkMap, nicIpAddressMap, | ||
details, false, forced, false); | ||
details, false, forced, false, | ||
sourceVMwareInstance.getBootType(), sourceVMwareInstance.getBootMode()); | ||
long timeElapsedInSecs = (System.currentTimeMillis() - importStartTime) / 1000; | ||
logger.debug(String.format("VMware VM %s imported successfully to CloudStack instance %s (%s), Time taken: %d secs, OVF files imported from %s, Source VMware VM details - OS: %s, PowerState: %s, Disks: %s, NICs: %s", | ||
sourceVMName, instanceName, displayName, timeElapsedInSecs, (ovfTemplateOnConvertLocation != null)? "MS" : "KVM Host", sourceVMwareInstance.getOperatingSystem(), sourceVMwareInstance.getPowerState(), sourceVMwareInstance.getDisks(), sourceVMwareInstance.getNics())); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to check if bootMode is blank or not?
In a similar code block in #11218, I added a deployasis check as I saw it in UserVmManagerImpl.commitUserVm, not sure if it is worth adding?