From d6a4fb836f7be64793f8d42b0a811eb81c50f455 Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Fri, 11 May 2012 17:19:08 -0500 Subject: Update service commands * add {create|delete} service * allow 'service' arg to also search type attribute in show command Change-Id: I992359dc95fab1fbdab0666d5cbb75e44ba6e0f3 --- openstackclient/common/utils.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'openstackclient/common') 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={}): -- cgit v1.2.1