Merge "Use SUBNET instead of SUBNET_GATEWAY event in L3"

This commit is contained in:
Jenkins 2017-05-18 18:12:29 +00:00 committed by Gerrit Code Review
commit bbcfc4b45c
2 changed files with 8 additions and 4 deletions

View File

@ -1752,14 +1752,18 @@ class L3RpcNotifierMixin(object):
LOG.debug('%s not configured', constants.L3) LOG.debug('%s not configured', constants.L3)
@staticmethod @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): def _notify_subnet_gateway_ip_update(resource, event, trigger, **kwargs):
l3plugin = directory.get_plugin(constants.L3) l3plugin = directory.get_plugin(constants.L3)
if not l3plugin: if not l3plugin:
return return
context = kwargs['context'] context = kwargs['context']
network_id = kwargs['network_id'] orig = kwargs['original_subnet']
subnet_id = kwargs['subnet_id'] 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( query = context.session.query(models_v2.Port).filter_by(
network_id=network_id, network_id=network_id,
device_owner=constants.DEVICE_OWNER_ROUTER_GW) device_owner=constants.DEVICE_OWNER_ROUTER_GW)

View File

@ -3264,7 +3264,7 @@ class L3NatTestCaseBase(L3NatTestCaseMixin):
# make sure the callback is registered. # make sure the callback is registered.
registry.subscribe( registry.subscribe(
l3_db.L3RpcNotifierMixin._notify_subnet_gateway_ip_update, l3_db.L3RpcNotifierMixin._notify_subnet_gateway_ip_update,
resources.SUBNET_GATEWAY, resources.SUBNET,
events.AFTER_UPDATE) events.AFTER_UPDATE)
with mock.patch.object(plugin.l3_rpc_notifier, with mock.patch.object(plugin.l3_rpc_notifier,
'routers_updated') as chk_method: 'routers_updated') as chk_method: