|
|
69a85a |
From f4d190653c55d399b32afc956b2b4a1ff8d20101 Mon Sep 17 00:00:00 2001
|
|
|
69a85a |
From: Fernando Fernandez Mancera <ffmancera@riseup.net>
|
|
|
69a85a |
Date: Mon, 26 Jul 2021 09:58:23 +0200
|
|
|
69a85a |
Subject: [PATCH 3/4] ovs: fix state=ignore for ovs port when removing them
|
|
|
69a85a |
|
|
|
69a85a |
When removing an ovs port while the interface is marked as ignored, the
|
|
|
69a85a |
interface should not being removed from the ovs bridge as the user
|
|
|
69a85a |
specidied it should be ignored.
|
|
|
69a85a |
|
|
|
69a85a |
Example:
|
|
|
69a85a |
|
|
|
69a85a |
```
|
|
|
69a85a |
interfaces:
|
|
|
69a85a |
- name: dummy0
|
|
|
69a85a |
type: dummy
|
|
|
69a85a |
state: ignore
|
|
|
69a85a |
- name: ovsbr0
|
|
|
69a85a |
type: ovs-bridge
|
|
|
69a85a |
state: up
|
|
|
69a85a |
bridge:
|
|
|
69a85a |
port:
|
|
|
69a85a |
- name: ovs0
|
|
|
69a85a |
```
|
|
|
69a85a |
|
|
|
69a85a |
Integration test case added.
|
|
|
69a85a |
|
|
|
69a85a |
Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
|
|
|
69a85a |
Signed-off-by: Gris Ge <fge@redhat.com>
|
|
|
69a85a |
---
|
|
|
69a85a |
libnmstate/nm/profiles.py | 22 ++++++++++++++++++++--
|
|
|
69a85a |
1 file changed, 20 insertions(+), 2 deletions(-)
|
|
|
69a85a |
|
|
|
69a85a |
diff --git a/libnmstate/nm/profiles.py b/libnmstate/nm/profiles.py
|
|
|
69a85a |
index beda5c7..3b0b6be 100644
|
|
|
69a85a |
--- a/libnmstate/nm/profiles.py
|
|
|
69a85a |
+++ b/libnmstate/nm/profiles.py
|
|
|
69a85a |
@@ -23,6 +23,8 @@
|
|
|
69a85a |
import logging
|
|
|
69a85a |
from operator import attrgetter
|
|
|
69a85a |
|
|
|
69a85a |
+from libnmstate.schema import Interface
|
|
|
69a85a |
+from libnmstate.schema import InterfaceState
|
|
|
69a85a |
from libnmstate.schema import InterfaceType
|
|
|
69a85a |
|
|
|
69a85a |
from .common import NM
|
|
|
69a85a |
@@ -359,7 +361,7 @@ def _delete_orphan_nm_ovs_port_profiles(
|
|
|
69a85a |
continue
|
|
|
69a85a |
# When OVS port has no child, delete it
|
|
|
69a85a |
ovs_bridge_iface = ovs_bridge_profile.iface
|
|
|
69a85a |
- if not _nm_ovs_port_has_child(
|
|
|
69a85a |
+ if not _nm_ovs_port_has_child_or_is_ignored(
|
|
|
69a85a |
nm_profile, ovs_bridge_iface, net_state
|
|
|
69a85a |
):
|
|
|
69a85a |
ProfileDelete(
|
|
|
69a85a |
@@ -404,7 +406,9 @@ def _use_uuid_as_controller_and_parent(nm_profiles):
|
|
|
69a85a |
nm_profile.update_parent(uuid)
|
|
|
69a85a |
|
|
|
69a85a |
|
|
|
69a85a |
-def _nm_ovs_port_has_child(nm_profile, ovs_bridge_iface, net_state):
|
|
|
69a85a |
+def _nm_ovs_port_has_child_or_is_ignored(
|
|
|
69a85a |
+ nm_profile, ovs_bridge_iface, net_state
|
|
|
69a85a |
+):
|
|
|
69a85a |
ovs_port_uuid = nm_profile.get_uuid()
|
|
|
69a85a |
ovs_port_name = nm_profile.get_interface_name()
|
|
|
69a85a |
for ovs_iface_name in ovs_bridge_iface.port:
|
|
|
69a85a |
@@ -415,4 +419,18 @@ def _nm_ovs_port_has_child(nm_profile, ovs_bridge_iface, net_state):
|
|
|
69a85a |
and ovs_iface.controller_type == InterfaceType.OVS_PORT
|
|
|
69a85a |
):
|
|
|
69a85a |
return True
|
|
|
69a85a |
+ # Gather the ovs bridge interface from the current state in order to check
|
|
|
69a85a |
+ # if any port is ignored in the original desired state.
|
|
|
69a85a |
+ current_ovs_bridge = net_state.ifaces.get_cur_iface(
|
|
|
69a85a |
+ ovs_bridge_iface.name, InterfaceType.OVS_BRIDGE
|
|
|
69a85a |
+ )
|
|
|
69a85a |
+ if current_ovs_bridge:
|
|
|
69a85a |
+ for port_name in current_ovs_bridge.port:
|
|
|
69a85a |
+ port_iface = net_state.ifaces.all_kernel_ifaces.get(port_name)
|
|
|
69a85a |
+ if (
|
|
|
69a85a |
+ port_iface
|
|
|
69a85a |
+ and port_iface.original_desire_dict.get(Interface.STATE)
|
|
|
69a85a |
+ == InterfaceState.IGNORE
|
|
|
69a85a |
+ ):
|
|
|
69a85a |
+ return True
|
|
|
69a85a |
return False
|
|
|
69a85a |
--
|
|
|
69a85a |
2.32.0
|
|
|
69a85a |
|