Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
16 changes: 16 additions & 0 deletions agent/conf/agent.properties
Original file line number Diff line number Diff line change
Expand Up @@ -457,3 +457,19 @@ iscsi.session.cleanup.enabled=false

# Instance conversion VIRT_V2V_TMPDIR env var
#convert.instance.env.virtv2v.tmpdir=

# LIBGUESTFS backend to use for VMware to KVM conversion via VDDK (default: direct)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should keep other possible options in the comment (other than direct) ?

#libguestfs.backend=direct

# Path to the VDDK library directory for VMware to KVM conversion via VDDK,
# passed to virt-v2v as -io vddk-libdir=<path>
#vddk.lib.dir=

# Ordered VDDK transport preference for VMware to KVM conversion via VDDK, passed as
# -io vddk-transports=<value> to virt-v2v. Example: nbd:nbdssl
#vddk.transports=

# Optional vCenter SHA1 thumbprint for VMware to KVM conversion via VDDK, passed as
# -io vddk-thumbprint=<value>. If unset, CloudStack computes it on the KVM host via openssl.
#vddk.thumbprint=

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,37 @@ public Property<Integer> getWorkers() {
*/
public static final Property<String> CONVERT_ENV_VIRTV2V_TMPDIR = new Property<>("convert.instance.env.virtv2v.tmpdir", null, String.class);

/**
* Path to the VDDK library directory on the KVM conversion host, used when converting VMs from VMware to KVM via VDDK.
* This directory is passed to virt-v2v as <code>-io vddk-libdir=&lt;path&gt;</code>.
* Data type: String.<br>
* Default value: <code>null</code>
*/
public static final Property<String> VDDK_LIB_DIR = new Property<>("vddk.lib.dir", null, String.class);

/**
* Value for the LIBGUESTFS_BACKEND env var used during VMware to KVM conversion via VDDK.
* Data type: String.<br>
* Default value: <code>direct</code>
*/
public static final Property<String> LIBGUESTFS_BACKEND = new Property<>("libguestfs.backend", "direct", String.class);

/**
* Ordered list of VDDK transports for virt-v2v, passed as <code>-io vddk-transports=&lt;value&gt;</code>.
* Example: <code>nbd:nbdssl</code>.
* Data type: String.<br>
* Default value: <code>null</code>
*/
public static final Property<String> VDDK_TRANSPORTS = new Property<>("vddk.transports", null, String.class);

/**
* vCenter TLS certificate thumbprint used by virt-v2v VDDK mode, passed as <code>-io vddk-thumbprint=&lt;value&gt;</code>.
* If unset, the KVM host computes it at runtime from the vCenter endpoint.
* Data type: String.<br>
* Default value: <code>null</code>
*/
public static final Property<String> VDDK_THUMBPRINT = new Property<>("vddk.thumbprint", null, String.class);

/**
* BGP controll CIDR
* Data type: String.<br>
Expand Down
20 changes: 19 additions & 1 deletion api/src/main/java/com/cloud/agent/api/to/RemoteInstanceTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,17 @@ public class RemoteInstanceTO implements Serializable {
private String vcenterPassword;
private String vcenterHost;
private String datacenterName;
private String clusterName;
private String hostName;

public RemoteInstanceTO() {
}

public RemoteInstanceTO(String instanceName) {
public RemoteInstanceTO(String instanceName, String clusterName, String hostName) {
this.hypervisorType = Hypervisor.HypervisorType.VMware;
this.instanceName = instanceName;
this.clusterName = clusterName;
this.hostName = hostName;
}

public RemoteInstanceTO(String instanceName, String instancePath, String vcenterHost, String vcenterUsername, String vcenterPassword, String datacenterName) {
Expand All @@ -55,6 +59,12 @@ public RemoteInstanceTO(String instanceName, String instancePath, String vcenter
this.datacenterName = datacenterName;
}

public RemoteInstanceTO(String instanceName, String instancePath, String vcenterHost, String vcenterUsername, String vcenterPassword, String datacenterName, String clusterName, String hostName) {
this(instanceName, instancePath, vcenterHost, vcenterUsername, vcenterPassword, datacenterName);
this.clusterName = clusterName;
this.hostName = hostName;
}

public Hypervisor.HypervisorType getHypervisorType() {
return this.hypervisorType;
}
Expand Down Expand Up @@ -82,4 +92,12 @@ public String getVcenterHost() {
public String getDatacenterName() {
return datacenterName;
}

public String getClusterName() {
return clusterName;
}

public String getHostName() {
return hostName;
}
}
3 changes: 3 additions & 0 deletions api/src/main/java/com/cloud/host/Host.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public static String[] toStrings(Host.Type... types) {
String HOST_UEFI_ENABLE = "host.uefi.enable";
String HOST_VOLUME_ENCRYPTION = "host.volume.encryption";
String HOST_INSTANCE_CONVERSION = "host.instance.conversion";
String HOST_VDDK_SUPPORT = "host.vddk.support";
String HOST_VDDK_LIB_DIR = "vddk.lib.dir";
String HOST_VDDK_VERSION = "host.vddk.version";
String HOST_OVFTOOL_VERSION = "host.ovftool.version";
String HOST_VIRTV2V_VERSION = "host.virtv2v.version";
String HOST_SSH_PORT = "host.ssh.port";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ public class ApiConstants {
public static final String USER_CONFIGURABLE = "userconfigurable";
public static final String USER_SECURITY_GROUP_LIST = "usersecuritygrouplist";
public static final String USER_SECRET_KEY = "usersecretkey";
public static final String USE_VDDK = "usevddk";
public static final String USE_VIRTUAL_NETWORK = "usevirtualnetwork";
public static final String USE_VIRTUAL_ROUTER_IP_RESOLVER = "userouteripresolver";
public static final String UPDATE_IN_SEQUENCE = "updateinsequence";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@ public class ImportVmCmd extends ImportUnmanagedInstanceCmd {
description = "(only for importing VMs from VMware to KVM) optional - the ID of the guest OS for the imported VM.")
private Long guestOsId;

@Parameter(name = ApiConstants.USE_VDDK,
type = CommandType.BOOLEAN,
since = "4.22.1",
description = "(only for importing VMs from VMware to KVM) optional - if true, uses VDDK on the KVM conversion host for converting the VM. " +
"This parameter is mutually exclusive with " + ApiConstants.FORCE_MS_TO_IMPORT_VM_FILES + ".")
private Boolean useVddk;


/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
Expand Down Expand Up @@ -255,6 +263,10 @@ public Long getStoragePoolId() {
return storagePoolId;
}

public boolean getUseVddk() {
return BooleanUtils.toBooleanDefaultIfNull(useVddk, true);
}

public String getTmpPath() {
return tmpPath;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

public class CheckConvertInstanceCommand extends Command {
boolean checkWindowsGuestConversionSupport = false;
boolean useVddk = false;
String vddkLibDir;

public CheckConvertInstanceCommand() {
}
Expand All @@ -26,6 +28,11 @@ public CheckConvertInstanceCommand(boolean checkWindowsGuestConversionSupport) {
this.checkWindowsGuestConversionSupport = checkWindowsGuestConversionSupport;
}

public CheckConvertInstanceCommand(boolean checkWindowsGuestConversionSupport, boolean useVddk) {
this.checkWindowsGuestConversionSupport = checkWindowsGuestConversionSupport;
this.useVddk = useVddk;
}

@Override
public boolean executeInSequence() {
return false;
Expand All @@ -34,4 +41,20 @@ public boolean executeInSequence() {
public boolean getCheckWindowsGuestConversionSupport() {
return checkWindowsGuestConversionSupport;
}

public boolean isUseVddk() {
return useVddk;
}

public void setUseVddk(boolean useVddk) {
this.useVddk = useVddk;
}

public String getVddkLibDir() {
return vddkLibDir;
}

public void setVddkLibDir(String vddkLibDir) {
this.vddkLibDir = vddkLibDir;
}
}
45 changes: 45 additions & 0 deletions core/src/main/java/com/cloud/agent/api/ConvertInstanceCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public class ConvertInstanceCommand extends Command {
private boolean exportOvfToConversionLocation;
private int threadsCountToExportOvf = 0;
private String extraParams;
private boolean useVddk;
private String libguestfsBackend;
private String vddkLibDir;
private String vddkTransports;
private String vddkThumbprint;

public ConvertInstanceCommand() {
}
Expand Down Expand Up @@ -90,6 +95,46 @@ public void setExtraParams(String extraParams) {
this.extraParams = extraParams;
}

public boolean isUseVddk() {
return useVddk;
}

public void setUseVddk(boolean useVddk) {
this.useVddk = useVddk;
}

public String getLibguestfsBackend() {
return libguestfsBackend;
}

public void setLibguestfsBackend(String libguestfsBackend) {
this.libguestfsBackend = libguestfsBackend;
}

public String getVddkLibDir() {
return vddkLibDir;
}

public void setVddkLibDir(String vddkLibDir) {
this.vddkLibDir = vddkLibDir;
}

public String getVddkTransports() {
return vddkTransports;
}

public void setVddkTransports(String vddkTransports) {
this.vddkTransports = vddkTransports;
}

public String getVddkThumbprint() {
return vddkThumbprint;
}

public void setVddkThumbprint(String vddkThumbprint) {
this.vddkThumbprint = vddkThumbprint;
}

@Override
public boolean executeInSequence() {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -805,8 +805,11 @@ protected AgentAttache notifyMonitorsOfConnection(final AgentAttache attache, fi
String uefiEnabled = detailsMap.get(Host.HOST_UEFI_ENABLE);
String virtv2vVersion = detailsMap.get(Host.HOST_VIRTV2V_VERSION);
String ovftoolVersion = detailsMap.get(Host.HOST_OVFTOOL_VERSION);
String vddkSupport = detailsMap.get(Host.HOST_VDDK_SUPPORT);
String vddkLibDir = detailsMap.get(Host.HOST_VDDK_LIB_DIR);
String vddkVersion = detailsMap.get(Host.HOST_VDDK_VERSION);
logger.debug("Got HOST_UEFI_ENABLE [{}] for host [{}]:", uefiEnabled, host);
if (ObjectUtils.anyNotNull(uefiEnabled, virtv2vVersion, ovftoolVersion)) {
if (ObjectUtils.anyNotNull(uefiEnabled, virtv2vVersion, ovftoolVersion, vddkSupport, vddkLibDir, vddkVersion)) {
_hostDao.loadDetails(host);
boolean updateNeeded = false;
if (StringUtils.isNotBlank(uefiEnabled) && !uefiEnabled.equals(host.getDetails().get(Host.HOST_UEFI_ENABLE))) {
Expand All @@ -821,6 +824,26 @@ protected AgentAttache notifyMonitorsOfConnection(final AgentAttache attache, fi
host.getDetails().put(Host.HOST_OVFTOOL_VERSION, ovftoolVersion);
updateNeeded = true;
}
if (StringUtils.isNotBlank(vddkSupport) && !vddkSupport.equals(host.getDetails().get(Host.HOST_VDDK_SUPPORT))) {
host.getDetails().put(Host.HOST_VDDK_SUPPORT, vddkSupport);
updateNeeded = true;
}
if (!StringUtils.defaultString(vddkLibDir).equals(StringUtils.defaultString(host.getDetails().get(Host.HOST_VDDK_LIB_DIR)))) {
if (StringUtils.isBlank(vddkLibDir)) {
host.getDetails().remove(Host.HOST_VDDK_LIB_DIR);
} else {
host.getDetails().put(Host.HOST_VDDK_LIB_DIR, vddkLibDir);
}
updateNeeded = true;
}
if (!StringUtils.defaultString(vddkVersion).equals(StringUtils.defaultString(host.getDetails().get(Host.HOST_VDDK_VERSION)))) {
if (StringUtils.isBlank(vddkVersion)) {
host.getDetails().remove(Host.HOST_VDDK_VERSION);
} else {
host.getDetails().put(Host.HOST_VDDK_VERSION, vddkVersion);
}
updateNeeded = true;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

do we need all these params in host_details? Persisting Host.HOST_VDDK_VERSION should be enough when vddk lib is properly set, to indicate vddk support.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Version identification is not just enough to claim the support but we will also need the directory where it is located as we need to pass that in the virt-v2v command with vddk.

}
if (updateNeeded) {
_hostDao.saveDetails(host);
}
Expand Down
Loading
Loading