summaryrefslogtreecommitdiff
path: root/openstackclient/common/utils.py
diff options
context:
space:
mode:
authorHidekazu Nakamura <hid-nakamura@vf.jp.nec.com>2015-11-06 00:47:38 +0900
committerMatthew Edmonds <edmondsw@us.ibm.com>2016-04-01 16:44:33 -0400
commit55b37d5e33f322077303a895d3453320b3895f11 (patch)
tree5143fab5ee694bc960253006ede8f4b172ccbb35 /openstackclient/common/utils.py
parent061037aaf1817f1da2da87081c1b2bc1e479e2ad (diff)
downloadpython-openstackclient-55b37d5e33f322077303a895d3453320b3895f11.tar.gz
Don't mask authorization errors
Project show with name argument returns 'Could not find resource' error when the user is not authorized. It should report the authorization error instead. This patch makes that change. Change-Id: Iac3521f8a411060b0ec9ef46c8f0e1f3551e56ae Closes-Bug: #1511625
Diffstat (limited to 'openstackclient/common/utils.py')
-rw-r--r--openstackclient/common/utils.py25
1 files changed, 9 insertions, 16 deletions
diff --git a/openstackclient/common/utils.py b/openstackclient/common/utils.py
index c6ed6a71..daa65c25 100644
--- a/openstackclient/common/utils.py
+++ b/openstackclient/common/utils.py
@@ -100,22 +100,15 @@ def find_resource(manager, name_or_id, **kwargs):
else:
pass
- try:
- for resource in manager.list():
- # short circuit and return the first match
- if (resource.get('id') == name_or_id or
- resource.get('name') == name_or_id):
- return resource
- else:
- # we found no match, keep going to bomb out
- pass
- except Exception:
- # in case the list fails for some reason
- pass
-
- # if we hit here, we've failed, report back this error:
- msg = "Could not find resource %s" % name_or_id
- raise exceptions.CommandError(msg)
+ for resource in manager.list():
+ # short circuit and return the first match
+ if (resource.get('id') == name_or_id or
+ resource.get('name') == name_or_id):
+ return resource
+ else:
+ # we found no match, report back this error:
+ msg = "Could not find resource %s" % name_or_id
+ raise exceptions.CommandError(msg)
def format_dict(data):