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):