Merge "Unify exception thrown in l3-agent-scheduler fails"
This commit is contained in:
commit
d9b0fee0e6
@ -132,12 +132,11 @@ class L3AgentSchedulerDbMixin(l3agentscheduler.L3AgentSchedulerPluginBase,
|
||||
raise l3agentscheduler.InvalidL3Agent(id=id)
|
||||
query = context.session.query(RouterL3AgentBinding)
|
||||
try:
|
||||
binding = query.filter(
|
||||
RouterL3AgentBinding.l3_agent_id == agent_db.id,
|
||||
RouterL3AgentBinding.router_id == router_id).one()
|
||||
if binding:
|
||||
raise l3agentscheduler.RouterHostedByL3Agent(
|
||||
router_id=router_id, agent_id=id)
|
||||
binding = query.filter_by(router_id=router_id).one()
|
||||
|
||||
raise l3agentscheduler.RouterHostedByL3Agent(
|
||||
router_id=router_id,
|
||||
agent_id=binding.l3_agent_id)
|
||||
except exc.NoResultFound:
|
||||
pass
|
||||
|
||||
@ -229,7 +228,7 @@ class L3AgentSchedulerDbMixin(l3agentscheduler.L3AgentSchedulerPluginBase,
|
||||
l3_agents = [l3_agent for l3_agent in
|
||||
l3_agents if not
|
||||
agents_db.AgentDbMixin.is_agent_down(
|
||||
l3_agent['heartbeat_timestamp'])]
|
||||
l3_agent['heartbeat_timestamp'])]
|
||||
return l3_agents
|
||||
|
||||
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))
|
||||
|
||||
def test_router_sync_data(self):
|
||||
with contextlib.nested(self.subnet(),
|
||||
self.subnet(cidr='10.0.2.0/24'),
|
||||
self.subnet(cidr='10.0.3.0/24')) as (
|
||||
s1, s2, s3):
|
||||
with contextlib.nested(
|
||||
self.subnet(),
|
||||
self.subnet(cidr='10.0.2.0/24'),
|
||||
self.subnet(cidr='10.0.3.0/24')
|
||||
) as (s1, s2, s3):
|
||||
self._register_agent_states()
|
||||
self._set_net_external(s1['subnet']['network_id'])
|
||||
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(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):
|
||||
with self.router() as router1:
|
||||
self._register_agent_states()
|
||||
|
Loading…
Reference in New Issue
Block a user