From e9021c213b0f98195920e63aa573c040d5a3cf6d Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Sun, 14 Apr 2013 17:02:45 -0500 Subject: Add fixed-ip and floating-ip commands Adds: * fixed-ip commands: add, remove * floating-ip commands: add, create, delete, list, remove * floating-ip-poo command: list Also uses NAME_ATTR in the Resource class if present to determine the attribute to be used for searching in utils.find_resource() Change-Id: Ifd8fa60f880fc4050dea182ac24553cc2c4bff15 --- openstackclient/common/utils.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'openstackclient/common/utils.py') 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 -- cgit v1.2.1