diff options
| author | Adam Gandelman <adamg@ubuntu.com> | 2014-09-22 17:04:47 -0700 |
|---|---|---|
| committer | Adam Gandelman <adamg@ubuntu.com> | 2014-12-12 16:05:56 -0800 |
| commit | a90a669c9c03d6bdbecaef8fad162b73d8d0fa9f (patch) | |
| tree | 9d1a3f5385a4b6c03784da1cf1554b0fa24dab4b /troveclient/utils.py | |
| parent | 6f8b0d09bdcd0f627b8b5e6227e2d6232d9dbf78 (diff) | |
| download | python-troveclient-a90a669c9c03d6bdbecaef8fad162b73d8d0fa9f.tar.gz | |
Fallback to flavor's str_id when id is None
When a nova flavor's id is a string and not an int, Trove will
return None for the flavor's id and instead expect clients
to use the str_id field. This updates the shell mask this
from the user and always present the relevant value as id, and
allow specifying either str_id or id for flavor-show.
find_resource() was updated to deal with ints and strings, not just
UUIDs and ints.
Relies on changes to Trove @ https://review.openstack.org/#/c/115811
Related-bug: #1333852
Change-Id: If08430b07b7e8b6a1737f3e71dba6a471de63794
Diffstat (limited to 'troveclient/utils.py')
| -rw-r--r-- | troveclient/utils.py | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/troveclient/utils.py b/troveclient/utils.py index 9210d6d..67b600c 100644 --- a/troveclient/utils.py +++ b/troveclient/utils.py @@ -205,20 +205,15 @@ def print_dict(d, property="Property"): def find_resource(manager, name_or_id): """Helper for the _find_* methods.""" # first 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 - if sys.version_info <= (3, 0): + if isinstance(name_or_id, int) or name_or_id.isdigit(): + name_or_id = int(name_or_id) + elif sys.version_info <= (3, 0): name_or_id = strutils.safe_decode(name_or_id) - # now try to get entity as uuid try: - uuid.UUID(name_or_id) return manager.get(name_or_id) - except (ValueError, exceptions.NotFound): + except exceptions.NotFound: pass try: |
