From 045f641cec19c6d2826ef20e3ed1409b1991836f Mon Sep 17 00:00:00 2001 From: Takashi NATSUME Date: Mon, 6 Aug 2018 01:20:38 +0900 Subject: [PATCH] Refactor the getid method in novaclient/base.py TrivialFix Change-Id: I30aa4cea658bd3b96f9e7e3d7037232fed8d3749 --- novaclient/base.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/novaclient/base.py b/novaclient/base.py index 3bf61856b..40e100a9d 100644 --- a/novaclient/base.py +++ b/novaclient/base.py @@ -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