[OVN] Allow only one physical network per bridge

Same as in other ML2 plugins (OVS, Linux Bridge), OVN mechanism driver
should allow only one physical network per bridge. The rule "one
network, one bridge" should be present in OVN too.

By allowing only one physical network per bridge, Neutron prevents
having two networks with subnets with the same CIDR in the same bridge.
Currently is possible and this CIDR clash is not prevented (shouldn't be
by the API). This architectural limitation prevents this situation.

This limitation is already present in deployment tools as TripleO.

Closes-Bug: #1956476
Change-Id: I74a2ca9a344a93219deb94d60247478ee3200659
This commit is contained in:
Rodolfo Alonso Hernandez 2021-12-23 11:00:09 +00:00
parent 12eecf9679
commit 55afd9bc92
4 changed files with 16 additions and 5 deletions

View File

@ -828,8 +828,7 @@ class OvsdbSbOvnIdl(sb_impl_idl.OvnSbApiIdlImpl, Backend):
def _get_chassis_physnets(self, chassis): def _get_chassis_physnets(self, chassis):
bridge_mappings = chassis.external_ids.get('ovn-bridge-mappings', '') bridge_mappings = chassis.external_ids.get('ovn-bridge-mappings', '')
mapping_dict = helpers.parse_mappings(bridge_mappings.split(','), mapping_dict = helpers.parse_mappings(bridge_mappings.split(','))
unique_values=False)
return list(mapping_dict.keys()) return list(mapping_dict.keys())
def chassis_exists(self, hostname): def chassis_exists(self, hostname):

View File

@ -194,8 +194,7 @@ class ChassisEvent(row_event.RowEvent):
phy_nets = [] phy_nets = []
if event != self.ROW_DELETE: if event != self.ROW_DELETE:
bridge_mappings = row.external_ids.get('ovn-bridge-mappings', '') bridge_mappings = row.external_ids.get('ovn-bridge-mappings', '')
mapping_dict = helpers.parse_mappings(bridge_mappings.split(','), mapping_dict = helpers.parse_mappings(bridge_mappings.split(','))
unique_values=False)
phy_nets = list(mapping_dict) phy_nets = list(mapping_dict)
self.driver.update_segment_host_mapping(host, phy_nets) self.driver.update_segment_host_mapping(host, phy_nets)

View File

@ -53,7 +53,7 @@ class TestSbApi(BaseOvnIdlTest):
{'external_ids': {'ovn-bridge-mappings': {'external_ids': {'ovn-bridge-mappings':
'public:br-ex,private:br-0'}}, 'public:br-ex,private:br-0'}},
{'external_ids': {'ovn-bridge-mappings': {'external_ids': {'ovn-bridge-mappings':
'public:br-ex,public2:br-ex'}}, 'public:br-ex,public2:br-ex2'}},
{'external_ids': {'ovn-bridge-mappings': {'external_ids': {'ovn-bridge-mappings':
'public:br-ex'}}, 'public:br-ex'}},
] ]
@ -99,6 +99,15 @@ class TestSbApi(BaseOvnIdlTest):
self.assertGreaterEqual(set(mapping.keys()), self.assertGreaterEqual(set(mapping.keys()),
{c['name'] for c in self.data['chassis']}) {c['name'] for c in self.data['chassis']})
def test_multiple_physnets_in_one_bridge(self):
self.data = {
'chassis': [
{'external_ids': {'ovn-bridge-mappings': 'p1:br-ex,p2:br-ex'}}
]
}
self.load_test_data()
self.assertRaises(ValueError, self.api.get_chassis_and_physnets)
def _add_switch_port(self, chassis_name, def _add_switch_port(self, chassis_name,
type=ovn_const.LSP_TYPE_LOCALPORT): type=ovn_const.LSP_TYPE_LOCALPORT):
sname, pname = (utils.get_rand_device_name(prefix=p) sname, pname = (utils.get_rand_device_name(prefix=p)

View File

@ -0,0 +1,4 @@
---
other:
- |
OVN mechanism driver allows only to have one physical network per bridge.