Blame SOURCES/rhel-system-roles-network-pr121.diff

8b3abe
diff --git a/library/network_connections.py b/library/network_connections.py
8b3abe
index 39e81e8..6fa5e2f 100644
8b3abe
--- a/library/network_connections.py
8b3abe
+++ b/library/network_connections.py
8b3abe
@@ -1369,6 +1369,13 @@ class NMUtil:
8b3abe
             finally:
8b3abe
                 ac.handler_disconnect(ac_id)
8b3abe
 
8b3abe
+    def reapply(self, device, connection=None):
8b3abe
+        version_id = 0
8b3abe
+        flags = 0
8b3abe
+        return Util.call_async_method(
8b3abe
+            device, "reapply", [connection, version_id, flags]
8b3abe
+        )
8b3abe
+
8b3abe
 
8b3abe
 ###############################################################################
8b3abe
 
8b3abe
@@ -2088,6 +2095,9 @@ class Cmd_nm(Cmd):
8b3abe
         )
8b3abe
         self.connections_data_set_changed(idx)
8b3abe
         if self.check_mode == CheckMode.REAL_RUN:
8b3abe
+            if self._try_reapply(idx, con):
8b3abe
+                return
8b3abe
+
8b3abe
             try:
8b3abe
                 ac = self.nmutil.connection_activate(con)
8b3abe
             except MyError as e:
8b3abe
@@ -2102,6 +2112,33 @@ class Cmd_nm(Cmd):
8b3abe
             except MyError as e:
8b3abe
                 self.log_error(idx, "up connection failed while waiting: %s" % (e))
8b3abe
 
8b3abe
+    def _try_reapply(self, idx, con):
8b3abe
+        """ Try to reapply a connection
8b3abe
+
8b3abe
+        If there is exactly one active connection with the same UUID activated
8b3abe
+        on exactly one device, ask the device to reapply the connection.
8b3abe
+
8b3abe
+        :returns: `True`, when the connection was reapplied, `False` otherwise
8b3abe
+        :rtype: bool
8b3abe
+        """
8b3abe
+        NM = Util.NM()
8b3abe
+
8b3abe
+        acons = list(self.nmutil.active_connection_list(connections=[con]))
8b3abe
+        if len(acons) != 1:
8b3abe
+            return False
8b3abe
+
8b3abe
+        active_connection = acons[0]
8b3abe
+        if active_connection.get_state() == NM.ActiveConnectionState.ACTIVATED:
8b3abe
+            devices = active_connection.get_devices()
8b3abe
+            if len(devices) == 1:
8b3abe
+                try:
8b3abe
+                    self.nmutil.reapply(devices[0])
8b3abe
+                    self.log_info(idx, "connection reapplied")
8b3abe
+                    return True
8b3abe
+                except MyError as error:
8b3abe
+                    self.log_info(idx, "connection reapply failed: %s" % (error))
8b3abe
+        return False
8b3abe
+
8b3abe
     def run_action_down(self, idx):
8b3abe
         connection = self.connections[idx]
8b3abe