mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
manager: If 2 URI names collide, make the names more verbose
This commit is contained in:
parent
d3472fd1f1
commit
16ab9b9edc
@ -418,7 +418,7 @@ class vmmConnection(vmmGObject):
|
|||||||
|
|
||||||
# Connection pretty print routines
|
# Connection pretty print routines
|
||||||
|
|
||||||
def _get_pretty_desc(self, active, shorthost):
|
def _get_pretty_desc(self, active, shorthost, show_trans):
|
||||||
def match_whole_string(orig, reg):
|
def match_whole_string(orig, reg):
|
||||||
match = re.match(reg, orig)
|
match = re.match(reg, orig)
|
||||||
if not match:
|
if not match:
|
||||||
@ -429,14 +429,19 @@ class vmmConnection(vmmGObject):
|
|||||||
def is_ip_addr(orig):
|
def is_ip_addr(orig):
|
||||||
return match_whole_string(orig, "[0-9.]+")
|
return match_whole_string(orig, "[0-9.]+")
|
||||||
|
|
||||||
(scheme, ignore, hostname,
|
(scheme, username, hostname,
|
||||||
path, ignore, ignore) = virtinst.util.uri_split(self.uri)
|
path, ignore, ignore) = virtinst.util.uri_split(self.uri)
|
||||||
|
|
||||||
hv = ""
|
hv = ""
|
||||||
rest = ""
|
rest = ""
|
||||||
scheme = scheme.split("+")[0]
|
transport = ""
|
||||||
|
port = ""
|
||||||
|
if scheme.count("+"):
|
||||||
|
transport = scheme.split("+")[1]
|
||||||
|
scheme = scheme.split("+")[0]
|
||||||
|
|
||||||
if hostname.count(":"):
|
if hostname.count(":"):
|
||||||
|
port = hostname.split(":")[1]
|
||||||
hostname = hostname.split(":")[0]
|
hostname = hostname.split(":")[0]
|
||||||
|
|
||||||
if hostname:
|
if hostname:
|
||||||
@ -456,6 +461,14 @@ class vmmConnection(vmmGObject):
|
|||||||
else:
|
else:
|
||||||
hv = scheme.capitalize()
|
hv = scheme.capitalize()
|
||||||
|
|
||||||
|
if show_trans:
|
||||||
|
if transport:
|
||||||
|
hv += "+" + transport
|
||||||
|
if username:
|
||||||
|
hostname = username + "@" + hostname
|
||||||
|
if port:
|
||||||
|
hostname += ":" + port
|
||||||
|
|
||||||
if path and path != "/system" and path != "/":
|
if path and path != "/system" and path != "/":
|
||||||
if path == "/session":
|
if path == "/session":
|
||||||
hv += " Usermode"
|
hv += " Usermode"
|
||||||
@ -464,11 +477,11 @@ class vmmConnection(vmmGObject):
|
|||||||
|
|
||||||
return "%s (%s)" % (rest, hv)
|
return "%s (%s)" % (rest, hv)
|
||||||
|
|
||||||
def get_pretty_desc_inactive(self, shorthost=True):
|
def get_pretty_desc_inactive(self, shorthost=True, transport=False):
|
||||||
return self._get_pretty_desc(False, shorthost)
|
return self._get_pretty_desc(False, shorthost, transport)
|
||||||
|
|
||||||
def get_pretty_desc_active(self, shorthost=True):
|
def get_pretty_desc_active(self, shorthost=True, transport=False):
|
||||||
return self._get_pretty_desc(True, shorthost)
|
return self._get_pretty_desc(True, shorthost, transport)
|
||||||
|
|
||||||
|
|
||||||
#######################
|
#######################
|
||||||
|
@ -825,6 +825,24 @@ class vmmManager(vmmGObjectUI):
|
|||||||
row = self._append_connection(vmlist.get_model(), conn)
|
row = self._append_connection(vmlist.get_model(), conn)
|
||||||
vmlist.get_selection().select_iter(row)
|
vmlist.get_selection().select_iter(row)
|
||||||
|
|
||||||
|
# Try to make sure that 2 row descriptions don't collide
|
||||||
|
connrows = []
|
||||||
|
descs = []
|
||||||
|
for row in self.rows.values():
|
||||||
|
if row[ROW_IS_CONN]:
|
||||||
|
connrows.append(row)
|
||||||
|
for row in connrows:
|
||||||
|
descs.append(row[ROW_NAME])
|
||||||
|
|
||||||
|
for row in connrows:
|
||||||
|
conn = row[ROW_HANDLE]
|
||||||
|
name = row[ROW_NAME]
|
||||||
|
if descs.count(name) <= 1:
|
||||||
|
continue
|
||||||
|
|
||||||
|
newname = conn.get_pretty_desc_inactive(False, True)
|
||||||
|
self.conn_refresh_resources(conn, newname)
|
||||||
|
|
||||||
def _remove_connection(self, engine_ignore, conn):
|
def _remove_connection(self, engine_ignore, conn):
|
||||||
model = self.window.get_widget("vm-list").get_model()
|
model = self.window.get_widget("vm-list").get_model()
|
||||||
parent = self.rows[conn.get_uri()].iter
|
parent = self.rows[conn.get_uri()].iter
|
||||||
@ -879,11 +897,13 @@ class vmmManager(vmmGObjectUI):
|
|||||||
self.conn_refresh_resources(conn)
|
self.conn_refresh_resources(conn)
|
||||||
self.vm_selected()
|
self.vm_selected()
|
||||||
|
|
||||||
def conn_refresh_resources(self, conn):
|
def conn_refresh_resources(self, conn, newname=None):
|
||||||
vmlist = self.window.get_widget("vm-list")
|
vmlist = self.window.get_widget("vm-list")
|
||||||
model = vmlist.get_model()
|
model = vmlist.get_model()
|
||||||
row = self.rows[conn.get_uri()]
|
row = self.rows[conn.get_uri()]
|
||||||
|
|
||||||
|
if newname:
|
||||||
|
row[ROW_NAME] = newname
|
||||||
row[ROW_MARKUP] = self._build_conn_markup(conn, row)
|
row[ROW_MARKUP] = self._build_conn_markup(conn, row)
|
||||||
row[ROW_STATUS] = ("<span size='smaller'>%s</span>" %
|
row[ROW_STATUS] = ("<span size='smaller'>%s</span>" %
|
||||||
conn.get_state_text())
|
conn.get_state_text())
|
||||||
|
Loading…
Reference in New Issue
Block a user