summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLIU Yulong <i@liuyulong.me>2022-12-06 09:41:56 +0800
committerLIU Yulong <i@liuyulong.me>2023-04-06 09:32:27 +0800
commit5a17f2b24a51f62c406c1ad0ffa797480ef943f4 (patch)
tree18cd55a676ffbc1a1d665982b5f4b88d20f912bf
parent208421910d2bb3c71b0947254d5eca1326c184d0 (diff)
downloadneutron-5a17f2b24a51f62c406c1ad0ffa797480ef943f4.tar.gz
Pass physical bridge informations to OVS agent extension API
The metadata agent extension needs the patch ports informations between br-int and br-meta to add direct flows. Partially-Implements: blueprint distributed-metadata-datapath Change-Id: I58f3813ed9a4c4006ebb62e613ef4dc07a17a23b
-rw-r--r--neutron/plugins/ml2/drivers/openvswitch/agent/ovs_agent_extension_api.py17
-rw-r--r--neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py12
-rw-r--r--neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_agent_extension_api.py8
3 files changed, 32 insertions, 5 deletions
diff --git a/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_agent_extension_api.py b/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_agent_extension_api.py
index c6ec265a0b..aa4c3f4724 100644
--- a/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_agent_extension_api.py
+++ b/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_agent_extension_api.py
@@ -41,12 +41,18 @@ class OVSAgentExtensionAPI(object):
'''
def __init__(self, int_br, tun_br, phys_brs=None,
- plugin_rpc=None):
+ plugin_rpc=None,
+ phys_ofports=None,
+ bridge_mappings=None):
super(OVSAgentExtensionAPI, self).__init__()
self.br_int = int_br
self.br_tun = tun_br
self.br_phys = phys_brs or {}
self.plugin_rpc = plugin_rpc
+ # OVS agent extensions use this map to get physical device ofport.
+ self.phys_ofports = phys_ofports or {}
+ # OVS agent extensions use this map to get ovs bridge.
+ self.bridge_mappings = bridge_mappings or {}
def request_int_br(self):
"""Allows extensions to request an integration bridge to use for
@@ -74,3 +80,12 @@ class OVSAgentExtensionAPI(object):
"""
for phy_br in self.br_phys.values():
yield OVSCookieBridge(phy_br)
+
+ def request_physical_br(self, name):
+ """Allows extensions to request one physical bridge to use for
+ extension specific flows.
+ """
+ if not self.br_phys.get(name):
+ return None
+
+ return OVSCookieBridge(self.br_phys.get(name))
diff --git a/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py b/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py
index d6d45fe3f7..104052f72b 100644
--- a/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py
+++ b/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py
@@ -312,10 +312,14 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
self.ancillary_brs = self.setup_ancillary_bridges(
ovs_conf.integration_bridge, ovs_conf.tunnel_bridge)
- agent_api = ovs_ext_api.OVSAgentExtensionAPI(self.int_br,
- self.tun_br,
- self.phys_brs,
- self.plugin_rpc)
+ agent_api = ovs_ext_api.OVSAgentExtensionAPI(
+ self.int_br,
+ self.tun_br,
+ self.phys_brs,
+ self.plugin_rpc,
+ phys_ofports=self.phys_ofports,
+ bridge_mappings=self.bridge_mappings)
+
self.ext_manager.initialize(
self.connection, ovs_const.EXTENSION_DRIVER_TYPE, agent_api)
diff --git a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_agent_extension_api.py b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_agent_extension_api.py
index 50897a8772..f8a5643f3a 100644
--- a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_agent_extension_api.py
+++ b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_agent_extension_api.py
@@ -68,6 +68,14 @@ class TestOVSAgentExtensionAPI(ovs_test_base.OVSOSKenTestBase):
for phys_br in agent_extension_api.request_phy_brs():
self._test_bridge(self.br_phys[phys_br.br_name], phys_br)
+ def test_request_physical_br(self):
+ agent_extension_api = ovs_ext_agt.OVSAgentExtensionAPI(
+ self.br_int, self.br_tun,
+ {'phys1': self.br_phys['br-phys1'],
+ 'phys2': self.br_phys['br-phys2']})
+ phys_br = agent_extension_api.request_physical_br('phys1')
+ self._test_bridge(self.br_phys[phys_br.br_name], phys_br)
+
class TestOVSCookieBridgeOSKen(native_ovs_bridge_test_base.OVSBridgeTestBase):