]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Return 404 when executing router-list-on-l3-agent with invalid agent_id
authorHirofumi Ichihara <ichihara.hirofumi@lab.ntt.co.jp>
Fri, 23 Jan 2015 08:30:53 +0000 (17:30 +0900)
committerHirofumi Ichihara <ichihara.hirofumi@lab.ntt.co.jp>
Tue, 27 Jan 2015 05:18:45 +0000 (14:18 +0900)
Neutron server returns HTML code 200 when users execute
router-list-on-l3-agent with invalid agent_id.
Users expect HTML code 404 to be returned.

Change-Id: Ifadca8d6573a94abc3580a0de4463b755ef12a24
Closes-bug: 1413500

neutron/db/l3_agentschedulers_db.py
neutron/tests/unit/openvswitch/test_agent_scheduler.py

index 104c4f6024a163780b205e739ea13061e8523959..03225d34c1d148fda36ae73a281de6315557eb56 100644 (file)
@@ -287,6 +287,8 @@ class L3AgentSchedulerDbMixin(l3agentscheduler.L3AgentSchedulerPluginBase,
                 context, [router_id], new_agent.host)
 
     def list_routers_on_l3_agent(self, context, agent_id):
+        # Exception thrown if the requested agent does not exist.
+        self._get_agent(context, agent_id)
         query = context.session.query(RouterL3AgentBinding.router_id)
         query = query.filter(RouterL3AgentBinding.l3_agent_id == agent_id)
 
index c3e813e4c9913f8930fcb7ee644aebbe3a9e37a9..486960154c54971f799e94c3ab49b0d150b877a3 100644 (file)
@@ -1150,6 +1150,11 @@ class OvsAgentSchedulerTestCase(OvsAgentSchedulerTestCaseBase):
                 expected_code=exc.HTTPForbidden.code,
                 admin_context=False)
 
+    def test_list_routers_hosted_by_l3_agent_with_invalid_agent(self):
+        invalid_agentid = 'non_existent_agent'
+        self._list_routers_hosted_by_l3_agent(invalid_agentid,
+                                              exc.HTTPNotFound.code)
+
 
 class OvsDhcpAgentNotifierTestCase(test_l3_plugin.L3NatTestCaseMixin,
                                    test_agent_ext_plugin.AgentDBTestMixIn,