Skip to content

Commit 10f0300

Browse files
committed
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
1 parent 62938c0 commit 10f0300

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

openstackclient/common/module.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,15 @@ def take_action(self, parsed_args):
8686
# Handle xxxclient and openstacksdk
8787
(k.endswith('client') or k == 'openstack')):
8888
try:
89-
data[k] = mods[k].__version__
89+
# NOTE(RuiChen): openstacksdk bug/1588823 exist,
90+
# no good way to add __version__ for
91+
# openstack module properly, hard code
92+
# looks bad, but openstacksdk module
93+
# information is important.
94+
if k == 'openstack':
95+
data[k] = mods[k].version.__version__
96+
else:
97+
data[k] = mods[k].__version__
9098
except Exception:
9199
# Catch all exceptions, just skip it
92100
pass

openstackclient/tests/functional/common/test_module.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ class ModuleTest(base.TestCase):
2323

2424
CLIENTS = ['openstackclient',
2525
'keystoneclient',
26-
'novaclient']
26+
'novaclient',
27+
'openstack']
2728

2829
LIBS = ['osc_lib',
2930
'os_client_config',

openstackclient/tests/unit/fakes.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ class FakeModule(object):
161161
def __init__(self, name, version):
162162
self.name = name
163163
self.__version__ = version
164+
# Workaround for openstacksdk case
165+
self.version = mock.Mock()
166+
self.version.__version__ = version
164167

165168

166169
class FakeResource(object):

0 commit comments

Comments
 (0)