From 70b58cff5c43f0c66168b51fc2584af6b9dec955 Mon Sep 17 00:00:00 2001 From: David Shrewsbury Date: Mon, 26 Jan 2015 16:45:18 -0500 Subject: [PATCH] Fix obj_to_dict type filtering Commit 88f5f2661ee2ba31056251b4cdf91949fca0a031 fixed the python 3 unit tests, but broke obj_to_dict() because client classes were no longer being filtered out (like nova's ServerManager class). Trying to remove these by using inspect.isclass() does not work as it does not recognize these types as classes (perhaps b/c they are being serialized?). This change reverts to the old style behaviour, but uses the six class to fix python3 compatibility. Change-Id: Ief7bba30d983f67cd28d886cd1d3dfd2a45e957d --- requirements.txt | 1 + shade/meta.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index c284bfde6..a4fac76d3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,7 @@ pbr>=0.5.21,<1.0 os-client-config +six python-novaclient python-keystoneclient>=0.11.0 diff --git a/shade/meta.py b/shade/meta.py index c0baa0078..992247ec3 100644 --- a/shade/meta.py +++ b/shade/meta.py @@ -13,6 +13,11 @@ # limitations under the License. +import six + +NON_CALLABLES = (six.string_types, bool, dict, int, list, type(None)) + + def find_nova_addresses(addresses, ext_tag=None, key_name=None, version=4): ret = [] @@ -133,6 +138,6 @@ def obj_to_dict(obj): instance = {} for key in dir(obj): value = getattr(obj, key) - if not callable(value) and not key.startswith('_'): + if isinstance(value, NON_CALLABLES) and not key.startswith('_'): instance[key] = value return instance