connection: Bunch of minor tweaks handling TCP URIs
This commit is contained in:
parent
ee9aa0ef11
commit
fc171fc31d
|
@ -52,22 +52,22 @@ def do_we_have_session():
|
|||
return False
|
||||
|
||||
|
||||
def creds_dialog(creds):
|
||||
def creds_dialog(conn, creds):
|
||||
"""
|
||||
Thread safe wrapper for libvirt openAuth user/pass callback
|
||||
"""
|
||||
|
||||
retipc = []
|
||||
|
||||
def wrapper(fn, creds):
|
||||
def wrapper(fn, conn, creds):
|
||||
try:
|
||||
ret = fn(creds)
|
||||
ret = fn(conn, creds)
|
||||
except:
|
||||
logging.exception("Error from creds dialog")
|
||||
ret = -1
|
||||
retipc.append(ret)
|
||||
|
||||
GLib.idle_add(wrapper, creds_dialog_main, creds)
|
||||
GLib.idle_add(wrapper, _creds_dialog_main, conn, creds)
|
||||
|
||||
while not retipc:
|
||||
time.sleep(.1)
|
||||
|
@ -75,7 +75,7 @@ def creds_dialog(creds):
|
|||
return retipc[0]
|
||||
|
||||
|
||||
def creds_dialog_main(creds):
|
||||
def _creds_dialog_main(conn, creds):
|
||||
"""
|
||||
Libvirt openAuth callback for username/password credentials
|
||||
"""
|
||||
|
@ -118,11 +118,15 @@ def creds_dialog_main(creds):
|
|||
ent = Gtk.Entry()
|
||||
if cred[0] == libvirt.VIR_CRED_PASSPHRASE:
|
||||
ent.set_visibility(False)
|
||||
elif conn.get_uri_username():
|
||||
ent.set_text(conn.get_uri_username())
|
||||
ent.connect("activate", _on_ent_activate)
|
||||
entry.append(ent)
|
||||
|
||||
box.attach(label[row], 0, 1, row, row + 1, Gtk.AttachOptions.FILL, 0, 0, 0)
|
||||
box.attach(entry[row], 1, 2, row, row + 1, Gtk.AttachOptions.FILL, 0, 0, 0)
|
||||
box.attach(label[row], 0, 1, row, row + 1,
|
||||
Gtk.AttachOptions.FILL, 0, 0, 0)
|
||||
box.attach(entry[row], 1, 2, row, row + 1,
|
||||
Gtk.AttachOptions.FILL, 0, 0, 0)
|
||||
row = row + 1
|
||||
|
||||
vbox = dialog.get_child()
|
||||
|
|
|
@ -320,10 +320,13 @@ class vmmConnection(vmmGObject):
|
|||
except:
|
||||
return self.get_uri_hostname()
|
||||
|
||||
get_uri_username = property(lambda s:
|
||||
getattr(s, "_backend").get_uri_username)
|
||||
get_uri_hostname = property(lambda s:
|
||||
getattr(s, "_backend").get_uri_hostname)
|
||||
get_transport = property(lambda s:
|
||||
getattr(s, "_backend").get_uri_transport)
|
||||
getattr(s, "_backend").get_uri_hostname)
|
||||
get_uri_transport = property(lambda s:
|
||||
getattr(s, "_backend").get_uri_transport)
|
||||
get_uri_port = property(lambda s: getattr(s, "_backend").get_uri_port)
|
||||
get_driver = property(lambda s: getattr(s, "_backend").get_uri_driver)
|
||||
is_container = property(lambda s: getattr(s, "_backend").is_container)
|
||||
is_lxc = property(lambda s: getattr(s, "_backend").is_lxc)
|
||||
|
@ -887,7 +890,7 @@ class vmmConnection(vmmGObject):
|
|||
|
||||
def _do_creds_password(self, creds):
|
||||
try:
|
||||
return connectauth.creds_dialog(creds)
|
||||
return connectauth.creds_dialog(self, creds)
|
||||
except:
|
||||
logging.debug("Launching creds dialog failed", exc_info=True)
|
||||
return -1
|
||||
|
|
|
@ -688,7 +688,7 @@ class vmmConsolePages(vmmGObjectUI):
|
|||
if ginfo.is_bad_localhost():
|
||||
self._activate_unavailable_page(
|
||||
_("Guest is on a remote host with transport '%s'\n"
|
||||
"but is only configured to listen on locally.\n"
|
||||
"but is only configured to listen locally.\n"
|
||||
"Connect using 'ssh' transport or change the\n"
|
||||
"guest's listen address." % ginfo.transport))
|
||||
return
|
||||
|
|
|
@ -563,12 +563,12 @@ class vmmEngine(vmmGObject):
|
|||
|
||||
if conn.is_remote():
|
||||
logging.debug("connect_error: conn transport=%s",
|
||||
conn.get_transport())
|
||||
conn.get_uri_transport())
|
||||
if re.search(r"nc: .* -- 'U'", tb):
|
||||
hint += _("The remote host requires a version of netcat/nc\n"
|
||||
"which supports the -U option.")
|
||||
show_errmsg = False
|
||||
elif (conn.get_transport()[0] == "ssh" and
|
||||
elif (conn.get_uri_transport() == "ssh" and
|
||||
re.search(r"ssh-askpass", tb)):
|
||||
|
||||
if self.config.askpass_package:
|
||||
|
|
|
@ -38,10 +38,11 @@ class ConnectionInfo(object):
|
|||
self.gaddr = gdev.listen or "127.0.0.1"
|
||||
self.gtlsport = gdev.tlsPort or None
|
||||
|
||||
self.transport, self.connuser = conn.get_transport()
|
||||
self.transport = conn.get_uri_transport()
|
||||
self.connuser = conn.get_uri_username()
|
||||
|
||||
(self._connhost,
|
||||
self._connport) = conn.get_backend().get_uri_host_port()
|
||||
self._connhost = conn.get_uri_hostname()
|
||||
self._connport = conn.get_uri_port()
|
||||
if self._connhost == "localhost":
|
||||
self._connhost = "127.0.0.1"
|
||||
|
||||
|
|
|
@ -363,14 +363,12 @@ class VirtualConnection(object):
|
|||
|
||||
def get_uri_hostname(self):
|
||||
return self._urisplits.hostname or "localhost"
|
||||
|
||||
def get_uri_host_port(self):
|
||||
return self.get_uri_hostname(), self._urisplits.port
|
||||
|
||||
def get_uri_port(self):
|
||||
return self._urisplits.port
|
||||
def get_uri_username(self):
|
||||
return self._urisplits.username
|
||||
def get_uri_transport(self):
|
||||
if self._urisplits.transport:
|
||||
return [self._urisplits.transport, self._urisplits.username]
|
||||
return [None, None]
|
||||
return self._urisplits.transport
|
||||
|
||||
def get_uri_driver(self):
|
||||
return self._urisplits.scheme
|
||||
|
|
Loading…
Reference in New Issue