summaryrefslogtreecommitdiff
path: root/keystoneclient/base.py
diff options
context:
space:
mode:
Diffstat (limited to 'keystoneclient/base.py')
-rw-r--r--keystoneclient/base.py14
1 files changed, 4 insertions, 10 deletions
diff --git a/keystoneclient/base.py b/keystoneclient/base.py
index c466b1b..67edfb4 100644
--- a/keystoneclient/base.py
+++ b/keystoneclient/base.py
@@ -38,16 +38,10 @@ def getid(obj):
Abstracts the common pattern of allowing both an object or an object's ID
(UUID) as a parameter when dealing with relationships.
"""
- try:
- if obj.uuid:
- return obj.uuid
- except AttributeError: # nosec(cjschaef): 'obj' doesn't contain attribute
- # 'uuid', return attribute 'id' or the 'obj'
- pass
- try:
- return obj.id
- except AttributeError:
- return obj
+ if getattr(obj, 'uuid', None):
+ return obj.uuid
+ else:
+ return getattr(obj, 'id', obj)
def filter_none(**kwargs):