From 99e3999975e053f76e60a714647e0f7165f8eab0 Mon Sep 17 00:00:00 2001 From: Boden R Date: Mon, 22 Apr 2019 11:45:14 -0600 Subject: [PATCH] use publish for SEGMENT_HOST_MAPPING callback events This patch switches over to payload style callbacks for all SEGMENT_HOST_MAPPING events. NeutronLibImpact Change-Id: I71888b2b72b486c32991d651cdc608adb2149500 --- neutron/services/segments/db.py | 9 ++++++--- neutron/services/segments/plugin.py | 13 +++++++------ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/neutron/services/segments/db.py b/neutron/services/segments/db.py index 88fe78dc0b0..a8f1436b461 100644 --- a/neutron/services/segments/db.py +++ b/neutron/services/segments/db.py @@ -299,9 +299,12 @@ def _update_segment_host_mapping_for_agent(resource, event, trigger, segment['id'] for segment in segments if check_segment_for_agent(segment, agent)} update_segment_host_mapping(context, host, current_segment_ids) - registry.notify(resources.SEGMENT_HOST_MAPPING, events.AFTER_CREATE, - plugin, context=context, host=host, - current_segment_ids=current_segment_ids) + registry.publish(resources.SEGMENT_HOST_MAPPING, events.AFTER_CREATE, + plugin, payload=events.DBEventPayload( + context, + metadata={ + 'host': host, + 'current_segment_ids': current_segment_ids})) def _add_segment_host_mapping_for_segment(resource, event, trigger, diff --git a/neutron/services/segments/plugin.py b/neutron/services/segments/plugin.py index b607f09e6b4..cc08c22af8c 100644 --- a/neutron/services/segments/plugin.py +++ b/neutron/services/segments/plugin.py @@ -348,13 +348,14 @@ class NovaSegmentNotifier(object): @registry.receives(resources.SEGMENT_HOST_MAPPING, [events.AFTER_CREATE]) def _notify_host_addition_to_aggregate(self, resource, event, trigger, - context, host, current_segment_ids, - **kwargs): - subnets = subnet_obj.Subnet.get_objects(context, - segment_id=current_segment_ids) + payload=None): + subnets = subnet_obj.Subnet.get_objects( + payload.context, + segment_id=payload.metadata.get('current_segment_ids')) segment_ids = {s.segment_id for s in subnets} - self.batch_notifier.queue_event(Event(self._add_host_to_aggregate, - segment_ids, host=host)) + self.batch_notifier.queue_event( + Event(self._add_host_to_aggregate, + segment_ids, host=payload.metadata.get('host'))) def _add_host_to_aggregate(self, event): for segment_id in event.segment_ids: