From f29a849ffcc203e7038fd2a026e0f755dcf2c1fc Mon Sep 17 00:00:00 2001 From: Steve Martinelli Date: Thu, 18 Apr 2013 17:49:42 -0500 Subject: Finish up v3 role commands * Add remove role * Add --role to group list * Add --role to user list * Fix groups in AddRole() * Remove the tweaks to utils.find_resource for domains; will address that across domains, projects, users and groups in another patch. I want to nail down the structure of these commands and get that into place Change-Id: I8673dd8221ef88978dada5a2833c187026bdb31a --- openstackclient/common/utils.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'openstackclient/common') diff --git a/openstackclient/common/utils.py b/openstackclient/common/utils.py index 56f9cd17..06542887 100644 --- a/openstackclient/common/utils.py +++ b/openstackclient/common/utils.py @@ -24,20 +24,27 @@ from openstackclient.common import exceptions def find_resource(manager, name_or_id): """Helper for the _find_* methods.""" - # first try to get entity as integer id + + # Try to get entity as integer id try: if isinstance(name_or_id, int) or name_or_id.isdigit(): return manager.get(int(name_or_id)) except exceptions.NotFound: pass - # now try to get entity as uuid + # Try to get entity as uuid try: uuid.UUID(str(name_or_id)) return manager.get(name_or_id) except (ValueError, exceptions.NotFound): pass + # Try directly using the passed value + try: + return manager.get(name_or_id) + except Exception: + pass + kwargs = {} if 'NAME_ATTR' in manager.resource_class.__dict__: # novaclient does this for oddball resources -- cgit v1.2.1