refactor the getid method in keystoneclient/base.py
Refer to a merged commit. https://review.openstack.org/#/c/588983/ TrivialFix Change-Id: Ie3a02843e35382dd24230e91534b6ed72846957d
This commit is contained in:
@@ -38,16 +38,10 @@ def getid(obj):
|
|||||||
Abstracts the common pattern of allowing both an object or an object's ID
|
Abstracts the common pattern of allowing both an object or an object's ID
|
||||||
(UUID) as a parameter when dealing with relationships.
|
(UUID) as a parameter when dealing with relationships.
|
||||||
"""
|
"""
|
||||||
try:
|
if getattr(obj, 'uuid', None):
|
||||||
if obj.uuid:
|
|
||||||
return obj.uuid
|
return obj.uuid
|
||||||
except AttributeError: # nosec(cjschaef): 'obj' doesn't contain attribute
|
else:
|
||||||
# 'uuid', return attribute 'id' or the 'obj'
|
return getattr(obj, 'id', obj)
|
||||||
pass
|
|
||||||
try:
|
|
||||||
return obj.id
|
|
||||||
except AttributeError:
|
|
||||||
return obj
|
|
||||||
|
|
||||||
|
|
||||||
def filter_none(**kwargs):
|
def filter_none(**kwargs):
|
||||||
|
Reference in New Issue
Block a user