[PATCH] V2 network gui: do not crash on devices without settings (eg wireless) (#1010519)
Radek Vykydal
rvykydal at redhat.com
Mon Sep 23 15:28:20 UTC 2013
Also do not read slaves from settings but use new 'Slaves' property to read
current slaves instead.
---
pyanaconda/network.py | 15 ++++++---------
pyanaconda/nm.py | 23 +++++++++++++++++++++++
2 files changed, 29 insertions(+), 9 deletions(-)
diff --git a/pyanaconda/network.py b/pyanaconda/network.py
index dcb6ee0..03dbaec 100644
--- a/pyanaconda/network.py
+++ b/pyanaconda/network.py
@@ -34,6 +34,7 @@ import threading
import re
import dbus
import IPy
+import itertools
from simpleconfig import SimpleConfigFile
from blivet.devices import FcoeDiskDevice, iScsiDiskDevice
@@ -1046,22 +1047,18 @@ def status_message():
slaves = {}
ssids = {}
- nonslaves = []
# first find slaves and wireless aps
for devname in active_devs:
- master = nm.nm_device_setting_value(devname, "connection", "master")
- if master:
- if master in slaves:
- slaves[master].append(devname)
- else:
- slaves[master] = [devname]
- else:
- nonslaves.append(devname)
+ slaves[devname] = nm.nm_device_slaves(devname) or []
if nm.nm_device_type_is_wifi(devname):
ssids[devname] = nm.nm_device_active_ssid(devname) or ""
+ all_slaves = set(itertools.chain.from_iterable(slaves.values()))
+ nonslaves = [dev for dev in active_devs if dev not in all_slaves]
+
if len(nonslaves) == 1:
+ devname = nonslaves[0]
if nm.nm_device_type_is_ethernet(devname):
msg = _("Wired (%(interface_name)s) connected") \
% {"interface_name": devname}
diff --git a/pyanaconda/nm.py b/pyanaconda/nm.py
index 3c587dc..17b765d 100644
--- a/pyanaconda/nm.py
+++ b/pyanaconda/nm.py
@@ -440,6 +440,29 @@ def nm_device_ip_config(name, version=4):
return [addr_list, ns_list]
+def nm_device_slaves(name):
+ """Return slaves of device.
+
+ :param name: name of device
+ :type name: str
+ :return: names of slaves of device or None if device has no 'Slaves' property
+ :rtype: list of strings or None
+ :raise UnknownDeviceError if device is not found
+ """
+
+ try:
+ slaves = nm_device_property(name, "Slaves")
+ except PropertyNotFoundError:
+ return None
+
+ slave_ifaces = []
+ for slave in slaves:
+ iface = _get_property(slave, "Interface", ".Device")
+ slave_ifaces.append(iface)
+
+ return slave_ifaces
+
+
def nm_ntp_servers_from_dhcp():
"""Return NTP servers obtained by DHCP.
--
1.7.11.7
More information about the anaconda-patches
mailing list