summaryrefslogtreecommitdiff
path: root/openstackclient/common/utils.py
diff options
context:
space:
mode:
authorDean Troyer <dtroyer@gmail.com>2012-05-11 17:19:08 -0500
committerDean Troyer <dtroyer@gmail.com>2012-05-15 15:48:11 -0500
commitd6a4fb836f7be64793f8d42b0a811eb81c50f455 (patch)
tree2442875620bd302a5a8a32188f0b6249982e6675 /openstackclient/common/utils.py
parentfd8197de6d8178ded323fd6e0bcc0c0b59ff30f3 (diff)
downloadpython-openstackclient-d6a4fb836f7be64793f8d42b0a811eb81c50f455.tar.gz
Update service commands
* add {create|delete} service * allow 'service' arg to also search type attribute in show command Change-Id: I992359dc95fab1fbdab0666d5cbb75e44ba6e0f3
Diffstat (limited to 'openstackclient/common/utils.py')
-rw-r--r--openstackclient/common/utils.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/openstackclient/common/utils.py b/openstackclient/common/utils.py
index b37ff806..475efeca 100644
--- a/openstackclient/common/utils.py
+++ b/openstackclient/common/utils.py
@@ -47,10 +47,17 @@ def find_resource(manager, name_or_id):
# finally try to find entity by name
try:
return manager.find(name=name_or_id)
- except exceptions.NotFound:
- msg = "No %s with a name or ID of '%s' exists." % \
- (manager.resource_class.__name__.lower(), name_or_id)
- raise exceptions.CommandError(msg)
+ # FIXME(dtroyer): The exception to catch here is dependent on which
+ # client library the manager passed in belongs to.
+ # Eventually this should be pulled from a common set
+ # of client exceptions.
+ except Exception as ex:
+ if '.NotFound' in type(ex).__name__:
+ msg = "No %s with a name or ID of '%s' exists." % \
+ (manager.resource_class.__name__.lower(), name_or_id)
+ raise exceptions.CommandError(msg)
+ else:
+ raise
def get_item_properties(item, fields, mixed_case_fields=[], formatters={}):