Use the oslo.utils.reflection to extract the class name

The oslo.utils reflection module/code handles more variations
 of where a class name may come from (on python 2 and python 3)
so its usage allows getting more accurate class names so we might
as well use it.

Change-Id: I7b130d6acb183a06a4efe648ee2c3fbd2905cdd5
This commit is contained in:
LiuNanke 2016-01-08 15:48:00 +08:00
parent fa7d8f4b9f
commit 416457de4d
2 changed files with 8 additions and 2 deletions

View File

@ -22,6 +22,7 @@ Base utilities to build API operation managers and objects on top of.
import contextlib
import hashlib
import os
from oslo_utils import reflection
from troveclient.compat import exceptions
from troveclient.compat import utils
@ -264,7 +265,9 @@ class Resource(object):
reprkeys = sorted(k for k in self.__dict__.keys()
if k[0] != '_' and k != 'manager')
info = ", ".join("%s=%s" % (k, getattr(self, k)) for k in reprkeys)
return "<%s %s>" % (self.__class__.__name__, info)
self_cls_name = reflection.get_class_name(self,
fully_qualified=False)
return "<%s %s>" % (self_cls_name, info)
def get(self):
# set_loaded() first ... so if we have to bail, we know we tried.

View File

@ -26,6 +26,7 @@ Base utilities to build API operation managers and objects on top of.
import abc
import copy
from oslo_utils import reflection
import six
from six.moves.urllib import parse
@ -435,7 +436,9 @@ class Resource(object):
for k in self.__dict__.keys()
if k[0] != '_' and k != 'manager')
info = ", ".join("%s=%s" % (k, getattr(self, k)) for k in reprkeys)
return "<%s %s>" % (self.__class__.__name__, info)
self_cls_name = reflection.get_class_name(self,
fully_qualified=False)
return "<%s %s>" % (self_cls_name, info)
@property
def human_id(self):