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
This commit is contained in:
Rui Chen 2017-02-22 16:18:56 +08:00
parent 62938c02e0
commit 10f0300f70
3 changed files with 14 additions and 2 deletions

View File

@ -86,6 +86,14 @@ class ListModule(command.ShowOne):
# Handle xxxclient and openstacksdk
(k.endswith('client') or k == 'openstack')):
try:
# 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

View File

@ -23,7 +23,8 @@ class ModuleTest(base.TestCase):
CLIENTS = ['openstackclient',
'keystoneclient',
'novaclient']
'novaclient',
'openstack']
LIBS = ['osc_lib',
'os_client_config',

View File

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