diff options
Diffstat (limited to 'openstackclient/common/utils.py')
| -rw-r--r-- | openstackclient/common/utils.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/openstackclient/common/utils.py b/openstackclient/common/utils.py index 76532fcb..8a792675 100644 --- a/openstackclient/common/utils.py +++ b/openstackclient/common/utils.py @@ -38,9 +38,16 @@ def find_resource(manager, name_or_id): except (ValueError, exceptions.NotFound): pass + kwargs = {} + if 'NAME_ATTR' in manager.resource_class.__dict__: + # novaclient does this for oddball resources + kwargs[manager.resource_class.NAME_ATTR] = name_or_id + else: + kwargs['name'] = name_or_id + # finally try to find entity by name try: - return manager.find(name=name_or_id) + return manager.find(**kwargs) # 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 |
