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
This commit is contained in:
LIU Yulong 2022-12-06 09:41:56 +08:00
parent 208421910d
commit 5a17f2b24a
3 changed files with 32 additions and 5 deletions

View File

@ -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))

View File

@ -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)

View File

@ -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):