From 10f0300f704ca8dd5928d9a8b41ac6c16732f203 Mon Sep 17 00:00:00 2001 From: Rui Chen Date: Wed, 22 Feb 2017 16:18:56 +0800 Subject: [PATCH] Show openstacksdk version info in "module list" openstacksdk bug/1588823 exist, no good way to add __version__ for openstack module properly, fix the issue in osc side, make openstacksdk module information be available. Change-Id: I27ff61792443d1aa07f31598bed3aa32f924ff40 Partial-Bug: #1662058 --- openstackclient/common/module.py | 10 +++++++++- openstackclient/tests/functional/common/test_module.py | 3 ++- openstackclient/tests/unit/fakes.py | 3 +++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/openstackclient/common/module.py b/openstackclient/common/module.py index f471b2aa02..ba911ecb8f 100644 --- a/openstackclient/common/module.py +++ b/openstackclient/common/module.py @@ -86,7 +86,15 @@ class ListModule(command.ShowOne): # Handle xxxclient and openstacksdk (k.endswith('client') or k == 'openstack')): try: - data[k] = mods[k].__version__ + # NOTE(RuiChen): openstacksdk bug/1588823 exist, + # no good way to add __version__ for + # openstack module properly, hard code + # looks bad, but openstacksdk module + # information is important. + if k == 'openstack': + data[k] = mods[k].version.__version__ + else: + data[k] = mods[k].__version__ except Exception: # Catch all exceptions, just skip it pass diff --git a/openstackclient/tests/functional/common/test_module.py b/openstackclient/tests/functional/common/test_module.py index b56c83ad24..f4f2e95215 100644 --- a/openstackclient/tests/functional/common/test_module.py +++ b/openstackclient/tests/functional/common/test_module.py @@ -23,7 +23,8 @@ class ModuleTest(base.TestCase): CLIENTS = ['openstackclient', 'keystoneclient', - 'novaclient'] + 'novaclient', + 'openstack'] LIBS = ['osc_lib', 'os_client_config', diff --git a/openstackclient/tests/unit/fakes.py b/openstackclient/tests/unit/fakes.py index 626b466d35..f28f9103d9 100644 --- a/openstackclient/tests/unit/fakes.py +++ b/openstackclient/tests/unit/fakes.py @@ -161,6 +161,9 @@ class FakeModule(object): def __init__(self, name, version): self.name = name self.__version__ = version + # Workaround for openstacksdk case + self.version = mock.Mock() + self.version.__version__ = version class FakeResource(object):