From a147631309cfc57f47f74fc9721f07db85d3fe65 Mon Sep 17 00:00:00 2001 From: Nikolas Hermanns Date: Fri, 12 Feb 2016 11:21:25 +0100 Subject: [PATCH] Misleading output when network is not found Output is: Unable to find network with name '7ea795c9-0b72-4585-bd91-9bf83c0d1c80' Output should be: Unable to find network with name or id Someone could think that the net id is not checked. Closes-Bug: #1544907 Change-Id: I6999ab4e07a58751a9860764447c00fe7bf8ee81 --- neutronclient/neutron/v2_0/__init__.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/neutronclient/neutron/v2_0/__init__.py b/neutronclient/neutron/v2_0/__init__.py index f3f4669..d740aac 100644 --- a/neutronclient/neutron/v2_0/__init__.py +++ b/neutronclient/neutron/v2_0/__init__.py @@ -118,9 +118,17 @@ def find_resource_by_name_or_id(client, resource, name_or_id, return find_resource_by_id(client, resource, name_or_id, cmd_resource, parent_id, fields) except exceptions.NotFound: - return _find_resource_by_name(client, resource, name_or_id, - project_id, cmd_resource, parent_id, - fields) + try: + return _find_resource_by_name(client, resource, name_or_id, + project_id, cmd_resource, parent_id, + fields) + except exceptions.NotFound: + not_found_message = (_("Unable to find %(resource)s with name " + "or id '%(name_or_id)s'") % + {'resource': resource, + 'name_or_id': name_or_id}) + raise exceptions.NotFound( + message=not_found_message) def find_resourceid_by_name_or_id(client, resource, name_or_id,