diff --git a/neutronclient/neutron/v2_0/__init__.py b/neutronclient/neutron/v2_0/__init__.py index 34c5592af..702a50ce7 100644 --- a/neutronclient/neutron/v2_0/__init__.py +++ b/neutronclient/neutron/v2_0/__init__.py @@ -68,9 +68,8 @@ def find_resource_by_id(client, resource, resource_id, cmd_resource=None, not_found_message = (_("Unable to find %(resource)s with id " "'%(id)s'") % {'resource': resource, 'id': resource_id}) - # 404 is used to simulate server side behavior - raise exceptions.NeutronClientException( - message=not_found_message, status_code=404) + # 404 is raised by exceptions.NotFound to simulate serverside behavior + raise exceptions.NotFound(message=not_found_message) def find_resourceid_by_id(client, resource, resource_id, cmd_resource=None, @@ -105,9 +104,8 @@ def _find_resource_by_name(client, resource, name, project_id=None, not_found_message = (_("Unable to find %(resource)s with name " "'%(name)s'") % {'resource': resource, 'name': name}) - # 404 is used to simulate server side behavior - raise exceptions.NeutronClientException( - message=not_found_message, status_code=404) + # 404 is raised by exceptions.NotFound to simulate serverside behavior + raise exceptions.NotFound(message=not_found_message) else: return info[0] @@ -118,7 +116,7 @@ def find_resource_by_name_or_id(client, resource, name_or_id, try: return find_resource_by_id(client, resource, name_or_id, cmd_resource, parent_id, fields) - except exceptions.NeutronClientException: + except exceptions.NotFound: return _find_resource_by_name(client, resource, name_or_id, project_id, cmd_resource, parent_id, fields) diff --git a/neutronclient/tests/unit/test_name_or_id.py b/neutronclient/tests/unit/test_name_or_id.py index 412c45515..47b6b9b21 100644 --- a/neutronclient/tests/unit/test_name_or_id.py +++ b/neutronclient/tests/unit/test_name_or_id.py @@ -144,7 +144,7 @@ class CLITestNameorID(testtools.TestCase): try: neutronV20.find_resourceid_by_name_or_id( self.client, 'network', name) - except exceptions.NeutronClientException as ex: + except exceptions.NotFound as ex: self.assertIn('Unable to find', ex.message) self.assertEqual(404, ex.status_code) @@ -193,6 +193,6 @@ class CLITestNameorID(testtools.TestCase): try: neutronV20.find_resourceid_by_name_or_id( self.client, 'security_group', name, project) - except exceptions.NeutronClientException as ex: + except exceptions.NotFound as ex: self.assertIn('Unable to find', ex.message) self.assertEqual(404, ex.status_code)