Skip to content

Commit 75147b7

Browse files
authored
[Vmware to KVM Migration] Display virt-v2v and ovftool versions for supported hosts for migration (#11019)
* [Vmware to KVM Migration] Display virt-v2v and ovftool versions for supported hosts for migration * Fix UI display * Address review comments * Fix ovftool and version display - also display versions on host details view
1 parent 5790091 commit 75147b7

File tree

7 files changed

+81
-6
lines changed

7 files changed

+81
-6
lines changed

api/src/main/java/com/cloud/host/Host.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,12 @@ public static String[] toStrings(Host.Type... types) {
5353
return strs;
5454
}
5555
}
56-
public static final String HOST_UEFI_ENABLE = "host.uefi.enable";
57-
public static final String HOST_VOLUME_ENCRYPTION = "host.volume.encryption";
58-
public static final String HOST_INSTANCE_CONVERSION = "host.instance.conversion";
56+
57+
String HOST_UEFI_ENABLE = "host.uefi.enable";
58+
String HOST_VOLUME_ENCRYPTION = "host.volume.encryption";
59+
String HOST_INSTANCE_CONVERSION = "host.instance.conversion";
60+
String HOST_OVFTOOL_VERSION = "host.ovftool.version";
61+
String HOST_VIRTV2V_VERSION = "host.virtv2v.version";
5962

6063
/**
6164
* @return name of the machine.

engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils;
5555
import org.apache.commons.collections.MapUtils;
5656
import org.apache.commons.lang3.BooleanUtils;
57+
import org.apache.commons.lang3.ObjectUtils;
5758
import org.apache.commons.lang3.StringUtils;
5859
import org.apache.logging.log4j.ThreadContext;
5960

@@ -703,11 +704,25 @@ protected AgentAttache notifyMonitorsOfConnection(final AgentAttache attache, fi
703704
Map<String, String> detailsMap = readyAnswer.getDetailsMap();
704705
if (detailsMap != null) {
705706
String uefiEnabled = detailsMap.get(Host.HOST_UEFI_ENABLE);
707+
String virtv2vVersion = detailsMap.get(Host.HOST_VIRTV2V_VERSION);
708+
String ovftoolVersion = detailsMap.get(Host.HOST_OVFTOOL_VERSION);
706709
logger.debug("Got HOST_UEFI_ENABLE [{}] for host [{}]:", uefiEnabled, host);
707-
if (uefiEnabled != null) {
710+
if (ObjectUtils.anyNotNull(uefiEnabled, virtv2vVersion, ovftoolVersion)) {
708711
_hostDao.loadDetails(host);
712+
boolean updateNeeded = false;
709713
if (!uefiEnabled.equals(host.getDetails().get(Host.HOST_UEFI_ENABLE))) {
710714
host.getDetails().put(Host.HOST_UEFI_ENABLE, uefiEnabled);
715+
updateNeeded = true;
716+
}
717+
if (StringUtils.isNotBlank(virtv2vVersion) && !virtv2vVersion.equals(host.getDetails().get(Host.HOST_VIRTV2V_VERSION))) {
718+
host.getDetails().put(Host.HOST_VIRTV2V_VERSION, virtv2vVersion);
719+
updateNeeded = true;
720+
}
721+
if (StringUtils.isNotBlank(ovftoolVersion) && !ovftoolVersion.equals(host.getDetails().get(Host.HOST_OVFTOOL_VERSION))) {
722+
host.getDetails().put(Host.HOST_OVFTOOL_VERSION, ovftoolVersion);
723+
updateNeeded = true;
724+
}
725+
if (updateNeeded) {
711726
_hostDao.saveDetails(host);
712727
}
713728
}

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
package com.cloud.hypervisor.kvm.resource;
1818

1919
import static com.cloud.host.Host.HOST_INSTANCE_CONVERSION;
20+
import static com.cloud.host.Host.HOST_OVFTOOL_VERSION;
21+
import static com.cloud.host.Host.HOST_VIRTV2V_VERSION;
2022
import static com.cloud.host.Host.HOST_VOLUME_ENCRYPTION;
2123

2224
import java.io.BufferedReader;
@@ -3766,7 +3768,14 @@ public StartupCommand[] initialize() {
37663768
cmd.setIqn(getIqn());
37673769
cmd.getHostDetails().put(HOST_VOLUME_ENCRYPTION, String.valueOf(hostSupportsVolumeEncryption()));
37683770
cmd.setHostTags(getHostTags());
3769-
cmd.getHostDetails().put(HOST_INSTANCE_CONVERSION, String.valueOf(hostSupportsInstanceConversion()));
3771+
boolean instanceConversionSupported = hostSupportsInstanceConversion();
3772+
cmd.getHostDetails().put(HOST_INSTANCE_CONVERSION, String.valueOf(instanceConversionSupported));
3773+
if (instanceConversionSupported) {
3774+
cmd.getHostDetails().put(HOST_VIRTV2V_VERSION, getHostVirtV2vVersion());
3775+
}
3776+
if (hostSupportsOvfExport()) {
3777+
cmd.getHostDetails().put(HOST_OVFTOOL_VERSION, getHostOvfToolVersion());
3778+
}
37703779
HealthCheckResult healthCheckResult = getHostHealthCheckResult();
37713780
if (healthCheckResult != HealthCheckResult.IGNORE) {
37723781
cmd.setHostHealthCheckResult(healthCheckResult == HealthCheckResult.SUCCESS);
@@ -5368,8 +5377,24 @@ public boolean hostSupportsOvfExport() {
53685377
return exitValue == 0;
53695378
}
53705379

5380+
public String getHostVirtV2vVersion() {
5381+
if (!hostSupportsInstanceConversion()) {
5382+
return "";
5383+
}
5384+
String cmd = String.format("%s | awk '{print $2}'", INSTANCE_CONVERSION_SUPPORTED_CHECK_CMD);
5385+
String version = Script.runSimpleBashScript(cmd);
5386+
return StringUtils.isNotBlank(version) ? version.split(",")[0] : "";
5387+
}
5388+
5389+
public String getHostOvfToolVersion() {
5390+
if (!hostSupportsOvfExport()) {
5391+
return "";
5392+
}
5393+
return Script.runSimpleBashScript(OVF_EXPORT_TOOl_GET_VERSION_CMD);
5394+
}
5395+
53715396
public boolean ovfExportToolSupportsParallelThreads() {
5372-
String ovfExportToolVersion = Script.runSimpleBashScript(OVF_EXPORT_TOOl_GET_VERSION_CMD);
5397+
String ovfExportToolVersion = getHostOvfToolVersion();
53735398
if (StringUtils.isBlank(ovfExportToolVersion)) {
53745399
return false;
53755400
}

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtReadyCommandWrapper.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ public Answer execute(final ReadyCommand command, final LibvirtComputingResource
4747
hostDetails.put(Host.HOST_UEFI_ENABLE, Boolean.TRUE.toString());
4848
}
4949

50+
if (libvirtComputingResource.hostSupportsInstanceConversion()) {
51+
hostDetails.put(Host.HOST_VIRTV2V_VERSION, libvirtComputingResource.getHostVirtV2vVersion());
52+
}
53+
54+
if (libvirtComputingResource.hostSupportsOvfExport()) {
55+
hostDetails.put(Host.HOST_OVFTOOL_VERSION, libvirtComputingResource.getHostOvfToolVersion());
56+
}
57+
5058
return new ReadyAnswer(command, hostDetails);
5159
}
5260

ui/public/locales/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,9 @@
10891089
"label.host": "IP address",
10901090
"label.host.alerts": "Hosts in alert state",
10911091
"label.host.name": "Host name",
1092+
"label.host.ovftool.version": "OVFTool Version",
10921093
"label.host.tag": "Host tag",
1094+
"label.host.virtv2v.version": "Virt-v2v Version",
10931095
"label.hostcontrolstate": "Compute Resource Status",
10941096
"label.hostid": "Host",
10951097
"label.hostname": "Host",

ui/src/views/infra/HostInfo.vue

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,22 @@
5656
</div>
5757
</div>
5858
</a-list-item>
59+
<a-list-item v-if="host.details && host.details['host.virtv2v.version']">
60+
<div>
61+
<strong>{{ $t('label.host.virtv2v.version') }}</strong>
62+
<div>
63+
{{ host.details['host.virtv2v.version'] }}
64+
</div>
65+
</div>
66+
</a-list-item>
67+
<a-list-item v-if="host.details && host.details['host.ovftool.version']">
68+
<div>
69+
<strong>{{ $t('label.host.ovftool.version') }}</strong>
70+
<div>
71+
{{ host.details['host.ovftool.version'] }}
72+
</div>
73+
</div>
74+
</a-list-item>
5975
<a-list-item v-if="host.hosttags">
6076
<div>
6177
<strong>{{ $t('label.hosttags') }}</strong>

ui/src/views/tools/ImportUnmanagedInstance.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,12 @@ export default {
944944
} else {
945945
host.name = host.name + ' (' + this.$t('label.not.supported') + ')'
946946
}
947+
if (host.details['host.virtv2v.version']) {
948+
host.name = host.name + ' (virt-v2v=' + host.details['host.virtv2v.version'] + ')'
949+
}
950+
if (host.details['host.ovftool.version']) {
951+
host.name = host.name + ' (ovftool=' + host.details['host.ovftool.version'] + ')'
952+
}
947953
})
948954
})
949955
},

0 commit comments

Comments
 (0)