From 5c331ecbd25be464184e345cea8f38bb9fc712fc Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Wed, 12 Jul 2017 12:59:36 -0700 Subject: [PATCH] Fixed AttributeError in l2pop.delete_port_postcommit The error sneaked in with Ib6e59ab3405857d3ed4d82df1a80800089c3f06e where is_ha_router_port expects a NeutronContext object but we still pass PortContext instead. Change-Id: I593af5d050de00ddea7d758007d9856c4b97695f Closes-Bug: #1703938 --- neutron/plugins/ml2/drivers/l2pop/mech_driver.py | 2 +- .../unit/plugins/ml2/drivers/l2pop/test_mech_driver.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/neutron/plugins/ml2/drivers/l2pop/mech_driver.py b/neutron/plugins/ml2/drivers/l2pop/mech_driver.py index d4befda6aab..185324188c8 100644 --- a/neutron/plugins/ml2/drivers/l2pop/mech_driver.py +++ b/neutron/plugins/ml2/drivers/l2pop/mech_driver.py @@ -76,7 +76,7 @@ class L2populationMechanismDriver(api.MechanismDriver): fdb_entries = self._get_agent_fdb( plugin_context, context.bottom_bound_segment, port, agent_host) if fdb_entries and l3_hamode_db.is_ha_router_port( - context, port['device_owner'], port['device_id']): + plugin_context, port['device_owner'], port['device_id']): session = db_api.get_reader_session() network_id = port['network_id'] other_fdb_ports = self._get_ha_port_agents_fdb( diff --git a/neutron/tests/unit/plugins/ml2/drivers/l2pop/test_mech_driver.py b/neutron/tests/unit/plugins/ml2/drivers/l2pop/test_mech_driver.py index a0149468d86..25aff7cc146 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/l2pop/test_mech_driver.py +++ b/neutron/tests/unit/plugins/ml2/drivers/l2pop/test_mech_driver.py @@ -1146,6 +1146,14 @@ class TestL2PopulationRpcTestCase(test_plugin.Ml2PluginV2TestCase): self.driver.get_network( self.context, p['port']['network_id']), models.PortBinding(), bindings) + fdbs = { + p['port']['network_id']: { + 'segment_id': 'fakeid', + 'ports': {}, + } + } + mock.patch.object( + l2pop_mech, '_get_agent_fdb', return_value=fdbs).start() # The point is to provide coverage and to assert that # no exceptions are raised. l2pop_mech.delete_port_postcommit(port_context)