Browse Source

Merge "[L3] Delete DvrFipGatewayPortAgentBindings after no gw ports" into stable/ussuri

changes/34/780834/1 16.3.1
Zuul 1 month ago
committed by Gerrit Code Review
parent
commit
4ca55a3365
2 changed files with 29 additions and 0 deletions
  1. +5
    -0
      neutron/db/l3_dvr_db.py
  2. +24
    -0
      neutron/tests/unit/db/test_l3_dvr_db.py

+ 5
- 0
neutron/db/l3_dvr_db.py View File

@ -375,6 +375,11 @@ class DVRResourceOperationHandler(object):
# to clean up the fip namespace as it is no longer required.
self.l3plugin.l3_rpc_notifier.delete_fipnamespace_for_ext_net(
payload.context, network_id)
# Delete the Floating IP agent gateway port
# bindings on all hosts
l3_obj.DvrFipGatewayPortAgentBinding.delete_objects(
payload.context,
network_id=network_id)
def _delete_fip_agent_port(self, context, network_id, host_id):
try:


+ 24
- 0
neutron/tests/unit/db/test_l3_dvr_db.py View File

@ -1409,3 +1409,27 @@ class L3DvrTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
self.assertRaises(
exceptions.BadRequest,
self.mixin._get_assoc_data, self.ctx, mock.ANY, mock.Mock())
def test__delete_dvr_internal_ports(self):
payload = mock.Mock()
payload.context = mock.Mock()
payload.latest_state = {'distributed': True}
payload.metadata = {'new_network_id': 'fake-net-1',
'network_id': 'fake-net-2'}
plugin = mock.Mock()
directory.add_plugin(plugin_constants.CORE, plugin)
plugin.get_ports.return_value = []
with mock.patch.object(self.mixin,
'delete_floatingip_agent_gateway_port') as \
del_port, \
mock.patch.object(
self.mixin.l3_rpc_notifier,
'delete_fipnamespace_for_ext_net') as \
del_fip_ns, \
mock.patch.object(router_obj.DvrFipGatewayPortAgentBinding,
"delete_objects") as del_binding:
self.mixin._delete_dvr_internal_ports(
None, None, resources.ROUTER_GATEWAY, payload)
del_port.assert_called_once()
del_fip_ns.assert_called_once()
del_binding.assert_called_once()

Loading…
Cancel
Save