Merge "Check compatibility when auto schedule ha routers" into stable/mitaka
This commit is contained in:
commit
803cc36fd8
|
@ -306,10 +306,12 @@ class L3Scheduler(object):
|
||||||
agent)
|
agent)
|
||||||
scheduled = False
|
scheduled = False
|
||||||
admin_ctx = context.elevated()
|
admin_ctx = context.elevated()
|
||||||
for router, agents in routers_agents:
|
underscheduled_routers = [router for router, agents in routers_agents
|
||||||
max_agents_not_reached = (
|
if (not self.max_ha_agents or
|
||||||
not self.max_ha_agents or agents < self.max_ha_agents)
|
agents < self.max_ha_agents)]
|
||||||
if max_agents_not_reached:
|
schedulable_routers = self._get_routers_can_schedule(
|
||||||
|
admin_ctx, plugin, underscheduled_routers, agent)
|
||||||
|
for router in schedulable_routers:
|
||||||
if not self._router_has_binding(admin_ctx, router['id'],
|
if not self._router_has_binding(admin_ctx, router['id'],
|
||||||
agent.id):
|
agent.id):
|
||||||
self.create_ha_port_and_bind(plugin, admin_ctx,
|
self.create_ha_port_and_bind(plugin, admin_ctx,
|
||||||
|
|
|
@ -1676,6 +1676,34 @@ class L3HAChanceSchedulerTestCase(L3HATestCaseMixin):
|
||||||
def test_auto_schedule_all_routers_when_agent_added(self):
|
def test_auto_schedule_all_routers_when_agent_added(self):
|
||||||
self._auto_schedule_when_agent_added(False)
|
self._auto_schedule_when_agent_added(False)
|
||||||
|
|
||||||
|
def test_auto_schedule_ha_router_when_incompatible_agent_exist(self):
|
||||||
|
handle_internal_only_routers_agent = helpers.register_l3_agent(
|
||||||
|
'host_3', constants.L3_AGENT_MODE_LEGACY, internal_only=False)
|
||||||
|
router = self._create_ha_router()
|
||||||
|
|
||||||
|
self.plugin.auto_schedule_routers(
|
||||||
|
self.adminContext, handle_internal_only_routers_agent.host, [])
|
||||||
|
agents = self.plugin.get_l3_agents_hosting_routers(
|
||||||
|
self.adminContext, [router['id']],
|
||||||
|
admin_state_up=True)
|
||||||
|
agent_ids = [agent['id'] for agent in agents]
|
||||||
|
self.assertEqual(2, len(agents))
|
||||||
|
self.assertNotIn(handle_internal_only_routers_agent.id, agent_ids)
|
||||||
|
|
||||||
|
def test_auto_schedule_ha_router_when_dvr_agent_exist(self):
|
||||||
|
dvr_agent = helpers.register_l3_agent(
|
||||||
|
HOST_DVR, constants.L3_AGENT_MODE_DVR)
|
||||||
|
router = self._create_ha_router()
|
||||||
|
|
||||||
|
self.plugin.auto_schedule_routers(self.adminContext, dvr_agent.host,
|
||||||
|
[])
|
||||||
|
agents = self.plugin.get_l3_agents_hosting_routers(
|
||||||
|
self.adminContext, [router['id']],
|
||||||
|
admin_state_up=True)
|
||||||
|
agent_ids = [agent['id'] for agent in agents]
|
||||||
|
self.assertEqual(2, len(agents))
|
||||||
|
self.assertNotIn(dvr_agent.id, agent_ids)
|
||||||
|
|
||||||
def _auto_schedule_when_agent_added(self, specific_router):
|
def _auto_schedule_when_agent_added(self, specific_router):
|
||||||
router = self._create_ha_router()
|
router = self._create_ha_router()
|
||||||
agents = self.plugin.get_l3_agents_hosting_routers(
|
agents = self.plugin.get_l3_agents_hosting_routers(
|
||||||
|
|
Loading…
Reference in New Issue