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
(cherry picked from commit 7f63139424
)
This commit is contained in:
parent
8458e78649
commit
b22122453b
@ -480,21 +480,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'])
|
||||
|
||||
|
||||
|
@ -1496,10 +1496,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']}]
|
||||
@ -1519,8 +1519,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,
|
||||
|
Loading…
Reference in New Issue
Block a user