Fix notify listener syntax for SEGMENT_HOST_MAPPING

Change auto_schedule_new_network_segments call to use old notification
listener syntax in old stable branches of Neutron that still use
notify instead of publish.
Fix only needed for stable/stein, stable/rocky, stable/queens

Closes-Bug: #1939125
Change-Id: I99a50725a514b324d3f886db9fd2d3dd37efd031
This commit is contained in:
Szymon Wroblewski 2021-08-06 13:18:04 +02:00 committed by Szymon Wróblewski
parent 7f63139424
commit 66bc64155a
2 changed files with 11 additions and 11 deletions

View File

@ -487,21 +487,21 @@ class DhcpAgentSchedulerDbMixin(dhcpagentscheduler
@registry.receives(resources.SEGMENT_HOST_MAPPING, [events.AFTER_CREATE])
def auto_schedule_new_network_segments(self, resource, event, trigger,
payload=None):
context, host, current_segment_ids,
**kwargs):
if not cfg.CONF.network_auto_schedule:
return
segment_plugin = directory.get_plugin('segments')
dhcp_notifier = self.agent_notifiers.get(constants.AGENT_TYPE_DHCP)
segment_ids = payload.metadata.get('current_segment_ids')
segments = segment_plugin.get_segments(
payload.context, filters={'id': segment_ids})
context, filters={'id': current_segment_ids})
subnets = subnet_obj.Subnet.get_objects(
payload.context, segment_id=segment_ids)
context, segment_id=current_segment_ids)
network_ids = {s.network_id for s in subnets}
for network_id in network_ids:
for segment in segments:
self._schedule_network(
payload.context, network_id, dhcp_notifier,
context, network_id, dhcp_notifier,
candidate_hosts=segment['hosts'])

View File

@ -1564,10 +1564,10 @@ class OvsDhcpAgentNotifierTestCase(test_agent.AgentDBTestMixIn,
def _test_auto_schedule_new_network_segments(self, subnet_on_segment):
ctx = mock.Mock()
payload = events.DBEventPayload(
ctx,
metadata={'host': 'HOST A',
'current_segment_ids': set(['segment-1'])})
notify_kwargs = {
'context': ctx,
'host': 'HOST A',
'current_segment_ids': set(['segment-1'])}
segments_plugin = mock.Mock()
segments_plugin.get_segments.return_value = [
{'id': 'segment-1', 'hosts': ['HOST A']}]
@ -1587,8 +1587,8 @@ class OvsDhcpAgentNotifierTestCase(test_agent.AgentDBTestMixIn,
dhcp_mixin.agent_notifiers[constants.AGENT_TYPE_DHCP] = (
dhcp_notifier)
dhcp_mixin.auto_schedule_new_network_segments(
resources.SEGMENT_HOST_MAPPING, events.AFTER_CREATE,
ctx, payload)
resources.SEGMENT_HOST_MAPPING, events.AFTER_CREATE, None,
**notify_kwargs)
if subnet_on_segment:
schedule_network.assert_called_once_with(
ctx, subnet_on_segment.network_id,