summaryrefslogtreecommitdiff
path: root/cinderclient
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-10-03 15:51:25 +0000
committerGerrit Code Review <review@openstack.org>2018-10-03 15:51:25 +0000
commitc73844df2dc1c02637235babb22cd263eaa45a5b (patch)
tree501a41cfdc7e43b1bfdef9128e77060c970d182f /cinderclient
parente9658c6ef65d3f4d6d36774140b10aeec0dc67b9 (diff)
parent42b598d1098d3ee3eb403d606252bab6cc130bd5 (diff)
downloadpython-cinderclient-c73844df2dc1c02637235babb22cd263eaa45a5b.tar.gz
Merge "refactor the getid method base.py"
Diffstat (limited to 'cinderclient')
-rw-r--r--cinderclient/apiclient/base.py13
-rw-r--r--cinderclient/base.py5
2 files changed, 5 insertions, 13 deletions
diff --git a/cinderclient/apiclient/base.py b/cinderclient/apiclient/base.py
index e1f611c..9011d8f 100644
--- a/cinderclient/apiclient/base.py
+++ b/cinderclient/apiclient/base.py
@@ -41,15 +41,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:
- pass
- try:
- return obj.id
- except AttributeError:
- return obj
+ if getattr(obj, 'uuid', None):
+ return obj.uuid
+ else:
+ return getattr(obj, 'id', obj)
# TODO(aababilov): call run_hooks() in HookableMixin's child classes
diff --git a/cinderclient/base.py b/cinderclient/base.py
index 5f6fb25..44d1149 100644
--- a/cinderclient/base.py
+++ b/cinderclient/base.py
@@ -53,10 +53,7 @@ def getid(obj):
Abstracts the common pattern of allowing both an object or an object's ID
as a parameter when dealing with relationships.
"""
- try:
- return obj.id
- except AttributeError:
- return obj
+ return getattr(obj, 'id', obj)
class Manager(common_base.HookableMixin):