From 8f2aad8fe169e8d6c9663f808898b90e0b62aefd Mon Sep 17 00:00:00 2001 From: Kevin Benton Date: Mon, 15 May 2017 16:02:44 -0700 Subject: [PATCH] Use SUBNET instead of SUBNET_GATEWAY event in L3 SUBNET_GATEWAY is being superceded by SUBNET, so we can just use that instead. Change-Id: I3ef5e6a046df4bae28aa111a796210a59df820fa Partial-Bug: #1690944 --- neutron/db/l3_db.py | 10 +++++++--- neutron/tests/unit/extensions/test_l3.py | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/neutron/db/l3_db.py b/neutron/db/l3_db.py index be53d62cbd0..03814b90704 100644 --- a/neutron/db/l3_db.py +++ b/neutron/db/l3_db.py @@ -1746,14 +1746,18 @@ class L3RpcNotifierMixin(object): LOG.debug('%s not configured', constants.L3) @staticmethod - @registry.receives(resources.SUBNET_GATEWAY, [events.AFTER_UPDATE]) + @registry.receives(resources.SUBNET, [events.AFTER_UPDATE]) def _notify_subnet_gateway_ip_update(resource, event, trigger, **kwargs): l3plugin = directory.get_plugin(constants.L3) if not l3plugin: return context = kwargs['context'] - network_id = kwargs['network_id'] - subnet_id = kwargs['subnet_id'] + orig = kwargs['original_subnet'] + updated = kwargs['subnet'] + if orig['gateway_ip'] == updated['gateway_ip']: + return + network_id = updated['network_id'] + subnet_id = updated['id'] query = context.session.query(models_v2.Port).filter_by( network_id=network_id, device_owner=constants.DEVICE_OWNER_ROUTER_GW) diff --git a/neutron/tests/unit/extensions/test_l3.py b/neutron/tests/unit/extensions/test_l3.py index ca54850d665..1a1577f6212 100644 --- a/neutron/tests/unit/extensions/test_l3.py +++ b/neutron/tests/unit/extensions/test_l3.py @@ -3253,7 +3253,7 @@ class L3NatTestCaseBase(L3NatTestCaseMixin): # make sure the callback is registered. registry.subscribe( l3_db.L3RpcNotifierMixin._notify_subnet_gateway_ip_update, - resources.SUBNET_GATEWAY, + resources.SUBNET, events.AFTER_UPDATE) with mock.patch.object(plugin.l3_rpc_notifier, 'routers_updated') as chk_method: