[virt-tools-list] [virt-manager PATCH] details: do not show MAC address if not set

Giuseppe Scrivano gscrivan at redhat.com
Fri Nov 14 08:51:11 UTC 2014


Fixes this exception:
Traceback (most recent call last):
  File "virt-manager/virtManager/create.py", line 1780, in finish
    self.customize(guest)
  File "virt-manager/virtManager/create.py", line 1812, in customize
    self.config_window = vmmDetails(virtinst_guest, self.topwin)
  File "virt-manager/virtManager/details.py", line 560, in __init__
    self.populate_hw_list()
  File "virt-manager/virtManager/details.py", line 3165, in populate_hw_list
    self.repopulate_hw_list()
  File "virt-manager/virtManager/details.py", line 3220, in repopulate_hw_list
    update_hwlist(HW_LIST_TYPE_NIC, dev)
  File "virt-manager/virtManager/details.py", line 3195, in update_hwlist
    label = _label_for_device(dev)
  File "virt-manager/virtManager/details.py", line 188, in _label_for_device
    return "NIC %s" % dev.macaddr[-9:]
TypeError: 'NoneType' object has no attribute '__getitem__'

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1164123

Signed-off-by: Giuseppe Scrivano <gscrivan at redhat.com>
---
 virtManager/details.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/virtManager/details.py b/virtManager/details.py
index 1b60743..69e42d9 100644
--- a/virtManager/details.py
+++ b/virtManager/details.py
@@ -185,7 +185,10 @@ def _label_for_device(dev):
         return "%s %s" % (ret, dev.disk_bus_index)
 
     if devtype == "interface":
-        return "NIC %s" % dev.macaddr[-9:]
+        if dev.macaddr:
+            return "NIC %s" % dev.macaddr[-9:]
+        else:
+            return "NIC"
 
     if devtype == "input":
         if dev.type == "tablet":
@@ -2702,7 +2705,11 @@ class vmmDetails(vmmGObjectUI):
         vmmAddHardware.populate_network_model_combo(
             self.vm, self.widget("network-model"))
         uiutil.set_combo_entry(self.widget("network-model"), net.model)
-        self.widget("network-mac-address").set_text(net.macaddr)
+
+        uiutil.set_grid_row_visible(self.widget("network-mac-address"),
+                                    bool(net.macaddr))
+        if net.macaddr:
+            self.widget("network-mac-address").set_text(net.macaddr)
 
         self.netlist.set_dev(net)
 
-- 
1.9.3




More information about the virt-tools-list mailing list