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
This commit is contained in:
Hirofumi Ichihara 2015-02-25 18:02:35 +09:00
parent d479b47938
commit dc4268b854
2 changed files with 8 additions and 1 deletions

View 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):

View 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,