Skip to content

Commit 66cdeac

Browse files
nvazquezdhslove
authored andcommitted
[Vmware to KVM Migration] Display virt-v2v and ovftool versions for supported hosts for migration (apache#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 d936d71 commit 66cdeac

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
public static final String HOST_TPM_ENABLE = "host.tpm.enable";
6164

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
@@ -62,6 +62,7 @@
6262
import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils;
6363
import org.apache.commons.collections.MapUtils;
6464
import org.apache.commons.lang3.BooleanUtils;
65+
import org.apache.commons.lang3.ObjectUtils;
6566
import org.apache.commons.lang3.StringUtils;
6667
import org.apache.logging.log4j.ThreadContext;
6768

@@ -806,11 +807,25 @@ protected AgentAttache notifyMonitorsOfConnection(final AgentAttache attache, fi
806807
Map<String, String> detailsMap = readyAnswer.getDetailsMap();
807808
if (detailsMap != null) {
808809
String uefiEnabled = detailsMap.get(Host.HOST_UEFI_ENABLE);
810+
String virtv2vVersion = detailsMap.get(Host.HOST_VIRTV2V_VERSION);
811+
String ovftoolVersion = detailsMap.get(Host.HOST_OVFTOOL_VERSION);
809812
logger.debug("Got HOST_UEFI_ENABLE [{}] for host [{}]:", uefiEnabled, host);
810-
if (uefiEnabled != null) {
813+
if (ObjectUtils.anyNotNull(uefiEnabled, virtv2vVersion, ovftoolVersion)) {
811814
_hostDao.loadDetails(host);
815+
boolean updateNeeded = false;
812816
if (!uefiEnabled.equals(host.getDetails().get(Host.HOST_UEFI_ENABLE))) {
813817
host.getDetails().put(Host.HOST_UEFI_ENABLE, uefiEnabled);
818+
updateNeeded = true;
819+
}
820+
if (StringUtils.isNotBlank(virtv2vVersion) && !virtv2vVersion.equals(host.getDetails().get(Host.HOST_VIRTV2V_VERSION))) {
821+
host.getDetails().put(Host.HOST_VIRTV2V_VERSION, virtv2vVersion);
822+
updateNeeded = true;
823+
}
824+
if (StringUtils.isNotBlank(ovftoolVersion) && !ovftoolVersion.equals(host.getDetails().get(Host.HOST_OVFTOOL_VERSION))) {
825+
host.getDetails().put(Host.HOST_OVFTOOL_VERSION, ovftoolVersion);
826+
updateNeeded = true;
827+
}
828+
if (updateNeeded) {
814829
_hostDao.saveDetails(host);
815830
}
816831
}

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
import static org.apache.cloudstack.utils.linux.KVMHostInfo.isHostS390x;
2224

@@ -4366,7 +4368,14 @@ public StartupCommand[] initialize() {
43664368

43674369
cmd.getHostDetails().put(HOST_VOLUME_ENCRYPTION, String.valueOf(hostSupportsVolumeEncryption()));
43684370
cmd.setHostTags(getHostTags());
4369-
cmd.getHostDetails().put(HOST_INSTANCE_CONVERSION, String.valueOf(hostSupportsInstanceConversion()));
4371+
boolean instanceConversionSupported = hostSupportsInstanceConversion();
4372+
cmd.getHostDetails().put(HOST_INSTANCE_CONVERSION, String.valueOf(instanceConversionSupported));
4373+
if (instanceConversionSupported) {
4374+
cmd.getHostDetails().put(HOST_VIRTV2V_VERSION, getHostVirtV2vVersion());
4375+
}
4376+
if (hostSupportsOvfExport()) {
4377+
cmd.getHostDetails().put(HOST_OVFTOOL_VERSION, getHostOvfToolVersion());
4378+
}
43704379
HealthCheckResult healthCheckResult = getHostHealthCheckResult();
43714380
if (healthCheckResult != HealthCheckResult.IGNORE) {
43724381
cmd.setHostHealthCheckResult(healthCheckResult == HealthCheckResult.SUCCESS);
@@ -6296,8 +6305,24 @@ public boolean hostSupportsOvfExport() {
62966305
return exitValue == 0;
62976306
}
62986307

6308+
public String getHostVirtV2vVersion() {
6309+
if (!hostSupportsInstanceConversion()) {
6310+
return "";
6311+
}
6312+
String cmd = String.format("%s | awk '{print $2}'", INSTANCE_CONVERSION_SUPPORTED_CHECK_CMD);
6313+
String version = Script.runSimpleBashScript(cmd);
6314+
return StringUtils.isNotBlank(version) ? version.split(",")[0] : "";
6315+
}
6316+
6317+
public String getHostOvfToolVersion() {
6318+
if (!hostSupportsOvfExport()) {
6319+
return "";
6320+
}
6321+
return Script.runSimpleBashScript(OVF_EXPORT_TOOl_GET_VERSION_CMD);
6322+
}
6323+
62996324
public boolean ovfExportToolSupportsParallelThreads() {
6300-
String ovfExportToolVersion = Script.runSimpleBashScript(OVF_EXPORT_TOOl_GET_VERSION_CMD);
6325+
String ovfExportToolVersion = getHostOvfToolVersion();
63016326
if (StringUtils.isBlank(ovfExportToolVersion)) {
63026327
return false;
63036328
}

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
@@ -1151,7 +1151,9 @@
11511151
"label.host": "IP address",
11521152
"label.host.alerts": "Hosts in alert state",
11531153
"label.host.name": "Host name",
1154+
"label.host.ovftool.version": "OVFTool Version",
11541155
"label.host.tag": "Host tag",
1156+
"label.host.virtv2v.version": "Virt-v2v Version",
11551157
"label.hostcontrolstate": "Compute Resource Status",
11561158
"label.hostid": "Host",
11571159
"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
@@ -946,6 +946,12 @@ export default {
946946
} else {
947947
host.name = host.name + ' (' + this.$t('label.not.supported') + ')'
948948
}
949+
if (host.details['host.virtv2v.version']) {
950+
host.name = host.name + ' (virt-v2v=' + host.details['host.virtv2v.version'] + ')'
951+
}
952+
if (host.details['host.ovftool.version']) {
953+
host.name = host.name + ' (ovftool=' + host.details['host.ovftool.version'] + ')'
954+
}
949955
})
950956
})
951957
},

0 commit comments

Comments
 (0)