use callback payloads for ROUTER/ROUTER_GATEWAY BEFORE_DELETE events

This patch switches ROUTER/ROUTER_GATEWAY BEFORE_DELETE events to use
payload style args. It also factors vpn_callback into a
separate callback specifically for ROUTER BEFORE_DELETE events to
support both styles; the TODO in the code can be cleaned up later.

Change-Id: I68fe5583426d6fa844a2a25a21256f842e587dff
Depends-On: https://review.openstack.org/#/c/562762
This commit is contained in:
Boden R 2018-06-29 08:10:26 -06:00 committed by YAMAMOTO Takashi
parent bb165298e0
commit bc9097c66e
1 changed files with 15 additions and 1 deletions

View File

@ -694,6 +694,8 @@ class VPNPluginRpcDbMixin(object):
def vpn_callback(resource, event, trigger, **kwargs):
# TODO(boden): refactor back into single method once everything is using
# the event payload objects
vpn_plugin = directory.get_plugin(p_constants.VPN)
if vpn_plugin:
context = kwargs.get('context')
@ -705,6 +707,17 @@ def vpn_callback(resource, event, trigger, **kwargs):
vpn_plugin.check_subnet_in_use(context, subnet_id, router_id)
def vpn_router_gateway_callback(resource, event, trigger, payload=None):
# TODO(boden): refactor back into single method once everything is using
# the event payload objects
vpn_plugin = directory.get_plugin(p_constants.VPN)
if vpn_plugin:
context = payload.context
router_id = payload.resource_id
if resource == resources.ROUTER_GATEWAY:
vpn_plugin.check_router_in_use(context, router_id)
def migration_callback(resource, event, trigger, **kwargs):
context = kwargs['context']
router = kwargs['router']
@ -725,7 +738,8 @@ def subnet_callback(resource, event, trigger, **kwargs):
def subscribe():
registry.subscribe(
vpn_callback, resources.ROUTER_GATEWAY, events.BEFORE_DELETE)
vpn_router_gateway_callback, resources.ROUTER_GATEWAY,
events.BEFORE_DELETE)
registry.subscribe(
vpn_callback, resources.ROUTER_INTERFACE, events.BEFORE_DELETE)
registry.subscribe(