|
|
ca44bc |
From 36ee761dd0d671439323077e4f77a89071fdcd9c Mon Sep 17 00:00:00 2001
|
|
|
ca44bc |
From: Edward Haas <edwardh@redhat.com>
|
|
|
ca44bc |
Date: Wed, 7 Oct 2020 20:13:12 +0300
|
|
|
ca44bc |
Subject: [PATCH 1/2] nm, bridge, ovs: Collect only existing profiles
|
|
|
ca44bc |
|
|
|
ca44bc |
During the reporting flow, connections that are in teardown process
|
|
|
ca44bc |
no longer point to a valid profile. Avoid collecting such profiles (in
|
|
|
ca44bc |
practice, these are actually `None` objects).
|
|
|
ca44bc |
|
|
|
ca44bc |
Signed-off-by: Edward Haas <edwardh@redhat.com>
|
|
|
ca44bc |
Signed-off-by: Gris Ge <fge@redhat.com>
|
|
|
ca44bc |
---
|
|
|
ca44bc |
libnmstate/nm/bridge.py | 6 +++---
|
|
|
ca44bc |
libnmstate/nm/ovs.py | 4 +++-
|
|
|
ca44bc |
2 files changed, 6 insertions(+), 4 deletions(-)
|
|
|
ca44bc |
|
|
|
ca44bc |
diff --git a/libnmstate/nm/bridge.py b/libnmstate/nm/bridge.py
|
|
|
ca44bc |
index b885f7a..0ca6c2d 100644
|
|
|
ca44bc |
--- a/libnmstate/nm/bridge.py
|
|
|
ca44bc |
+++ b/libnmstate/nm/bridge.py
|
|
|
ca44bc |
@@ -260,9 +260,9 @@ def _get_slave_profiles_by_name(master_device):
|
|
|
ca44bc |
for dev in master_device.get_slaves():
|
|
|
ca44bc |
active_con = connection.get_device_active_connection(dev)
|
|
|
ca44bc |
if active_con:
|
|
|
ca44bc |
- slaves_profiles_by_name[
|
|
|
ca44bc |
- dev.get_iface()
|
|
|
ca44bc |
- ] = active_con.props.connection
|
|
|
ca44bc |
+ profile = active_con.props.connection
|
|
|
ca44bc |
+ if profile:
|
|
|
ca44bc |
+ slaves_profiles_by_name[dev.get_iface()] = profile
|
|
|
ca44bc |
return slaves_profiles_by_name
|
|
|
ca44bc |
|
|
|
ca44bc |
|
|
|
ca44bc |
diff --git a/libnmstate/nm/ovs.py b/libnmstate/nm/ovs.py
|
|
|
ca44bc |
index 2518773..eb373c3 100644
|
|
|
ca44bc |
--- a/libnmstate/nm/ovs.py
|
|
|
ca44bc |
+++ b/libnmstate/nm/ovs.py
|
|
|
ca44bc |
@@ -279,5 +279,7 @@ def _get_slave_profiles(master_device, devices_info):
|
|
|
ca44bc |
if active_con:
|
|
|
ca44bc |
master = active_con.props.master
|
|
|
ca44bc |
if master and (master.get_iface() == master_device.get_iface()):
|
|
|
ca44bc |
- slave_profiles.append(active_con.props.connection)
|
|
|
ca44bc |
+ profile = active_con.props.connection
|
|
|
ca44bc |
+ if profile:
|
|
|
ca44bc |
+ slave_profiles.append(profile)
|
|
|
ca44bc |
return slave_profiles
|
|
|
ca44bc |
--
|
|
|
ca44bc |
2.28.0
|
|
|
ca44bc |
|
|
|
ca44bc |
|
|
|
ca44bc |
From caf638d75e57da8770cd884782475f1c5668fd6d Mon Sep 17 00:00:00 2001
|
|
|
ca44bc |
From: Edward Haas <edwardh@redhat.com>
|
|
|
ca44bc |
Date: Wed, 7 Oct 2020 12:26:42 +0300
|
|
|
ca44bc |
Subject: [PATCH 2/2] nm, ovs: Fix report crash when OVS has dup iface names
|
|
|
ca44bc |
|
|
|
ca44bc |
In case of an existing OVS deployment which uses an identical name for
|
|
|
ca44bc |
the bridge, port and interface, libnmstate.show() exploded.
|
|
|
ca44bc |
|
|
|
ca44bc |
It is now possible to report such deployments.
|
|
|
ca44bc |
|
|
|
ca44bc |
Signed-off-by: Edward Haas <edwardh@redhat.com>
|
|
|
ca44bc |
Signed-off-by: Gris Ge <fge@redhat.com>
|
|
|
ca44bc |
---
|
|
|
ca44bc |
libnmstate/nm/ovs.py | 24 +++++++++++++++++++++---
|
|
|
ca44bc |
1 file changed, 21 insertions(+), 3 deletions(-)
|
|
|
ca44bc |
|
|
|
ca44bc |
diff --git a/libnmstate/nm/ovs.py b/libnmstate/nm/ovs.py
|
|
|
ca44bc |
index eb373c3..d1f26ba 100644
|
|
|
ca44bc |
--- a/libnmstate/nm/ovs.py
|
|
|
ca44bc |
+++ b/libnmstate/nm/ovs.py
|
|
|
ca44bc |
@@ -140,7 +140,12 @@ def get_port_by_slave(nmdev):
|
|
|
ca44bc |
|
|
|
ca44bc |
|
|
|
ca44bc |
def get_ovs_info(context, bridge_device, devices_info):
|
|
|
ca44bc |
- port_profiles = _get_slave_profiles(bridge_device, devices_info)
|
|
|
ca44bc |
+ ovs_ports_info = (
|
|
|
ca44bc |
+ info
|
|
|
ca44bc |
+ for info in devices_info
|
|
|
ca44bc |
+ if is_ovs_port_type_id(info[1]["type_id"])
|
|
|
ca44bc |
+ )
|
|
|
ca44bc |
+ port_profiles = _get_slave_profiles(bridge_device, ovs_ports_info)
|
|
|
ca44bc |
ports = _get_bridge_ports_info(context, port_profiles, devices_info)
|
|
|
ca44bc |
options = _get_bridge_options(context, bridge_device)
|
|
|
ca44bc |
|
|
|
ca44bc |
@@ -203,8 +208,21 @@ def _get_bridge_port_info(context, port_profile, devices_info):
|
|
|
ca44bc |
vlan_mode = port_setting.props.vlan_mode
|
|
|
ca44bc |
|
|
|
ca44bc |
port_name = port_profile.get_interface_name()
|
|
|
ca44bc |
- port_device = context.get_nm_dev(port_name)
|
|
|
ca44bc |
- port_slave_profiles = _get_slave_profiles(port_device, devices_info)
|
|
|
ca44bc |
+ port_device = next(
|
|
|
ca44bc |
+ dev
|
|
|
ca44bc |
+ for dev, devinfo in devices_info
|
|
|
ca44bc |
+ if devinfo["name"] == port_name
|
|
|
ca44bc |
+ and is_ovs_port_type_id(devinfo["type_id"])
|
|
|
ca44bc |
+ )
|
|
|
ca44bc |
+ devices_info_excluding_bridges_and_ports = (
|
|
|
ca44bc |
+ info
|
|
|
ca44bc |
+ for info in devices_info
|
|
|
ca44bc |
+ if not is_ovs_bridge_type_id(info[1]["type_id"])
|
|
|
ca44bc |
+ and not is_ovs_port_type_id(info[1]["type_id"])
|
|
|
ca44bc |
+ )
|
|
|
ca44bc |
+ port_slave_profiles = _get_slave_profiles(
|
|
|
ca44bc |
+ port_device, devices_info_excluding_bridges_and_ports
|
|
|
ca44bc |
+ )
|
|
|
ca44bc |
port_slave_names = [c.get_interface_name() for c in port_slave_profiles]
|
|
|
ca44bc |
|
|
|
ca44bc |
if port_slave_names:
|
|
|
ca44bc |
--
|
|
|
ca44bc |
2.28.0
|
|
|
ca44bc |
|