diff options
author | David Cantrell <dcantrell@redhat.com> | 2008-09-04 23:16:32 -1000 |
---|---|---|
committer | David Cantrell <dcantrell@redhat.com> | 2008-09-05 02:57:58 -1000 |
commit | 10d8b685205046d2fb75cc91621fff8da745a259 (patch) | |
tree | 52d6d10ed502a3438f77e96057d87f809034c67b /network.py | |
parent | 805f564ac79492bb7ad33e5830bd0592337866a4 (diff) | |
download | anaconda-10d8b685205046d2fb75cc91621fff8da745a259.tar.gz anaconda-10d8b685205046d2fb75cc91621fff8da745a259.tar.xz anaconda-10d8b685205046d2fb75cc91621fff8da745a259.zip |
Fail gracefully if we can't talk to NetworkManager over DBus.
Wrap it all in try/except so we fail gracefully for now. This
should make CD & DVD installs work.
Diffstat (limited to 'network.py')
-rw-r--r-- | network.py | 57 |
1 files changed, 31 insertions, 26 deletions
diff --git a/network.py b/network.py index a1f082a0b..7e43aad5d 100644 --- a/network.py +++ b/network.py @@ -68,7 +68,7 @@ def sanityCheckHostname(hostname): return _("Hostnames can only contain the characters 'a-z', 'A-Z', '0-9', '-', or '.'") return None - + # return if the device is of a type that requires a ptpaddr to be specified def isPtpDev(devname): if (devname.startswith("ctc") or devname.startswith("iucv")): @@ -82,29 +82,31 @@ def _anyUsing(method): else: methods = (method) - bus = dbus.SystemBus() - nm = bus.get_object(isys.NM_SERVICE, isys.NM_MANAGER_PATH) - nm_props_iface = dbus.Interface(nm, isys.DBUS_PROPS_IFACE) - - active_connections = nm_props_iface.Get(isys.NM_MANAGER_IFACE, "ActiveConnections") + try: + bus = dbus.SystemBus() + nm = bus.get_object(isys.NM_SERVICE, isys.NM_MANAGER_PATH) + nm_props_iface = dbus.Interface(nm, isys.DBUS_PROPS_IFACE) + active_connections = nm_props_iface.Get(isys.NM_MANAGER_IFACE, "ActiveConnections") - for path in active_connections: - active = bus.get_object(isys.NM_SERVICE, path) - active_props_iface = dbus.Interface(active, isys.DBUS_PROPS_IFACE) + for path in active_connections: + active = bus.get_object(isys.NM_SERVICE, path) + active_props_iface = dbus.Interface(active, isys.DBUS_PROPS_IFACE) - active_service_name = active_props_iface.Get(isys.NM_ACTIVE_CONNECTION_IFACE, "ServiceName") - active_path = active_props_iface.Get(isys.NM_ACTIVE_CONNECTION_IFACE, "Connection") + active_service_name = active_props_iface.Get(isys.NM_ACTIVE_CONNECTION_IFACE, "ServiceName") + active_path = active_props_iface.Get(isys.NM_ACTIVE_CONNECTION_IFACE, "Connection") - connection = bus.get_object(active_service_name, active_path) - connection_iface = dbus.Interface(connection, isys.NM_CONNECTION_IFACE) - settings = connection_iface.GetSettings() + connection = bus.get_object(active_service_name, active_path) + connection_iface = dbus.Interface(connection, isys.NM_CONNECTION_IFACE) + settings = connection_iface.GetSettings() - # XXX: add support for Ip6Config when it appears - ip4_setting = settings['ipv4'] - if not ip4_setting or not ip4_setting['method'] or ip4_setting['method'] in methods: - return True + # XXX: add support for Ip6Config when it appears + ip4_setting = settings['ipv4'] + if not ip4_setting or not ip4_setting['method'] or ip4_setting['method'] in methods: + return True - return False + return False + except: + return False # determine whether any active at boot devices are using dhcp or dhcpv6 def anyUsingDHCP(): @@ -134,14 +136,17 @@ def sanityCheckIPString(ip_string): raise IPError, errstr def hasActiveNetDev(): - bus = dbus.SystemBus() - nm = bus.get_object(isys.NM_SERVICE, isys.NM_MANAGER_PATH) - props = dbus.Interface(nm, isys.DBUS_PROPS_IFACE) - state = props.Get(isys.NM_SERVICE, "State") + try: + bus = dbus.SystemBus() + nm = bus.get_object(isys.NM_SERVICE, isys.NM_MANAGER_PATH) + props = dbus.Interface(nm, isys.DBUS_PROPS_IFACE) + state = props.Get(isys.NM_SERVICE, "State") - if int(state) == isys.NM_STATE_CONNECTED: - return True - else: + if int(state) == isys.NM_STATE_CONNECTED: + return True + else: + return False + except: return False class NetworkDevice(SimpleConfigFile): |