Merge "Unify exception thrown in l3-agent-scheduler fails"
This commit is contained in:
commit
30d7852437
@ -132,12 +132,11 @@ class L3AgentSchedulerDbMixin(l3agentscheduler.L3AgentSchedulerPluginBase,
|
|||||||
raise l3agentscheduler.InvalidL3Agent(id=id)
|
raise l3agentscheduler.InvalidL3Agent(id=id)
|
||||||
query = context.session.query(RouterL3AgentBinding)
|
query = context.session.query(RouterL3AgentBinding)
|
||||||
try:
|
try:
|
||||||
binding = query.filter(
|
binding = query.filter_by(router_id=router_id).one()
|
||||||
RouterL3AgentBinding.l3_agent_id == agent_db.id,
|
|
||||||
RouterL3AgentBinding.router_id == router_id).one()
|
raise l3agentscheduler.RouterHostedByL3Agent(
|
||||||
if binding:
|
router_id=router_id,
|
||||||
raise l3agentscheduler.RouterHostedByL3Agent(
|
agent_id=binding.l3_agent_id)
|
||||||
router_id=router_id, agent_id=id)
|
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -229,7 +228,7 @@ class L3AgentSchedulerDbMixin(l3agentscheduler.L3AgentSchedulerPluginBase,
|
|||||||
l3_agents = [l3_agent for l3_agent in
|
l3_agents = [l3_agent for l3_agent in
|
||||||
l3_agents if not
|
l3_agents if not
|
||||||
agents_db.AgentDbMixin.is_agent_down(
|
agents_db.AgentDbMixin.is_agent_down(
|
||||||
l3_agent['heartbeat_timestamp'])]
|
l3_agent['heartbeat_timestamp'])]
|
||||||
return l3_agents
|
return l3_agents
|
||||||
|
|
||||||
def _get_l3_bindings_hosting_routers(self, context, router_ids):
|
def _get_l3_bindings_hosting_routers(self, context, router_ids):
|
||||||
|
@ -825,10 +825,11 @@ class OvsAgentSchedulerTestCase(test_l3_plugin.L3NatTestCaseMixin,
|
|||||||
self.assertEqual(0, len(l3agents))
|
self.assertEqual(0, len(l3agents))
|
||||||
|
|
||||||
def test_router_sync_data(self):
|
def test_router_sync_data(self):
|
||||||
with contextlib.nested(self.subnet(),
|
with contextlib.nested(
|
||||||
self.subnet(cidr='10.0.2.0/24'),
|
self.subnet(),
|
||||||
self.subnet(cidr='10.0.3.0/24')) as (
|
self.subnet(cidr='10.0.2.0/24'),
|
||||||
s1, s2, s3):
|
self.subnet(cidr='10.0.3.0/24')
|
||||||
|
) as (s1, s2, s3):
|
||||||
self._register_agent_states()
|
self._register_agent_states()
|
||||||
self._set_net_external(s1['subnet']['network_id'])
|
self._set_net_external(s1['subnet']['network_id'])
|
||||||
data = {'router': {'tenant_id': uuidutils.generate_uuid()}}
|
data = {'router': {'tenant_id': uuidutils.generate_uuid()}}
|
||||||
@ -908,6 +909,30 @@ class OvsAgentSchedulerTestCase(test_l3_plugin.L3NatTestCaseMixin,
|
|||||||
self.assertEqual(0, num_before_add)
|
self.assertEqual(0, num_before_add)
|
||||||
self.assertEqual(1, num_after_add)
|
self.assertEqual(1, num_after_add)
|
||||||
|
|
||||||
|
def test_router_add_to_l3_agent_two_times(self):
|
||||||
|
with self.router() as router1:
|
||||||
|
self._register_agent_states()
|
||||||
|
hosta_id = self._get_agent_id(constants.AGENT_TYPE_L3,
|
||||||
|
L3_HOSTA)
|
||||||
|
self._add_router_to_l3_agent(hosta_id,
|
||||||
|
router1['router']['id'])
|
||||||
|
self._add_router_to_l3_agent(hosta_id,
|
||||||
|
router1['router']['id'],
|
||||||
|
expected_code=exc.HTTPConflict.code)
|
||||||
|
|
||||||
|
def test_router_add_to_two_l3_agents(self):
|
||||||
|
with self.router() as router1:
|
||||||
|
self._register_agent_states()
|
||||||
|
hosta_id = self._get_agent_id(constants.AGENT_TYPE_L3,
|
||||||
|
L3_HOSTA)
|
||||||
|
hostb_id = self._get_agent_id(constants.AGENT_TYPE_L3,
|
||||||
|
L3_HOSTB)
|
||||||
|
self._add_router_to_l3_agent(hosta_id,
|
||||||
|
router1['router']['id'])
|
||||||
|
self._add_router_to_l3_agent(hostb_id,
|
||||||
|
router1['router']['id'],
|
||||||
|
expected_code=exc.HTTPConflict.code)
|
||||||
|
|
||||||
def test_router_policy(self):
|
def test_router_policy(self):
|
||||||
with self.router() as router1:
|
with self.router() as router1:
|
||||||
self._register_agent_states()
|
self._register_agent_states()
|
||||||
|
Loading…
Reference in New Issue
Block a user