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
|
||||
|
||||
def _get_pretty_desc(self, active, shorthost):
|
||||
def _get_pretty_desc(self, active, shorthost, show_trans):
|
||||
def match_whole_string(orig, reg):
|
||||
match = re.match(reg, orig)
|
||||
if not match:
|
||||
@ -429,14 +429,19 @@ class vmmConnection(vmmGObject):
|
||||
def is_ip_addr(orig):
|
||||
return match_whole_string(orig, "[0-9.]+")
|
||||
|
||||
(scheme, ignore, hostname,
|
||||
(scheme, username, hostname,
|
||||
path, ignore, ignore) = virtinst.util.uri_split(self.uri)
|
||||
|
||||
hv = ""
|
||||
rest = ""
|
||||
scheme = scheme.split("+")[0]
|
||||
transport = ""
|
||||
port = ""
|
||||
if scheme.count("+"):
|
||||
transport = scheme.split("+")[1]
|
||||
scheme = scheme.split("+")[0]
|
||||
|
||||
if hostname.count(":"):
|
||||
port = hostname.split(":")[1]
|
||||
hostname = hostname.split(":")[0]
|
||||
|
||||
if hostname:
|
||||
@ -456,6 +461,14 @@ class vmmConnection(vmmGObject):
|
||||
else:
|
||||
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 == "/session":
|
||||
hv += " Usermode"
|
||||
@ -464,11 +477,11 @@ class vmmConnection(vmmGObject):
|
||||
|
||||
return "%s (%s)" % (rest, hv)
|
||||
|
||||
def get_pretty_desc_inactive(self, shorthost=True):
|
||||
return self._get_pretty_desc(False, shorthost)
|
||||
def get_pretty_desc_inactive(self, shorthost=True, transport=False):
|
||||
return self._get_pretty_desc(False, shorthost, transport)
|
||||
|
||||
def get_pretty_desc_active(self, shorthost=True):
|
||||
return self._get_pretty_desc(True, shorthost)
|
||||
def get_pretty_desc_active(self, shorthost=True, transport=False):
|
||||
return self._get_pretty_desc(True, shorthost, transport)
|
||||
|
||||
|
||||
#######################
|
||||
|
@ -825,6 +825,24 @@ class vmmManager(vmmGObjectUI):
|
||||
row = self._append_connection(vmlist.get_model(), conn)
|
||||
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):
|
||||
model = self.window.get_widget("vm-list").get_model()
|
||||
parent = self.rows[conn.get_uri()].iter
|
||||
@ -879,11 +897,13 @@ class vmmManager(vmmGObjectUI):
|
||||
self.conn_refresh_resources(conn)
|
||||
self.vm_selected()
|
||||
|
||||
def conn_refresh_resources(self, conn):
|
||||
def conn_refresh_resources(self, conn, newname=None):
|
||||
vmlist = self.window.get_widget("vm-list")
|
||||
model = vmlist.get_model()
|
||||
row = self.rows[conn.get_uri()]
|
||||
|
||||
if newname:
|
||||
row[ROW_NAME] = newname
|
||||
row[ROW_MARKUP] = self._build_conn_markup(conn, row)
|
||||
row[ROW_STATUS] = ("<span size='smaller'>%s</span>" %
|
||||
conn.get_state_text())
|
||||
|
Loading…
Reference in New Issue
Block a user