Skip to content

Commit f353253

Browse files
author
jiahui.qiang
committed
Error in the return of command 'volume qos create'
This patch fixed a 'volume qos create' display mistake in argument of 'specs'[1]. For command such as: $ openstack volume qos create hello [1]https://bugs.launchpad.net/python-openstackclient/+bug/1656767 Closes-bug:#1656767 Change-Id: Ia9fce833d318d9b52b97c12cfb89e2d3c5465fbe
1 parent 4d3cfb9 commit f353253

4 files changed

Lines changed: 31 additions & 17 deletions

File tree

openstackclient/tests/functional/volume/v2/test_qos.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ def test_volume_qos_metadata(self):
5050
raw_output = self.openstack(
5151
'volume qos set --property a=b --property c=d ' + self.ID)
5252
self.assertEqual("", raw_output)
53-
opts = self.get_opts(['name', 'specs'])
53+
opts = self.get_opts(['name', 'properties'])
5454
raw_output = self.openstack('volume qos show ' + self.ID + opts)
5555
self.assertEqual(self.NAME + "\na='b', c='d'\n", raw_output)
5656

5757
raw_output = self.openstack(
5858
'volume qos unset --property a ' + self.ID)
5959
self.assertEqual("", raw_output)
60-
opts = self.get_opts(['name', 'specs'])
60+
opts = self.get_opts(['name', 'properties'])
6161
raw_output = self.openstack('volume qos show ' + self.ID + opts)
6262
self.assertEqual(self.NAME + "\nc='d'\n", raw_output)

openstackclient/tests/unit/volume/v2/test_qos_specs.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,24 +70,26 @@ def test_qos_associate(self):
7070

7171
class TestQosCreate(TestQos):
7272

73-
new_qos_spec = volume_fakes.FakeQos.create_one_qos()
7473
columns = (
7574
'consumer',
7675
'id',
7776
'name',
78-
'specs'
79-
)
80-
data = (
81-
new_qos_spec.consumer,
82-
new_qos_spec.id,
83-
new_qos_spec.name,
84-
new_qos_spec.specs
77+
'properties'
8578
)
8679

8780
def setUp(self):
8881
super(TestQosCreate, self).setUp()
8982

83+
self.new_qos_spec = volume_fakes.FakeQos.create_one_qos()
9084
self.qos_mock.create.return_value = self.new_qos_spec
85+
86+
self.data = (
87+
self.new_qos_spec.consumer,
88+
self.new_qos_spec.id,
89+
self.new_qos_spec.name,
90+
utils.format_dict(self.new_qos_spec.specs)
91+
)
92+
9193
# Get the command object to test
9294
self.cmd = qos_specs.CreateQos(self.app, None)
9395

@@ -147,11 +149,11 @@ def test_qos_create_with_properties(self):
147149

148150
columns, data = self.cmd.take_action(parsed_args)
149151

150-
self.new_qos_spec.specs.update(
151-
{'consumer': self.new_qos_spec.consumer})
152152
self.qos_mock.create.assert_called_with(
153153
self.new_qos_spec.name,
154-
self.new_qos_spec.specs
154+
{'consumer': self.new_qos_spec.consumer,
155+
'foo': 'bar',
156+
'iops': '9001'}
155157
)
156158

157159
self.assertEqual(self.columns, columns)
@@ -307,7 +309,7 @@ class TestQosList(TestQos):
307309
'Name',
308310
'Consumer',
309311
'Associations',
310-
'Specs',
312+
'Properties',
311313
)
312314
data = []
313315
for q in qos_specs:
@@ -383,7 +385,7 @@ class TestQosShow(TestQos):
383385
'consumer',
384386
'id',
385387
'name',
386-
'specs'
388+
'properties'
387389
)
388390
data = (
389391
qos_association.name,

openstackclient/volume/v2/qos_specs.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ def take_action(self, parsed_args):
9595

9696
qos_spec = volume_client.qos_specs.create(parsed_args.name, specs)
9797

98+
qos_spec._info.update(
99+
{'properties': utils.format_dict(qos_spec._info.pop('specs'))}
100+
)
98101
return zip(*sorted(six.iteritems(qos_spec._info)))
99102

100103

@@ -190,8 +193,11 @@ def take_action(self, parsed_args):
190193
for association in qos_associations]
191194
qos._info.update({'associations': associations})
192195

196+
display_columns = (
197+
'ID', 'Name', 'Consumer', 'Associations', 'Properties')
198+
193199
columns = ('ID', 'Name', 'Consumer', 'Associations', 'Specs')
194-
return (columns,
200+
return (display_columns,
195201
(utils.get_dict_properties(
196202
s._info, columns,
197203
formatters={
@@ -254,7 +260,8 @@ def take_action(self, parsed_args):
254260
qos_spec._info.update({
255261
'associations': utils.format_list(associations)
256262
})
257-
qos_spec._info.update({'specs': utils.format_dict(qos_spec.specs)})
263+
qos_spec._info.update(
264+
{'properties': utils.format_dict(qos_spec._info.pop('specs'))})
258265

259266
return zip(*sorted(six.iteritems(qos_spec._info)))
260267

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
fixes:
3+
- |
4+
Fixed a ``volume qos create`` display mistake in argument of ``specs``.
5+
[Bug `1656767 <https://bugs.launchpad.net/python-openstackclient/+bug/1656767>`_]

0 commit comments

Comments
 (0)