From f56ad38b83edc9f9601040b305228ae9afbc4018 Mon Sep 17 00:00:00 2001 From: wanghui Date: Fri, 9 Nov 2018 20:11:28 +0800 Subject: [PATCH] Refactor the getid method base.py Refer to a merged commit. https://review.openstack.org/#/c/588983/ Change-Id: Ied829d0a4f8bba79920320e028d37db7ba23491b --- zunclient/common/base.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/zunclient/common/base.py b/zunclient/common/base.py index c62060c2..368559d9 100644 --- a/zunclient/common/base.py +++ b/zunclient/common/base.py @@ -31,10 +31,7 @@ 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: - return obj.id - except AttributeError: - return obj + return getattr(obj, 'id', obj) class Manager(object):