Blame SOURCES/BZ_1859844-fix_converting_memory_only.patch

dad7e0
From fc7e6b2329409b95ab1726b7b65f14c284bf67ab Mon Sep 17 00:00:00 2001
dad7e0
From: Gris Ge <fge@redhat.com>
dad7e0
Date: Mon, 3 Aug 2020 12:07:56 +0800
dad7e0
Subject: [PATCH] nm: Fix converting memory-only profile to persistent
dad7e0
dad7e0
When converting memory-only profile to persistent using simple desire
dad7e0
state with `state: up` only, the memory only profile will not be
dad7e0
converted to persistent.
dad7e0
dad7e0
This is caused by `nm/applier.py` skip profile creation if desire state
dad7e0
is only `state: up`.
dad7e0
dad7e0
The fix is checking whether current profile's persistent state is equal
dad7e0
to desired.
dad7e0
dad7e0
Integration test case added.
dad7e0
dad7e0
Signed-off-by: Gris Ge <fge@redhat.com>
dad7e0
---
dad7e0
 libnmstate/nm/applier.py    |  1 +
dad7e0
 libnmstate/nm/connection.py | 10 ++++++++++
dad7e0
 2 files changed, 11 insertions(+)
dad7e0
dad7e0
diff --git a/libnmstate/nm/applier.py b/libnmstate/nm/applier.py
dad7e0
index 4d40862..26a057f 100644
dad7e0
--- a/libnmstate/nm/applier.py
dad7e0
+++ b/libnmstate/nm/applier.py
dad7e0
@@ -125,6 +125,7 @@ def apply_changes(context, net_state, save_to_disk):
dad7e0
                 and cur_con_profile
dad7e0
                 and cur_con_profile.profile
dad7e0
                 and not net_state.ifaces[ifname].is_changed
dad7e0
+                and cur_con_profile.is_memory_only != save_to_disk
dad7e0
             ):
dad7e0
                 # Don't create new profile if original desire does not ask
dad7e0
                 # anything besides state:up and not been marked as changed.
dad7e0
diff --git a/libnmstate/nm/connection.py b/libnmstate/nm/connection.py
dad7e0
index 5804f13..1f6c734 100644
dad7e0
--- a/libnmstate/nm/connection.py
dad7e0
+++ b/libnmstate/nm/connection.py
dad7e0
@@ -162,6 +162,16 @@ class ConnectionProfile:
dad7e0
         assert self._con_profile is None
dad7e0
         self._con_profile = con_profile
dad7e0
 
dad7e0
+    @property
dad7e0
+    def is_memory_only(self):
dad7e0
+        if self._con_profile:
dad7e0
+            profile_flags = self._con_profile.get_flags()
dad7e0
+            return (
dad7e0
+                NM.SettingsConnectionFlags.UNSAVED & profile_flags
dad7e0
+                or NM.SettingsConnectionFlags.VOLATILE & profile_flags
dad7e0
+            )
dad7e0
+        return False
dad7e0
+
dad7e0
     @property
dad7e0
     def devname(self):
dad7e0
         if self._con_profile:
dad7e0
-- 
dad7e0
2.28.0
dad7e0