From: Hirofumi Ichihara Date: Wed, 25 Feb 2015 09:02:35 +0000 (+0900) Subject: Return 404 when executing net-list-on-dhcp-agent with invalid agent_id X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=dc4268b8547ba9416c3c1de4fb41597ab9d5a6df;p=openstack-build%2Fneutron-build.git Return 404 when executing net-list-on-dhcp-agent with invalid agent_id Neutron server returns HTTP code 200 when users execute net-list-on-dhcp-agent with invalid agent_id. Users expect HTTP code 404 to be returned. Change-Id: I41652a9bf4a81835abb6646ea870781472757623 Closes-bug: 1425138 --- diff --git a/neutron/db/agentschedulers_db.py b/neutron/db/agentschedulers_db.py index e330b0fc3..7d1ee1f24 100644 --- a/neutron/db/agentschedulers_db.py +++ b/neutron/db/agentschedulers_db.py @@ -370,6 +370,8 @@ class DhcpAgentSchedulerDbMixin(dhcpagentscheduler return {'networks': self.get_networks(context, filters={'id': net_ids})} else: + # Exception will be thrown if the requested agent does not exist. + self._get_agent(context, id) return {'networks': []} def list_active_networks_on_active_dhcp_agent(self, context, host): diff --git a/neutron/tests/unit/openvswitch/test_agent_scheduler.py b/neutron/tests/unit/openvswitch/test_agent_scheduler.py index b9dc54338..6fd7c12a0 100644 --- a/neutron/tests/unit/openvswitch/test_agent_scheduler.py +++ b/neutron/tests/unit/openvswitch/test_agent_scheduler.py @@ -1175,10 +1175,15 @@ class OvsAgentSchedulerTestCase(OvsAgentSchedulerTestCaseBase): admin_context=False) def test_list_routers_hosted_by_l3_agent_with_invalid_agent(self): - invalid_agentid = 'non_existent_agent' + invalid_agentid = 'non_existing_agent' self._list_routers_hosted_by_l3_agent(invalid_agentid, exc.HTTPNotFound.code) + def test_list_networks_hosted_by_dhcp_agent_with_invalid_agent(self): + invalid_agentid = 'non_existing_agent' + self._list_networks_hosted_by_dhcp_agent(invalid_agentid, + exc.HTTPNotFound.code) + class OvsDhcpAgentNotifierTestCase(test_l3_plugin.L3NatTestCaseMixin, test_agent_ext_plugin.AgentDBTestMixIn,