From 4f8fe6adbfca242c5d4ef7d4d66b9240785f945e Mon Sep 17 00:00:00 2001 From: Eduardo Olivares Date: Wed, 13 Nov 2024 12:36:23 +0100 Subject: [PATCH] Fix type for config option bgp_chassis_id Type List was wrongly used. Type Str should be used instead. Closes-Bug: #2088057 Change-Id: I26e04725ce419f87b8cde78567e88fe479cee1ae --- ovn_bgp_agent/config.py | 14 +++++++------- .../unit/drivers/openstack/utils/test_ovs.py | 17 ++++++++++++++++- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/ovn_bgp_agent/config.py b/ovn_bgp_agent/config.py index 63a04f65..d704ecb0 100644 --- a/ovn_bgp_agent/config.py +++ b/ovn_bgp_agent/config.py @@ -231,13 +231,13 @@ local_ovn_cluster_opts = [ cfg.ListOpt('provider_networks_pool_prefixes', default=['192.168.0.0/16'], help='List of prefixes for provider networks'), - cfg.ListOpt('bgp_chassis_id', - default='bgp', - help='The chassis_id used for the ovn-controller instance' - ' related to the node-local OVN instance. Used as a' - ' suffix for getting instance-specific options' - ' from OVSDB. This option has effect only when the OVN' - ' NB driver is used.'), + cfg.StrOpt('bgp_chassis_id', + default='bgp', + help='The chassis_id used for the ovn-controller instance' + ' related to the node-local OVN instance. Used as a' + ' suffix for getting instance-specific options' + ' from OVSDB. This option has effect only when the OVN' + ' NB driver is used.'), ] CONF = cfg.CONF diff --git a/ovn_bgp_agent/tests/unit/drivers/openstack/utils/test_ovs.py b/ovn_bgp_agent/tests/unit/drivers/openstack/utils/test_ovs.py index 1272d6a4..8e603fda 100644 --- a/ovn_bgp_agent/tests/unit/drivers/openstack/utils/test_ovs.py +++ b/ovn_bgp_agent/tests/unit/drivers/openstack/utils/test_ovs.py @@ -15,6 +15,7 @@ from unittest import mock +from oslo_config import cfg from ovsdbapp.schema.open_vswitch import impl_idl as idl_ovs from ovn_bgp_agent import constants @@ -24,6 +25,9 @@ from ovn_bgp_agent.tests import base as test_base from ovn_bgp_agent.utils import linux_net +CONF = cfg.CONF + + class TestOVS(test_base.TestCase): def setUp(self): @@ -484,7 +488,18 @@ class TestOvsIdl(test_base.TestCase): 'Open_vSwitch', '.', 'external_ids') def test_get_ovn_bridge_mappings_bridge(self): - bridge = 'bgp' + bridge = 'bgp1' + self.execute_ref.return_value = { + 'ovn-bridge-mappings-bgp1': + 'net0:bridge0,net1:bridge1, net2:bridge2'} + ret = self.ovs_idl.get_ovn_bridge_mappings(bridge=bridge) + self.assertEqual(['net0:bridge0', 'net1:bridge1', 'net2:bridge2'], ret) + self.ovs_idl.idl_ovs.db_get.assert_called_once_with( + 'Open_vSwitch', '.', 'external_ids') + + def test_get_ovn_bridge_mappings_default_bridge(self): + # bgp_chassis_id defaults to 'bgp' + bridge = CONF.local_ovn_cluster.bgp_chassis_id self.execute_ref.return_value = { 'ovn-bridge-mappings-bgp': 'net0:bridge0,net1:bridge1, net2:bridge2'}