From 1a88a6141855e2dcf247be43f03859c093e75a9a Mon Sep 17 00:00:00 2001 From: Derek Lee Date: Thu, 13 Jul 2023 19:56:11 -0400 Subject: [PATCH] test/libvirt: allow libvirt conn URI to be specified The libvirt tests currently assumes that it is always running on a local instance and hard codes "qemu:///system" as the URI to create the Connection object with. This allows us to specify libvirt_conn_uri in the libvirt properties file to change it to a different instance. Also updates test/provisioner/e2e/README.md to add this option to the documentation and clarify the difference with libvirt_uri. Fixes: #1164 Signed-off-by: Derek Lee --- test/e2e/README.md | 3 ++- test/provisioner/provision_libvirt.go | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/test/e2e/README.md b/test/e2e/README.md index 7f456e147..58e14997b 100644 --- a/test/e2e/README.md +++ b/test/e2e/README.md @@ -58,8 +58,9 @@ Use the properties on the table below for Libvirt: |---|---|---| |libvirt_network|Libvirt Network|"default"| |libvirt_storage|Libvirt storage pool|"default"| -|libvirt_url|Libvirt connection URI|"qemu+ssh://root@192.168.122.1/system?no_verify=1"| |libvirt_vol_name|Volume name|"podvm-base.qcow2"| +|libvirt_uri|Libvirt pod URI|"qemu+ssh://root@192.168.122.1/system?no_verify=1"| +|libvirt_conn_uri|Libvirt host URI|"qemu:///system"| |libvirt_ssh_key_file|Path to SSH private key|| |pause_image|k8s pause image|| |vxlan_port| VXLAN port number|| diff --git a/test/provisioner/provision_libvirt.go b/test/provisioner/provision_libvirt.go index 2985052c5..f01f7b8d9 100644 --- a/test/provisioner/provision_libvirt.go +++ b/test/provisioner/provision_libvirt.go @@ -73,8 +73,11 @@ func NewLibvirtProvisioner(properties map[string]string) (CloudProvisioner, erro vol_name = properties["libvirt_vol_name"] } - // TODO: accept a different URI. - conn, err := libvirt.NewConnect("qemu:///system") + conn_uri := "qemu:///system" + if properties["libvirt_conn_uri"] != "" { + conn_uri = properties["libvirt_conn_uri"] + } + conn, err := libvirt.NewConnect(conn_uri) if err != nil { return nil, err }