Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)) {
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the deployasis check doesn't apply here, since Vmware to KVM migrations won't have that boolean enabled then converted VMs will never retain the boot mode and type. In case the VM is deploy as is then the boot mode and type will be preserved.
For the bootMode I think we do need to check if its not blank as that is the value we are adding as detail for the converted VM.

allDetails.put("UEFI", bootMode);

Check warning on line 1267 in server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java#L1267

Added line #L1267 was not covered by tests
}
}

private HashMap<String, UnmanagedInstanceTO> getUnmanagedInstancesForHost(HostVO host, String instanceName, List<String> managedVms) {
HashMap<String, UnmanagedInstanceTO> unmanagedInstances = new HashMap<>();
if (host.isInMaintenanceStates()) {
Expand Down Expand Up @@ -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());
Copy link
Contributor

Choose a reason for hiding this comment

The 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 unmanagedInstance and it is already passed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks - fixed

break;
}
if (userVm != null) {
Expand Down Expand Up @@ -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()));
Expand Down
12 changes: 12 additions & 0 deletions ui/src/components/view/InfoCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,18 @@
<span v-else>{{ resource.webhookname || resource.webhookid }}</span>
</div>
</div>
<div class="resource-detail-item" v-if="resource.boottype">
<div class="resource-detail-item__label">{{ $t('label.boottype') }}</div>
<div class="resource-detail-item__details">
<span>{{ resource.boottype }}</span>
</div>
</div>
<div class="resource-detail-item" v-if="resource.bootmode">
<div class="resource-detail-item__label">{{ $t('label.bootmode') }}</div>
<div class="resource-detail-item__details">
<span>{{ resource.bootmode }}</span>
</div>
</div>
<div class="resource-detail-item" v-if="resource.managementserverid">
<div class="resource-detail-item__label">{{ $t('label.management.servers') }}</div>
<div class="resource-detail-item__details">
Expand Down
Loading