Merge "Fix InvalidRequestError in auto_schedule_routers"
This commit is contained in:
commit
d07b175a95
@ -116,26 +116,25 @@ class L3Scheduler(object):
|
||||
|
||||
:returns: True if routers have been successfully assigned to host
|
||||
"""
|
||||
with context.session.begin(subtransactions=True):
|
||||
l3_agent = plugin.get_enabled_agent_on_host(
|
||||
context, constants.AGENT_TYPE_L3, host)
|
||||
if not l3_agent:
|
||||
return False
|
||||
l3_agent = plugin.get_enabled_agent_on_host(
|
||||
context, constants.AGENT_TYPE_L3, host)
|
||||
if not l3_agent:
|
||||
return False
|
||||
|
||||
unscheduled_routers = self.get_routers_to_schedule(
|
||||
context, plugin, router_ids)
|
||||
if not unscheduled_routers:
|
||||
return False
|
||||
unscheduled_routers = self.get_routers_to_schedule(
|
||||
context, plugin, router_ids)
|
||||
if not unscheduled_routers:
|
||||
return False
|
||||
|
||||
target_routers = self.get_routers_can_schedule(
|
||||
context, plugin, unscheduled_routers, l3_agent)
|
||||
if not target_routers:
|
||||
LOG.warn(_('No routers compatible with L3 agent configuration'
|
||||
' on host %s'), host)
|
||||
return False
|
||||
target_routers = self.get_routers_can_schedule(
|
||||
context, plugin, unscheduled_routers, l3_agent)
|
||||
if not target_routers:
|
||||
LOG.warn(_('No routers compatible with L3 agent configuration'
|
||||
' on host %s'), host)
|
||||
return False
|
||||
|
||||
self.bind_routers(context, target_routers, l3_agent)
|
||||
return True
|
||||
self.bind_routers(context, target_routers, l3_agent)
|
||||
return True
|
||||
|
||||
def get_candidates(self, plugin, context, sync_router, subnet_id):
|
||||
"""Return L3 agents where a router could be scheduled."""
|
||||
|
@ -101,7 +101,6 @@ class L3SchedulerBaseTestCase(base.BaseTestCase):
|
||||
super(L3SchedulerBaseTestCase, self).setUp()
|
||||
self.scheduler = FakeL3Scheduler()
|
||||
self.plugin = mock.Mock()
|
||||
self.context = q_context.get_admin_context()
|
||||
|
||||
def test_auto_schedule_routers(self):
|
||||
self.plugin.get_enabled_agent_on_host.return_value = [mock.ANY]
|
||||
@ -110,7 +109,7 @@ class L3SchedulerBaseTestCase(base.BaseTestCase):
|
||||
mock.patch.object(self.scheduler, 'get_routers_can_schedule')) as (
|
||||
gs, gr):
|
||||
result = self.scheduler.auto_schedule_routers(
|
||||
self.plugin, self.context, mock.ANY, mock.ANY)
|
||||
self.plugin, mock.ANY, mock.ANY, mock.ANY)
|
||||
self.assertTrue(self.plugin.get_enabled_agent_on_host.called)
|
||||
self.assertTrue(result)
|
||||
self.assertTrue(gs.called)
|
||||
@ -119,7 +118,7 @@ class L3SchedulerBaseTestCase(base.BaseTestCase):
|
||||
def test_auto_schedule_routers_no_agents(self):
|
||||
self.plugin.get_enabled_agent_on_host.return_value = None
|
||||
result = self.scheduler.auto_schedule_routers(
|
||||
self.plugin, self.context, mock.ANY, mock.ANY)
|
||||
self.plugin, mock.ANY, mock.ANY, mock.ANY)
|
||||
self.assertTrue(self.plugin.get_enabled_agent_on_host.called)
|
||||
self.assertFalse(result)
|
||||
|
||||
@ -128,7 +127,7 @@ class L3SchedulerBaseTestCase(base.BaseTestCase):
|
||||
'get_routers_to_schedule') as mock_routers:
|
||||
mock_routers.return_value = None
|
||||
result = self.scheduler.auto_schedule_routers(
|
||||
self.plugin, self.context, mock.ANY, mock.ANY)
|
||||
self.plugin, mock.ANY, mock.ANY, mock.ANY)
|
||||
self.assertTrue(self.plugin.get_enabled_agent_on_host.called)
|
||||
self.assertFalse(result)
|
||||
|
||||
@ -141,7 +140,7 @@ class L3SchedulerBaseTestCase(base.BaseTestCase):
|
||||
mock_unscheduled_routers.return_value = mock.ANY
|
||||
mock_target_routers.return_value = None
|
||||
result = self.scheduler.auto_schedule_routers(
|
||||
self.plugin, self.context, mock.ANY, mock.ANY)
|
||||
self.plugin, mock.ANY, mock.ANY, mock.ANY)
|
||||
self.assertTrue(self.plugin.get_enabled_agent_on_host.called)
|
||||
self.assertFalse(result)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user