Merge "Fix getting dhcp agents for multiple networks"
This commit is contained in:
commit
88710bbc6b
@ -335,12 +335,9 @@ class DhcpAgentSchedulerDbMixin(dhcpagentscheduler
|
||||
query = query.options(orm.contains_eager(
|
||||
NetworkDhcpAgentBinding.dhcp_agent))
|
||||
query = query.join(NetworkDhcpAgentBinding.dhcp_agent)
|
||||
if len(network_ids) == 1:
|
||||
if network_ids:
|
||||
query = query.filter(
|
||||
NetworkDhcpAgentBinding.network_id == network_ids[0])
|
||||
elif network_ids:
|
||||
query = query.filter(
|
||||
NetworkDhcpAgentBinding.network_id in network_ids)
|
||||
NetworkDhcpAgentBinding.network_id.in_(network_ids))
|
||||
if admin_state_up is not None:
|
||||
query = query.filter(agents_db.Agent.admin_state_up ==
|
||||
admin_state_up)
|
||||
|
@ -472,9 +472,11 @@ class TestDhcpSchedulerFilter(TestDhcpSchedulerBaseTestCase,
|
||||
agents = self._create_and_set_agents_down(['host-a', 'host-b'], 1)
|
||||
agents += self._create_and_set_agents_down(['host-c', 'host-d'], 1,
|
||||
admin_state_up=False)
|
||||
self._test_schedule_bind_network(agents, self.network_id)
|
||||
networks = kwargs.pop('networks', [self.network_id])
|
||||
for network in networks:
|
||||
self._test_schedule_bind_network(agents, network)
|
||||
agents = self.get_dhcp_agents_hosting_networks(self.ctx,
|
||||
[self.network_id],
|
||||
networks,
|
||||
**kwargs)
|
||||
host_ids = set(a['host'] for a in agents)
|
||||
self.assertEqual(expected, host_ids)
|
||||
@ -505,6 +507,14 @@ class TestDhcpSchedulerFilter(TestDhcpSchedulerBaseTestCase,
|
||||
active=True,
|
||||
admin_state_up=False)
|
||||
|
||||
def test_get_dhcp_agents_hosting_many_networks(self):
|
||||
net_id = 'another-net-id'
|
||||
self._save_networks([net_id])
|
||||
networks = [net_id, self.network_id]
|
||||
self._test_get_dhcp_agents_hosting_networks({'host-a', 'host-b',
|
||||
'host-c', 'host-d'},
|
||||
networks=networks)
|
||||
|
||||
|
||||
class DHCPAgentAZAwareWeightSchedulerTestCase(TestDhcpSchedulerBaseTestCase):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user