mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
details: Give a pretty description of network source
Currently we just printed net type and source device, when we could use the pretty print we already have in uihelpers. Break out the functionality and use it on the net screen.
This commit is contained in:
@@ -137,6 +137,7 @@ class vmmDetails(gobject.GObject):
|
||||
"vmm-details", domain="virt-manager")
|
||||
self.config = config
|
||||
self.vm = vm
|
||||
self.conn = self.vm.get_connection()
|
||||
self.engine = engine
|
||||
|
||||
self.topwin = self.window.get_widget("vmm-details")
|
||||
@@ -1507,12 +1508,26 @@ class vmmDetails(gobject.GObject):
|
||||
if not netinfo:
|
||||
return
|
||||
|
||||
self.window.get_widget("network-source-type").set_text(netinfo[5])
|
||||
self.window.get_widget("network-mac-address").set_text(netinfo[2])
|
||||
self.window.get_widget("network-source-device").set_text(netinfo[3] or
|
||||
"-")
|
||||
nettype = netinfo[5]
|
||||
source = netinfo[3]
|
||||
|
||||
model = netinfo[6] or _("Hypervisor Default")
|
||||
netobj = None
|
||||
if nettype == virtinst.VirtualNetworkInterface.TYPE_VIRTUAL:
|
||||
name_dict = {}
|
||||
for uuid in self.conn.list_net_uuids():
|
||||
net = self.conn.get_net(uuid)
|
||||
name = net.get_name()
|
||||
name_dict[name] = net
|
||||
|
||||
if source and name_dict.has_key(source):
|
||||
netobj = name_dict[source]
|
||||
|
||||
desc = uihelpers.pretty_network_desc(nettype, source, netobj)
|
||||
|
||||
self.window.get_widget("network-mac-address").set_text(netinfo[2])
|
||||
self.window.get_widget("network-source-device").set_text(desc)
|
||||
|
||||
model = netinfo[6] or _("Hypervisor default")
|
||||
self.window.get_widget("network-source-model").set_text(model)
|
||||
|
||||
def refresh_input_page(self):
|
||||
|
||||
@@ -59,6 +59,27 @@ def set_error_parent(parent):
|
||||
# Widgets for listing network device options (in create, addhardware) #
|
||||
#######################################################################
|
||||
|
||||
def pretty_network_desc(nettype, source=None, netobj=None):
|
||||
if nettype == VirtualNetworkInterface.TYPE_USER:
|
||||
return _("Usermode networking")
|
||||
|
||||
extra = None
|
||||
if nettype == VirtualNetworkInterface.TYPE_BRIDGE:
|
||||
ret = _("Bridge")
|
||||
elif nettype == VirtualNetworkInterface.TYPE_VIRTUAL:
|
||||
ret = _("Virtual network")
|
||||
if netobj:
|
||||
extra = ": %s" % netobj.pretty_forward_mode()
|
||||
else:
|
||||
ret = nettype.capitalize()
|
||||
|
||||
if source:
|
||||
ret += " '%s'" % source
|
||||
if extra:
|
||||
ret += " %s" % extra
|
||||
|
||||
return ret
|
||||
|
||||
def init_network_list(net_list):
|
||||
# [ network type, source name, label, sensitive? ]
|
||||
net_model = gtk.ListStore(str, str, str, bool)
|
||||
@@ -97,8 +118,8 @@ def populate_network_list(net_list, conn):
|
||||
|
||||
# For qemu:///session
|
||||
if conn.is_qemu_session():
|
||||
model.append([VirtualNetworkInterface.TYPE_USER, None,
|
||||
_("Usermode Networking"), True])
|
||||
nettype = VirtualNetworkInterface.TYPE_USER
|
||||
model.append([nettype, None, pretty_network_desc(nettype), True])
|
||||
set_active(0)
|
||||
return
|
||||
|
||||
@@ -107,22 +128,19 @@ def populate_network_list(net_list, conn):
|
||||
# Virtual Networks
|
||||
for uuid in conn.list_net_uuids():
|
||||
net = conn.get_net(uuid)
|
||||
nettype = VirtualNetworkInterface.TYPE_VIRTUAL
|
||||
|
||||
label = _("Virtual network") + " '%s'" % net.get_name()
|
||||
label = pretty_network_desc(nettype, net.get_name(), net)
|
||||
if not net.is_active():
|
||||
label += " (%s)" % _("Inactive")
|
||||
|
||||
desc = net.pretty_forward_mode()
|
||||
label += ": %s" % desc
|
||||
|
||||
hasNet = True
|
||||
# FIXME: Should we use 'default' even if it's inactive?
|
||||
# FIXME: This preference should be configurable
|
||||
if net.get_name() == "default":
|
||||
netIdxLabel = label
|
||||
|
||||
vnet_dict[label] = [VirtualNetworkInterface.TYPE_VIRTUAL,
|
||||
net.get_name(), label, True]
|
||||
vnet_dict[label] = [nettype, net.get_name(), label, True]
|
||||
|
||||
# Build a list of vnet bridges, so we know not to list them
|
||||
# in the physical interface list
|
||||
@@ -140,16 +158,17 @@ def populate_network_list(net_list, conn):
|
||||
for name in conn.list_net_device_paths():
|
||||
br = conn.get_net_device(name)
|
||||
bridge_name = br.get_bridge()
|
||||
nettype = VirtualNetworkInterface.TYPE_BRIDGE
|
||||
|
||||
if (bridge_name in vnet_bridges) or (br.get_name() in vnet_bridges):
|
||||
# Don't list this, as it is basically duplicating virtual net info
|
||||
continue
|
||||
|
||||
if br.is_shared():
|
||||
hasShared = True
|
||||
sensitive = True
|
||||
hasShared = True
|
||||
if br.get_bridge():
|
||||
brlabel = "(%s %s)" % (_("Bridge"), bridge_name)
|
||||
brlabel = "(%s)" % pretty_network_desc(nettype, bridge_name)
|
||||
else:
|
||||
bridge_name = name
|
||||
brlabel = _("(Empty bridge)")
|
||||
@@ -161,8 +180,7 @@ def populate_network_list(net_list, conn):
|
||||
if hasShared and not brIdxLabel:
|
||||
brIdxLabel = label
|
||||
|
||||
row = [VirtualNetworkInterface.TYPE_BRIDGE,
|
||||
bridge_name, label, sensitive]
|
||||
row = [nettype, bridge_name, label, sensitive]
|
||||
|
||||
if sensitive:
|
||||
bridge_dict[label] = row
|
||||
|
||||
@@ -2643,22 +2643,10 @@ I/O:</property>
|
||||
<widget class="GtkTable" id="table31">
|
||||
<property name="visible">True</property>
|
||||
<property name="border_width">3</property>
|
||||
<property name="n_rows">4</property>
|
||||
<property name="n_rows">3</property>
|
||||
<property name="n_columns">2</property>
|
||||
<property name="column_spacing">8</property>
|
||||
<property name="row_spacing">4</property>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label369">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">1</property>
|
||||
<property name="label" translatable="yes">Source type:</property>
|
||||
<property name="use_underline">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label397">
|
||||
<property name="visible">True</property>
|
||||
@@ -2666,22 +2654,6 @@ I/O:</property>
|
||||
<property name="label" translatable="yes">Source device:</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="bottom_attach">2</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="network-source-type">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label">label395</property>
|
||||
<property name="selectable">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
@@ -2696,8 +2668,6 @@ I/O:</property>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="bottom_attach">2</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
@@ -2710,8 +2680,8 @@ I/O:</property>
|
||||
<property name="use_underline">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="top_attach">3</property>
|
||||
<property name="bottom_attach">4</property>
|
||||
<property name="top_attach">2</property>
|
||||
<property name="bottom_attach">3</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
@@ -2720,11 +2690,11 @@ I/O:</property>
|
||||
<widget class="GtkLabel" id="label509">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">1</property>
|
||||
<property name="label" translatable="yes">Source model:</property>
|
||||
<property name="label" translatable="yes">Device model:</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="top_attach">2</property>
|
||||
<property name="bottom_attach">3</property>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="bottom_attach">2</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
@@ -2738,8 +2708,8 @@ I/O:</property>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">2</property>
|
||||
<property name="bottom_attach">3</property>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="bottom_attach">2</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
@@ -2753,8 +2723,8 @@ I/O:</property>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">3</property>
|
||||
<property name="bottom_attach">4</property>
|
||||
<property name="top_attach">2</property>
|
||||
<property name="bottom_attach">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
@@ -2779,52 +2749,6 @@ I/O:</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox49">
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<widget class="GtkAlignment" id="alignment138">
|
||||
<property name="visible">True</property>
|
||||
<property name="left_padding">13</property>
|
||||
<child>
|
||||
<widget class="GtkImage" id="image74">
|
||||
<property name="visible">True</property>
|
||||
<property name="yalign">0</property>
|
||||
<property name="stock">gtk-info</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkAlignment" id="alignment139">
|
||||
<property name="visible">True</property>
|
||||
<property name="left_padding">3</property>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label400">
|
||||
<property name="visible">True</property>
|
||||
<property name="yalign">0</property>
|
||||
<property name="label" translatable="yes"><b>Tip:</b> 'Source device' refers to the name of the device as seen from the host OS.</property>
|
||||
<property name="use_markup">True</property>
|
||||
<property name="wrap">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">6</property>
|
||||
|
||||
Reference in New Issue
Block a user