[master 1/1] Fix crash when devices and connections are changing (#1245960)

jkonecny12 installerbot-noreply at redhat.com
Tue Aug 4 12:04:44 UTC 2015


From: Jiri Konecny <jkonecny at redhat.com>

First when user add new device to started anaconda in Welcome screen then
the anaconda will crash in NetworkSpoke initialization. This happens
because it's not created configuration file for the new device.
Fixed by generating this configuration in NetworkSpoke initialization.

Second when user remove existing ethernet connection for device. This could
happen specially in Live compose. This is fixed now that we skipping
devices without connection and add that device after the connection
appears.

Resolves: rhbz#1245960
---
 pyanaconda/ui/gui/spokes/network.py | 30 ++++++++++++++++++++++++++----
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/pyanaconda/ui/gui/spokes/network.py b/pyanaconda/ui/gui/spokes/network.py
index 3e0d770..f42c818 100644
--- a/pyanaconda/ui/gui/spokes/network.py
+++ b/pyanaconda/ui/gui/spokes/network.py
@@ -254,6 +254,11 @@ def _setting_device_type(self, uuid):
         return dev_type
 
     def get_iface(self):
+        """Get interface name
+
+           :return: Interface name or ``None`` if can't find device name for given uuid
+           :rtype: string or NoneType
+        """
         if self.device:
             iface = self.device.get_iface()
         else:
@@ -438,27 +443,36 @@ def add_connection_to_list(self, uuid):
         if self.dev_cfg(uuid=uuid):
             log.debug("network: GUI, not adding connection %s, already in list", uuid)
             return False
+
         dev_cfg = DeviceConfiguration(con_uuid=uuid)
+
         if dev_cfg.setting_value("connection", "read-only"):
             log.debug("network: GUI, not adding read-only connection %s", uuid)
             return False
         if dev_cfg.device_type not in self.supported_device_types:
             log.debug("network: GUI, not adding connection %s of unsupported type", uuid)
             return False
-        # Configs for ethernet has been already added,
-        # this must be some slave
-        if dev_cfg.device_type == NetworkManager.DeviceType.ETHERNET:
+        # skip slaves - only slaves has master
+        if (dev_cfg.device_type == NetworkManager.DeviceType.ETHERNET
+           and dev_cfg.setting_value("connection", "master")):
             log.debug("network: GUI, not adding slave connection %s", uuid)
             return False
         # Wireless settings are handled in scope of its device's dev_cfg
         if dev_cfg.device_type == NetworkManager.DeviceType.WIFI:
             log.debug("network: GUI, not adding wireless connection %s", uuid)
             return False
+
         self.add_dev_cfg(dev_cfg)
         log.debug("network: GUI, adding connection %s", uuid)
         return True
 
     def initialize(self):
+        # There is signal for newly added devices from NetworkManager but this
+        # is registered after the initialize method.
+        # So if someone add new device in Welcome screen ifconf file won't
+        # be created which causing anaconda to crash.
+        log.debug("Dump missing interfaces in NetworkControlBox initialize method")
+        network.dumpMissingDefaultIfcfgs()
         for device in self.client.get_devices():
             self.add_device_to_list(device)
 
@@ -712,11 +726,19 @@ def add_device_to_list(self, device):
             log.error(e)
             return
         except nm.SettingsNotFoundError:
-            # wireless devices
+            # wireless devices or device without a connection
             dev_cfg = None
+
         if dev_cfg:
             dev_cfg.device = device
         else:
+            # it's wireless or device with missing connection
+            # skip device with missing connection now, will be add when connection appears
+            if device.get_device_type() != NetworkManager.DeviceType.WIFI:
+                log.debug("network: device %s missing connection", device.get_iface())
+                return
+
+            # wireless device
             dev_cfg = DeviceConfiguration(device=device)
             self.add_dev_cfg(dev_cfg)
 


-- 
To view this commit on github, visit https://github.com/rhinstaller/anaconda/commit/31a8cb6058bdb6c11dc6d26a5d781619bb456d22


More information about the anaconda-patches mailing list