diff --git a/neutron/scheduler/dhcp_agent_scheduler.py b/neutron/scheduler/dhcp_agent_scheduler.py index b414f12889b..ffa48045b4f 100644 --- a/neutron/scheduler/dhcp_agent_scheduler.py +++ b/neutron/scheduler/dhcp_agent_scheduler.py @@ -79,9 +79,10 @@ class AutoScheduler(object): if is_routed_network: if len(segments_on_network & segments_on_host) == 0: continue - else: - if len(agents) >= agents_per_network: - continue + # The following two checks apply to both routed and + # non-routed networks + if len(agents) >= agents_per_network: + continue if any(dhcp_agent.id == agent.id for agent in agents): continue net = plugin.get_network(context, net_id) diff --git a/neutron/tests/unit/scheduler/test_dhcp_agent_scheduler.py b/neutron/tests/unit/scheduler/test_dhcp_agent_scheduler.py index e1cc9b346ec..8c32f6f5c43 100644 --- a/neutron/tests/unit/scheduler/test_dhcp_agent_scheduler.py +++ b/neutron/tests/unit/scheduler/test_dhcp_agent_scheduler.py @@ -381,6 +381,7 @@ class TestAutoScheduleSegments(test_plugin.Ml2PluginV2TestCase, self.ctx, [net_id]) self.assertEqual(1, len(agents)) + cfg.CONF.set_override('dhcp_agents_per_network', 2) seg2_id = self._create_segment(net_id, 'physnet2') self._create_subnet(seg2_id, net_id, '192.168.11.0/24') helpers.register_dhcp_agent(HOST_C)