[PATCH] Check for hwaddress exceptions. (#999514)

David Shea dshea at redhat.com
Thu Aug 22 15:51:05 UTC 2013


When fetching an address, raise a PropertyNotFoundError if the device
type is not one for which we know the dbus interface name. Check for
exceptions when attempting to read the hardware address.
---
 pyanaconda/bootloader.py                    | 5 ++++-
 pyanaconda/nm.py                            | 9 +++++++--
 pyanaconda/ui/gui/spokes/advstorage/fcoe.py | 5 ++++-
 3 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/pyanaconda/bootloader.py b/pyanaconda/bootloader.py
index d25a6cb..440f3e6 100644
--- a/pyanaconda/bootloader.py
+++ b/pyanaconda/bootloader.py
@@ -840,7 +840,10 @@ class BootLoader(object):
         # Dracut needs the explicit ifname= because biosdevname
         # fails to rename the iface (because of BFS booting from it).
         for nic, dcb, auto_vlan in fcoe().nics:
-            hwaddr = nm_device_hwaddress(nic)
+            try:
+                hwaddr = nm_device_hwaddress(nic)
+            except ValueError:
+                continue
             self.boot_args.add("ifname=%s:%s" % (nic, hwaddr.lower()))
 
         #
diff --git a/pyanaconda/nm.py b/pyanaconda/nm.py
index 56c59d4..18a29e7 100644
--- a/pyanaconda/nm.py
+++ b/pyanaconda/nm.py
@@ -167,6 +167,8 @@ def nm_device_property(name, property):
     else:
         # Look in device type based interface
         device_type = proxy.get_cached_property("DeviceType").unpack()
+        if not device_type in device_type_interfaces:
+            raise PropertyNotFoundError(property)
         proxy = _get_proxy(object_path=device, interface_name=device_type_interfaces[device_type])
         if property in proxy.get_cached_property_names():
             retval = proxy.get_cached_property(property).unpack()
@@ -301,8 +303,11 @@ def _device_settings(name):
     elif devtype == NetworkManager.DeviceType.VLAN:
         settings = _find_settings(name, 'vlan', 'interface-name')
     else:
-        hwaddr_str = nm_device_hwaddress(name)
-        settings = _settings_for_hwaddr(hwaddr_str)
+        try:
+            hwaddr_str = nm_device_hwaddress(name)
+            settings = _settings_for_hwaddr(hwaddr_str)
+        except ValueError:
+            settings = None
 
     return settings
 
diff --git a/pyanaconda/ui/gui/spokes/advstorage/fcoe.py b/pyanaconda/ui/gui/spokes/advstorage/fcoe.py
index bbc9cea..0a232d3 100644
--- a/pyanaconda/ui/gui/spokes/advstorage/fcoe.py
+++ b/pyanaconda/ui/gui/spokes/advstorage/fcoe.py
@@ -60,7 +60,10 @@ class FCoEDialog(GUIObject):
             if not nm.nm_device_type_is_ethernet(devname):
                 continue
 
-            self._nicCombo.append_text("%s - %s" % (devname, nm.nm_device_hwaddress(devname)))
+            try:
+                self._nicCombo.append_text("%s - %s" % (devname, nm.nm_device_hwaddress(devname)))
+            except ValueError:
+                continue
 
         self._nicCombo.set_active(0)
 
-- 
1.8.3.1



More information about the anaconda-patches mailing list