Merge "use publish for SEGMENT_HOST_MAPPING callback events"

This commit is contained in:
Zuul 2019-05-07 21:45:43 +00:00 committed by Gerrit Code Review
commit 92215d40cb
2 changed files with 13 additions and 9 deletions

View File

@ -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,

View File

@ -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: