Skip to content

Commit 1be6c2d

Browse files
author
Huanxuan Ao
committed
Fix properties format for volume qos in volume v1
Notice that patch [1] fixed the error of properties format for volume qos in volume v2, but there is the same bug in volume v1, and the patch missed that, so fix the problem in v1 as well [1] https://review.openstack.org/#/c/421065/ Partial-Bug: #1656767 Change-Id: I156bf13d164dbd0d0a7ce394964176718c4ff0e5
1 parent bc4a3f4 commit 1be6c2d

3 files changed

Lines changed: 20 additions & 16 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def test_volume_qos_set_show_unset(self):
9494
)
9595
self.assertEqual(
9696
"Alpha='c', Beta='b'",
97-
cmd_output['specs']
97+
cmd_output['properties']
9898
)
9999

100100
# Test volume qos unset
@@ -115,7 +115,7 @@ def test_volume_qos_set_show_unset(self):
115115
)
116116
self.assertEqual(
117117
"Beta='b'",
118-
cmd_output['specs']
118+
cmd_output['properties']
119119
)
120120

121121
# TODO(qiangjiahui): Add tests for associate and disassociate volume type

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

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,23 +70,22 @@ 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-
datalist = (
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()
89-
82+
self.new_qos_spec = volume_fakes.FakeQos.create_one_qos()
83+
self.datalist = (
84+
self.new_qos_spec.consumer,
85+
self.new_qos_spec.id,
86+
self.new_qos_spec.name,
87+
utils.format_dict(self.new_qos_spec.specs)
88+
)
9089
self.qos_mock.create.return_value = self.new_qos_spec
9190
# Get the command object to test
9291
self.cmd = qos_specs.CreateQos(self.app, None)
@@ -336,7 +335,7 @@ def test_qos_list(self):
336335
'Name',
337336
'Consumer',
338337
'Associations',
339-
'Specs',
338+
'Properties',
340339
)
341340
self.assertEqual(collist, columns)
342341
datalist = ((
@@ -413,7 +412,7 @@ def test_qos_show(self):
413412
'consumer',
414413
'id',
415414
'name',
416-
'specs'
415+
'properties'
417416
)
418417
self.assertEqual(collist, columns)
419418
datalist = (

openstackclient/volume/v1/qos_specs.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ def take_action(self, parsed_args):
9494
specs.update(parsed_args.property)
9595

9696
qos_spec = volume_client.qos_specs.create(parsed_args.name, specs)
97-
97+
qos_spec._info.update(
98+
{'properties': utils.format_dict(qos_spec._info.pop('specs'))}
99+
)
98100
return zip(*sorted(six.iteritems(qos_spec._info)))
99101

100102

@@ -190,8 +192,10 @@ def take_action(self, parsed_args):
190192
for association in qos_associations]
191193
qos._info.update({'associations': associations})
192194

195+
display_columns = (
196+
'ID', 'Name', 'Consumer', 'Associations', 'Properties')
193197
columns = ('ID', 'Name', 'Consumer', 'Associations', 'Specs')
194-
return (columns,
198+
return (display_columns,
195199
(utils.get_dict_properties(
196200
s._info, columns,
197201
formatters={
@@ -254,7 +258,8 @@ def take_action(self, parsed_args):
254258
qos_spec._info.update({
255259
'associations': utils.format_list(associations)
256260
})
257-
qos_spec._info.update({'specs': utils.format_dict(qos_spec.specs)})
261+
qos_spec._info.update(
262+
{'properties': utils.format_dict(qos_spec._info.pop('specs'))})
258263

259264
return zip(*sorted(six.iteritems(qos_spec._info)))
260265

0 commit comments

Comments
 (0)