[PATCH 6/8] Don't fail on invalid network --device kickstart specification.

Radek Vykydal rvykydal at redhat.com
Tue Jan 29 12:10:46 UTC 2013


We can get also
org.freedesktop.DBus.Error.AccessDenied exception
---
 pyanaconda/isys/__init__.py | 12 ++++++------
 pyanaconda/network.py       |  4 +++-
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/pyanaconda/isys/__init__.py b/pyanaconda/isys/__init__.py
index 7f4bcb4..998b401 100755
--- a/pyanaconda/isys/__init__.py
+++ b/pyanaconda/isys/__init__.py
@@ -146,21 +146,21 @@ def getDeviceProperties(dev=None):
     else:
         return None
 
-# Get the MAC address for a network device.
 def getMacAddress(dev):
+    """Return MAC address of device. "" if not found"""
     if dev == '' or dev is None:
-        return False
+        return ""
 
     device_props_iface = getDeviceProperties(dev=dev)
     if device_props_iface is None:
-        return None
+        return ""
 
-    device_macaddr = None
+    device_macaddr = ""
     try:
         device_macaddr = device_props_iface.Get(NM_DEVICE_WIRED_IFACE, "HwAddress").upper()
     except dbus.exceptions.DBusException as e:
-        if e.get_dbus_name() != 'org.freedesktop.DBus.Error.InvalidArgs':
-            raise
+        log.debug("getMacAddress %s: %s" % (dev, e))
+        pass
     return device_macaddr
 
 # Determine if a network device is a wireless device.
diff --git a/pyanaconda/network.py b/pyanaconda/network.py
index 3c9ef43..0eba86a 100644
--- a/pyanaconda/network.py
+++ b/pyanaconda/network.py
@@ -995,6 +995,8 @@ def get_device_name(devspec):
             if isys.getMacAddress(d).lower() == devname.lower():
                 devname = d
                 break
+        else:
+            return ""
 
     return devname
 
@@ -1003,7 +1005,7 @@ def setOnboot(ksdata):
 
         devname = get_device_name(network_data.device)
         if not devname:
-            log.error("Kickstart: The provided network interface %s does not exist" % devname)
+            log.error("Kickstart: The provided network interface %s does not exist" % network_data.device)
             continue
 
         con = get_NM_connection(devname, spec_type="iface")
-- 
1.7.11.7



More information about the anaconda-patches mailing list