Refactor the getid method in novaclient/base.py

TrivialFix
Change-Id: I30aa4cea658bd3b96f9e7e3d7037232fed8d3749
This commit is contained in:
Takashi NATSUME 2018-08-06 01:20:38 +09:00
parent 1f75c7662d
commit 045f641cec
1 changed files with 1 additions and 4 deletions

View File

@ -41,10 +41,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)
# TODO(aababilov): call run_hooks() in HookableMixin's child classes