[master 19/20] libnm in spoke: allow adding missing connection for eth device externally

rvykydal installerbot-noreply at redhat.com
Mon Aug 31 14:56:02 UTC 2015


From: Radek Vykydal <rvykydal at redhat.com>

Eg with nmcli or nm-c-e.
Eg for device plugged in.
---
 pyanaconda/ui/gui/spokes/network.py | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/pyanaconda/ui/gui/spokes/network.py b/pyanaconda/ui/gui/spokes/network.py
index 3b238fb..605abc2 100644
--- a/pyanaconda/ui/gui/spokes/network.py
+++ b/pyanaconda/ui/gui/spokes/network.py
@@ -402,8 +402,21 @@ def add_connection_to_list(self, con):
         # Configs for ethernet has been already added,
         # this must be some slave
         if dev_cfg.get_device_type() == NM.DeviceType.ETHERNET:
-            log.debug("network: GUI, not adding slave connection %s", uuid)
-            return False
+            if con.get_setting_connection().get_master():
+                log.debug("network: GUI, not adding slave connection %s", uuid)
+                return False
+            else:
+                existing_dev_cfg = self.dev_cfg(iface=dev_cfg.get_iface())
+                if existing_dev_cfg:
+                    if existing_dev_cfg.con:
+                        log.debug("network: GUI, not adding connection %s, already have %s for device %s",
+                                  uuid, existing_dev_cfg.get_uuid(), existing_dev_cfg.device.get_iface())
+                        return False
+                    else:
+                        existing_dev_cfg.con = con
+                        log.debug("network: GUI, attaching connection %s to device %s",
+                                  uuid, existing_dev_cfg.device.get_iface())
+                        return True
         # Wireless settings are handled in scope of its device's dev_cfg
         if dev_cfg.get_device_type() == NM.DeviceType.WIFI:
             log.debug("network: GUI, not adding wireless connection %s", uuid)
@@ -704,8 +717,6 @@ def add_device_to_list(self, device):
             if len(cons) != 1:
                 log.warning("network: %s has unexpected number of connections: %s",
                              device.get_iface(), [c.get_uuid() for c in cons])
-            if not con:
-                return
 
         if con and self.dev_cfg(uuid=con.get_uuid()):
             # If we already have a connection for the device
@@ -756,7 +767,7 @@ def _dev_title(self, dev_cfg):
                      escape_markup(dev_cfg.device.get_product() or ""))
         return title
 
-    def dev_cfg(self, uuid=None, device=None):
+    def dev_cfg(self, uuid=None, device=None, iface=None):
         for row in self.dev_cfg_store:
             dev_cfg = row[DEVICES_COLUMN_OBJECT]
             if uuid:
@@ -766,6 +777,10 @@ def dev_cfg(self, uuid=None, device=None):
                 if not dev_cfg.device \
                    or dev_cfg.device.get_udi() != device.get_udi():
                     continue
+            if iface:
+                if not dev_cfg.device \
+                   or dev_cfg.device.get_iface() != iface:
+                    continue
             return dev_cfg
         return None
 


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


More information about the anaconda-patches mailing list