mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-10 23:45:49 -06:00
VirtualConnection: Allow setting a display name for fake URIs
This commit is contained in:
parent
f37d4d010a
commit
14103f175d
@ -382,6 +382,9 @@ class vmmConnection(vmmGObject):
|
||||
else:
|
||||
hv += " %s" % os.path.basename(path)
|
||||
|
||||
if self._backend.fake_name():
|
||||
hv = self._backend.fake_name()
|
||||
|
||||
return "%s (%s)" % (rest, hv)
|
||||
|
||||
def get_pretty_desc_inactive(self, shorthost=True, transport=False):
|
||||
|
@ -86,12 +86,19 @@ class VirtualConnection(object):
|
||||
def __init__(self, uri):
|
||||
_initial_uri = uri or ""
|
||||
|
||||
# virtinst unit test URI handling
|
||||
self._fake_pretty_name = None
|
||||
self._fake_libvirt_version = None
|
||||
self._fake_conn_version = None
|
||||
self._daemon_version = None
|
||||
self._conn_version = None
|
||||
|
||||
if _initial_uri.startswith(_virtinst_uri_magic):
|
||||
# virtinst unit test URI handling
|
||||
uri = _initial_uri.replace(_virtinst_uri_magic, "")
|
||||
ret = uri.split(",", 1)
|
||||
self._open_uri = ret[0]
|
||||
self._test_opts = parse_optstr(len(ret) > 1 and ret[1] or "")
|
||||
self._early_virtinst_test_uri()
|
||||
self._uri = self._virtinst_uri_make_fake()
|
||||
else:
|
||||
self._open_uri = _initial_uri
|
||||
@ -102,11 +109,6 @@ class VirtualConnection(object):
|
||||
self._urisplits = util.uri_split(self._uri)
|
||||
self._caps = None
|
||||
|
||||
self._fake_libvirt_version = None
|
||||
self._fake_conn_version = None
|
||||
self._daemon_version = None
|
||||
self._conn_version = None
|
||||
|
||||
self._support_cache = {}
|
||||
self._fetch_cache = {}
|
||||
|
||||
@ -262,6 +264,9 @@ class VirtualConnection(object):
|
||||
# Public URI bits #
|
||||
###################
|
||||
|
||||
def fake_name(self):
|
||||
return self._fake_pretty_name
|
||||
|
||||
def is_remote(self):
|
||||
if (hasattr(self, "_virtinst__fake_conn_remote") or
|
||||
self._urisplits[2]):
|
||||
@ -361,16 +366,12 @@ class VirtualConnection(object):
|
||||
return "lxc+abc:///"
|
||||
return self._open_uri
|
||||
|
||||
def _fixup_virtinst_test_uri(self, conn):
|
||||
"""
|
||||
This hack allows us to fake various drivers via passing a magic
|
||||
URI string to virt-*. Helps with testing
|
||||
"""
|
||||
def _early_virtinst_test_uri(self):
|
||||
# Need tmpfile names to be deterministic
|
||||
if not self._test_opts:
|
||||
return
|
||||
opts = self._test_opts.copy()
|
||||
opts = self._test_opts
|
||||
|
||||
# Need tmpfile names to be deterministic
|
||||
if "predictable" in opts:
|
||||
opts.pop("predictable")
|
||||
import tempfile
|
||||
@ -382,6 +383,19 @@ class VirtualConnection(object):
|
||||
opts.pop("remote")
|
||||
setattr(self, "_virtinst__fake_conn_remote", True)
|
||||
|
||||
if "prettyname" in opts:
|
||||
self._fake_pretty_name = opts.pop("prettyname")
|
||||
|
||||
|
||||
def _fixup_virtinst_test_uri(self, conn):
|
||||
"""
|
||||
This hack allows us to fake various drivers via passing a magic
|
||||
URI string to virt-*. Helps with testing
|
||||
"""
|
||||
if not self._test_opts:
|
||||
return
|
||||
opts = self._test_opts.copy()
|
||||
|
||||
# Fake capabilities
|
||||
if "caps" in opts:
|
||||
capsxml = file(opts.pop("caps")).read()
|
||||
|
Loading…
Reference in New Issue
Block a user