Introduce context in methods for Router Extra Attributes OVO usage.
This patch introduces context in methods where it is needed for object operations done during the integration of Router Extra Attributes OVO. Used in integration patch: https://review.openstack.org/#/c/381209/ Change-Id: I4dea67207220a19abf5d3cc754f02150b3621550 Partially-Implements: blueprint adopt-oslo-versioned-objects-for-db
This commit is contained in:
parent
dc8ad65838
commit
f5a721e0c2
@ -755,7 +755,7 @@ def is_ha_router(router):
|
||||
return cfg.CONF.l3_ha
|
||||
|
||||
|
||||
def is_ha_router_port(device_owner, router_id):
|
||||
def is_ha_router_port(context, device_owner, router_id):
|
||||
session = db_api.get_session()
|
||||
if device_owner == constants.DEVICE_OWNER_HA_REPLICATED_INT:
|
||||
return True
|
||||
|
@ -70,8 +70,8 @@ class L2populationMechanismDriver(api.MechanismDriver):
|
||||
def delete_port_postcommit(self, context):
|
||||
port = context.current
|
||||
agent_host = context.host
|
||||
fdb_entries = self._get_agent_fdb(context.bottom_bound_segment,
|
||||
port, agent_host)
|
||||
fdb_entries = self._get_agent_fdb(
|
||||
context, context.bottom_bound_segment, port, agent_host)
|
||||
if port['device_owner'] in l2pop_db.HA_ROUTER_PORTS and fdb_entries:
|
||||
session = db_api.get_session()
|
||||
network_id = port['network_id']
|
||||
@ -147,7 +147,7 @@ class L2populationMechanismDriver(api.MechanismDriver):
|
||||
def update_port_postcommit(self, context):
|
||||
port = context.current
|
||||
orig = context.original
|
||||
if l3_hamode_db.is_ha_router_port(port['device_owner'],
|
||||
if l3_hamode_db.is_ha_router_port(context, port['device_owner'],
|
||||
port['device_id']):
|
||||
return
|
||||
diff_ips = self._get_diff_ips(orig, port)
|
||||
@ -159,7 +159,8 @@ class L2populationMechanismDriver(api.MechanismDriver):
|
||||
if context.status == const.PORT_STATUS_DOWN:
|
||||
agent_host = context.host
|
||||
fdb_entries = self._get_agent_fdb(
|
||||
context.bottom_bound_segment, port, agent_host)
|
||||
context, context.bottom_bound_segment, port,
|
||||
agent_host)
|
||||
self.L2populationAgentNotify.remove_fdb_entries(
|
||||
self.rpc_ctx, fdb_entries)
|
||||
elif (context.host != context.original_host
|
||||
@ -168,7 +169,7 @@ class L2populationMechanismDriver(api.MechanismDriver):
|
||||
# The port has been migrated. Send notification about port
|
||||
# removal from old host.
|
||||
fdb_entries = self._get_agent_fdb(
|
||||
context.original_bottom_bound_segment,
|
||||
context, context.original_bottom_bound_segment,
|
||||
orig, context.original_host)
|
||||
self.L2populationAgentNotify.remove_fdb_entries(
|
||||
self.rpc_ctx, fdb_entries)
|
||||
@ -177,7 +178,8 @@ class L2populationMechanismDriver(api.MechanismDriver):
|
||||
self.update_port_up(context)
|
||||
elif context.status == const.PORT_STATUS_DOWN:
|
||||
fdb_entries = self._get_agent_fdb(
|
||||
context.bottom_bound_segment, port, context.host)
|
||||
context, context.bottom_bound_segment, port,
|
||||
context.host)
|
||||
self.L2populationAgentNotify.remove_fdb_entries(
|
||||
self.rpc_ctx, fdb_entries)
|
||||
|
||||
@ -246,7 +248,7 @@ class L2populationMechanismDriver(api.MechanismDriver):
|
||||
admin_context, agent_host, [port['device_id']]):
|
||||
return
|
||||
fdb_entries = self._get_agent_fdb(
|
||||
context.bottom_bound_segment, port, agent_host)
|
||||
context, context.bottom_bound_segment, port, agent_host)
|
||||
self.L2populationAgentNotify.remove_fdb_entries(
|
||||
self.rpc_ctx, fdb_entries)
|
||||
|
||||
@ -291,14 +293,14 @@ class L2populationMechanismDriver(api.MechanismDriver):
|
||||
|
||||
# Notify other agents to add fdb rule for current port
|
||||
if (port['device_owner'] != const.DEVICE_OWNER_DVR_INTERFACE and
|
||||
not l3_hamode_db.is_ha_router_port(port['device_owner'],
|
||||
port['device_id'])):
|
||||
not l3_hamode_db.is_ha_router_port(
|
||||
context, port['device_owner'], port['device_id'])):
|
||||
other_fdb_ports[agent_ip] += self._get_port_fdb_entries(port)
|
||||
|
||||
self.L2populationAgentNotify.add_fdb_entries(self.rpc_ctx,
|
||||
other_fdb_entries)
|
||||
|
||||
def _get_agent_fdb(self, segment, port, agent_host):
|
||||
def _get_agent_fdb(self, context, segment, port, agent_host):
|
||||
if not agent_host:
|
||||
return
|
||||
|
||||
@ -322,7 +324,8 @@ class L2populationMechanismDriver(api.MechanismDriver):
|
||||
const.FLOODING_ENTRY)
|
||||
# Notify other agents to remove fdb rules for current port
|
||||
if (port['device_owner'] != const.DEVICE_OWNER_DVR_INTERFACE and
|
||||
not l3_hamode_db.is_ha_router_port(port['device_owner'],
|
||||
not l3_hamode_db.is_ha_router_port(context,
|
||||
port['device_owner'],
|
||||
port['device_id'])):
|
||||
fdb_entries = self._get_port_fdb_entries(port)
|
||||
other_fdb_entries[network_id]['ports'][agent_ip] += fdb_entries
|
||||
|
@ -263,7 +263,8 @@ class RpcCallbacks(type_tunnel.TunnelRpcCallbackMixin):
|
||||
port = ml2_db.get_port(rpc_context.session, port_id)
|
||||
if not port:
|
||||
return
|
||||
is_ha_port = l3_hamode_db.is_ha_router_port(port['device_owner'],
|
||||
is_ha_port = l3_hamode_db.is_ha_router_port(rpc_context,
|
||||
port['device_owner'],
|
||||
port['device_id'])
|
||||
if is_ha_port:
|
||||
port_context = plugin.get_bound_port_context(
|
||||
|
@ -1187,7 +1187,7 @@ class L3HAModeDbTestCase(L3HATestFramework):
|
||||
interface_info)
|
||||
port = self._get_first_interface(router['id'])
|
||||
self.assertTrue(l3_hamode_db.is_ha_router_port(
|
||||
port['device_owner'], port['device_id']))
|
||||
self.admin_ctx, port['device_owner'], port['device_id']))
|
||||
|
||||
def test_is_ha_router_port_for_normal_port(self):
|
||||
network_id = self._create_network(self.core_plugin, self.admin_ctx)
|
||||
@ -1206,7 +1206,7 @@ class L3HAModeDbTestCase(L3HATestFramework):
|
||||
self.admin_ctx, filters=device_filter)[0]
|
||||
|
||||
self.assertFalse(l3_hamode_db.is_ha_router_port(
|
||||
port['device_owner'], port['device_id']))
|
||||
self.admin_ctx, port['device_owner'], port['device_id']))
|
||||
|
||||
|
||||
class L3HAUserTestCase(L3HATestFramework):
|
||||
|
Loading…
Reference in New Issue
Block a user