[PATCH rhel7-branch 9/9] network gui: do not crash on devices without settings (eg wireless) (#1011928)
Radek Vykydal
rvykydal at redhat.com
Wed Sep 25 12:54:29 UTC 2013
Related: rhbz#1011928
Also do not read slaves from settings but use new 'Slaves' property to read
current slaves instead.
Port of commit 45db9189550d3a986664dde9c0a99dbecbbc7918
---
pyanaconda/network.py | 14 +++++---------
pyanaconda/nm.py | 23 +++++++++++++++++++++++
2 files changed, 28 insertions(+), 9 deletions(-)
diff --git a/pyanaconda/network.py b/pyanaconda/network.py
index c0a4d6d..e73ea68 100644
--- a/pyanaconda/network.py
+++ b/pyanaconda/network.py
@@ -35,6 +35,7 @@ import simpleconfig
import re
import IPy
from flags import flags
+import itertools
from simpleconfig import SimpleConfigFile
from blivet.devices import FcoeDiskDevice, iScsiDiskDevice
@@ -1040,21 +1041,16 @@ 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:
if nm.nm_device_type_is_ethernet(devname):
msg = _("Wired (%(interface_name)s) connected") \
diff --git a/pyanaconda/nm.py b/pyanaconda/nm.py
index b65eec9..d2c6a6f 100644
--- a/pyanaconda/nm.py
+++ b/pyanaconda/nm.py
@@ -415,6 +415,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 a list of NTP servers that were specified the reply of the
DHCP server or empty list if no NTP servers were returned.
--
1.7.11.7
More information about the anaconda-patches
mailing list