use payloads for SERVICE_EDGE events

This patch switches over to the payload style of callbacks for
SERVICE_EDGE based callback events.

Change-Id: I126b93f068b0f4b3631d0395b9790744b336dd77
This commit is contained in:
Boden R 2018-08-29 15:01:07 -06:00
parent 502bc3ad65
commit 7a8e6faeb0
2 changed files with 13 additions and 11 deletions

View File

@ -80,13 +80,15 @@ class RouterBaseDriver(RouterAbstractDriver):
self._availability_zones = nsx_az.NsxVAvailabilityZones()
def _notify_after_router_edge_association(self, context, router):
registry.notify(nsxv_constants.SERVICE_EDGE, events.AFTER_CREATE,
self, context=context, router=router)
registry.publish(nsxv_constants.SERVICE_EDGE, events.AFTER_CREATE,
self, payload=events.DBEventPayload(
context, states=(router,)))
def _notify_before_router_edge_association(self, context, router,
edge_id=None):
registry.notify(nsxv_constants.SERVICE_EDGE, events.BEFORE_DELETE,
self, context=context, router=router, edge_id=edge_id)
registry.publish(nsxv_constants.SERVICE_EDGE, events.BEFORE_DELETE,
self, payload=events.DBEventPayload(
context, states=(router,), resource_id=edge_id))
def _get_external_network_id_by_router(self, context, router_id):
"""Get router's external network id if it has."""

View File

@ -328,12 +328,12 @@ class NSXBgpPlugin(service_base.ServicePluginBase, bgp_db.BgpDbMixin):
context, speaker, router, updated_port)
def _before_service_edge_delete_callback(self, resource, event,
trigger, **kwargs):
context = kwargs['context'].elevated()
router = kwargs['router']
trigger, payload=None):
context = payload.context.elevated()
router = payload.latest_state
ext_net_id = router.gw_port and router.gw_port['network_id']
gw_ip = router.gw_port and router.gw_port['fixed_ips'][0]['ip_address']
edge_id = kwargs.get('edge_id')
edge_id = payload.resource_id
speakers = self._bgp_speakers_for_gateway_network(context, ext_net_id)
for speaker in speakers:
driver = self._get_driver_by_project(
@ -347,9 +347,9 @@ class NSXBgpPlugin(service_base.ServicePluginBase, bgp_db.BgpDbMixin):
gw_ip, edge_id)
def _after_service_edge_create_callback(self, resource, event,
trigger, **kwargs):
context = kwargs['context'].elevated()
router = kwargs['router']
trigger, payload=None):
context = payload.context.elevated()
router = payload.latest_state
ext_net_id = router.gw_port and router.gw_port['network_id']
speakers = self._bgp_speakers_for_gateway_network(context, ext_net_id)
for speaker in speakers: