]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Return 404 when executing net-list-on-dhcp-agent with invalid agent_id
authorHirofumi Ichihara <ichihara.hirofumi@lab.ntt.co.jp>
Wed, 25 Feb 2015 09:02:35 +0000 (18:02 +0900)
committerHirofumi Ichihara <ichihara.hirofumi@lab.ntt.co.jp>
Thu, 12 Mar 2015 09:05:04 +0000 (18:05 +0900)
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

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

index e330b0fc390322e74a7d9693f2c5144322087a5a..7d1ee1f24baaf29e33b5f05545f28b017463b7fb 100644 (file)
@@ -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):
index b9dc54338a2e2e1f281dec9eb77a47b4a4c30aad..6fd7c12a0586eb6bd215a0a587606d010e8933c2 100644 (file)
@@ -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,