summaryrefslogtreecommitdiff
path: root/virtinst/uri.py
diff options
context:
space:
mode:
authorCole Robinson <crobinso@redhat.com>2020-02-02 18:16:48 -0500
committerCole Robinson <crobinso@redhat.com>2020-02-03 07:05:11 -0500
commit9a0d49a71869e5c3b1680b3d2e528658347609c8 (patch)
treece11de960c5ff924f8038ab4a07edaed416cdf98 /virtinst/uri.py
parent1b6e33e8b9ba6ff58ea51468d0ece12daa8fdf44 (diff)
downloadvirt-manager-9a0d49a71869e5c3b1680b3d2e528658347609c8.tar.gz
virtinst: uri: Rework MagicURI to work with passed in fakeuri
Rather than individual options for each possible hypervisor, and annotations like 'remote' or 'session', just have it take a fake URI to mock Signed-off-by: Cole Robinson <crobinso@redhat.com>
Diffstat (limited to 'virtinst/uri.py')
-rw-r--r--virtinst/uri.py36
1 files changed, 10 insertions, 26 deletions
diff --git a/virtinst/uri.py b/virtinst/uri.py
index cc1fb96b..37077177 100644
--- a/virtinst/uri.py
+++ b/virtinst/uri.py
@@ -105,8 +105,7 @@ class MagicURI(object):
* 'predictable': Generate predictable UUIDs, MAC addresses, and
temporary file names.
- * 'remote': Have the code consider this as a remote URI
- * 'session': Have the code consider this as a session URI
+ * 'fakeuri': The URI to advertise as the actual connection URI
* 'connver=%d': Override the connection (hv) version
* 'libver=%d': Override the libvirt version
* 'caps=%s': Points to a file with capabilities XML, that will
@@ -114,7 +113,6 @@ class MagicURI(object):
files in test/capabilities-xml/
* 'domcaps=%s': Points to a file with domain capabilities XML, that
will be returned in conn.getDomainCapabilities
- * qemu, xen, lxc or vz: Fake the specified hypervisor
See tests/utils.py for example URLs
"""
@@ -140,46 +138,32 @@ class MagicURI(object):
return ret
self.predictable = pop_bool("predictable")
- self.remote = pop_bool("remote")
- self.session = pop_bool("session")
+ self.fakeuri = opts.pop("fakeuri", None)
self.capsfile = opts.pop("caps", None)
self.domcapsfile = opts.pop("domcaps", None)
- self.hv = None
- if pop_bool("qemu"):
- self.hv = "qemu"
- if pop_bool("lxc"):
- self.hv = "lxc"
- if pop_bool("xen"):
- self.hv = "xen"
- if pop_bool("vz"):
- self.hv = "vz"
-
self.conn_version = opts.pop("connver", None)
if self.conn_version:
self.conn_version = int(self.conn_version)
- elif self.hv:
+ elif self.fakeuri:
self.conn_version = 10000000000
self.libvirt_version = opts.pop("libver", None)
if self.libvirt_version:
self.libvirt_version = int(self.libvirt_version)
- assert not opts
+ self._err = None
+ if opts:
+ self._err = "MagicURI has unhandled opts=%s" % opts
##############
# Public API #
##############
- def make_fake_uri(self):
- """
- If self.hv is set, we need to make a fake URI so that Connection
- URI handling bits have something to work with.
- """
- if self.hv:
- return self.hv + "+abc:///system"
- return self.open_uri
+ def validate(self):
+ if self._err:
+ raise RuntimeError(self._err)
def overwrite_conn_functions(self, conn):
"""
@@ -209,7 +193,7 @@ class MagicURI(object):
conn.getDomainCapabilities = fake_domcaps
- if self.hv:
+ if self.fakeuri:
origcreate = conn.createXML
origdefine = conn.defineXML
def newcreate(xml, flags):