From 385925657ea8871054077164f76d62ae194342cb Mon Sep 17 00:00:00 2001
From: Edward Haas <edwardh@redhat.com>
Date: Fri, 6 Sep 2019 15:45:58 +0800
Subject: [PATCH] metadata: Detach slaves without deleting them
In scenarios where a slave is detached from a master interface (bond, bridge)
and the slave is not mentioned in the desired state, the metadata
processing designates that slave for removal (marking it with `state=down`).
This behavior works fine with physical interfaces where the profile
removal only clears the interface configuration, but the device is still
present. With virtual interfaces (e.g. bond, vlan) the profile removal
also removed the device itself.
Detaching the slave should not cause the slave deletion implicitly.
Therefore, this patch avoids setting the slave interface state to
`down`, allowing it to just get detached without deletion.
Signed-off-by: Edward Haas <edwardh@redhat.com>
Signed-off-by: Gris Ge <fge@redhat.com>
---
libnmstate/metadata.py | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/libnmstate/metadata.py b/libnmstate/metadata.py
index 8274e22..b624abd 100644
--- a/libnmstate/metadata.py
+++ b/libnmstate/metadata.py
@@ -155,10 +155,7 @@ def _generate_link_master_metadata(
slaves2remove = set(current_slaves) - set(desired_slaves)
for slave in slaves2remove:
if slave not in ifaces_desired_state:
- ifaces_desired_state[slave] = {
- 'name': slave,
- 'state': 'down',
- }
+ ifaces_desired_state[slave] = {'name': slave}
current_masters = (
(ifname, ifstate)
--
2.23.0