use callback payloads for ROUTER/ROUTER_GATEWAY BEFORE_DELETE events
This patch switches callbacks over to the payload object style events [1] for ROUTER and ROUTER_GATEWAY BEFORE_DELETE based notifications. To do so a DBEventPayload object is used with the publish() method to pass along the related data. NeutronLibImpact [1] https://docs.openstack.org/neutron-lib/latest/contributor/callbacks.html#event-payloads Change-Id: I3ce4475643f4f0afed01f2e9956b3bf84714e6f2
This commit is contained in:
@@ -457,10 +457,11 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
|
||||
if router not in context.session:
|
||||
context.session.add(router)
|
||||
try:
|
||||
kwargs = {'context': context, 'router_id': router.id}
|
||||
registry.notify(
|
||||
resources.ROUTER_GATEWAY, events.BEFORE_DELETE, self,
|
||||
**kwargs)
|
||||
registry.publish(resources.ROUTER_GATEWAY,
|
||||
events.BEFORE_DELETE, self,
|
||||
payload=events.DBEventPayload(
|
||||
context, states=(router,),
|
||||
resource_id=router.id))
|
||||
except exceptions.CallbackFailure as e:
|
||||
# NOTE(armax): preserve old check's behavior
|
||||
if len(e.errors) == 1:
|
||||
@@ -555,8 +556,9 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
|
||||
|
||||
@db_api.retry_if_session_inactive()
|
||||
def delete_router(self, context, id):
|
||||
registry.notify(resources.ROUTER, events.BEFORE_DELETE,
|
||||
self, context=context, router_id=id)
|
||||
registry.publish(resources.ROUTER, events.BEFORE_DELETE, self,
|
||||
payload=events.DBEventPayload(
|
||||
context, resource_id=id))
|
||||
# TODO(nati) Refactor here when we have router insertion model
|
||||
router = self._ensure_router_not_in_use(context, id)
|
||||
original = self._make_router_dict(router)
|
||||
|
||||
Reference in New Issue
Block a user