Skip to content

Commit c5524c8

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Replace "Display Name" by "Name" in volume list"
2 parents adac738 + 6aceca2 commit c5524c8

9 files changed

Lines changed: 266 additions & 33 deletions

File tree

doc/source/backwards-incompatible.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,27 @@ Backwards Incompatible Changes
2727
.. * Remove in: <5.0>
2828
.. * Commit: <tbd>
2929
30+
Release 3.12.0
31+
--------------
32+
33+
1. Replace ``Display Name`` by ``Name`` in volume list.
34+
35+
Change column name ``Display Name`` to ``Name`` in ``volume list`` output.
36+
Current ``volume list --name`` command uses ``display_name`` as search_opts
37+
to send to cinder API, and show the result table with ``Display Name``
38+
as column title. Replace all ``Display Name`` by ``Name`` to be consistent
39+
with other list commands.
40+
41+
Support a mapping for volume list -c ``Display Name`` (Volume v1 and v2)
42+
and volume create/show -c ``display_name`` (Volume v1) to maintain backward
43+
compatibility until the next major release.
44+
45+
* In favor of: ``openstack volume list -c Name``
46+
* As of: 3.12.0
47+
* Removed in: n/a
48+
* Bug: https://bugs.launchpad.net/python-openstackclient/+bug/1657956
49+
* Commit: https://review.openstack.org/#/c/423081/
50+
3051
Release 3.10
3152
------------
3253

@@ -62,6 +83,7 @@ Release 3.0
6283
* Bug: n/a
6384
* Commit: https://review.openstack.org/332938
6485

86+
6587
Releases Before 3.0
6688
-------------------
6789

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def setUpClass(cls):
2727
super(TransferRequestTests, cls).setUpClass()
2828
cmd_output = json.loads(cls.openstack(
2929
'volume create -f json --size 1 ' + cls.VOLUME_NAME))
30-
cls.assertOutput(cls.VOLUME_NAME, cmd_output['display_name'])
30+
cls.assertOutput(cls.VOLUME_NAME, cmd_output['name'])
3131

3232
cmd_output = json.loads(cls.openstack(
3333
'volume transfer request create -f json ' +
@@ -51,7 +51,7 @@ def test_volume_transfer_request_accept(self):
5151
# create a volume
5252
cmd_output = json.loads(self.openstack(
5353
'volume create -f json --size 1 ' + volume_name))
54-
self.assertEqual(volume_name, cmd_output['display_name'])
54+
self.assertEqual(volume_name, cmd_output['name'])
5555

5656
# create volume transfer request for the volume
5757
# and get the auth_key of the new transfer request

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

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def test_volume_list(self):
8181
cmd_output = json.loads(self.openstack(
8282
'volume list -f json '
8383
))
84-
names = [x["Display Name"] for x in cmd_output]
84+
names = [x["Name"] for x in cmd_output]
8585
self.assertIn(name1, names)
8686
self.assertIn(name2, names)
8787

@@ -97,7 +97,7 @@ def test_volume_list(self):
9797
'volume list -f json ' +
9898
'--name ' + name1
9999
))
100-
names = [x["Display Name"] for x in cmd_output]
100+
names = [x["Name"] for x in cmd_output]
101101
self.assertIn(name1, names)
102102
self.assertNotIn(name2, names)
103103

@@ -113,7 +113,7 @@ def test_volume_set_and_unset(self):
113113
))
114114
self.assertEqual(
115115
name,
116-
cmd_output["display_name"],
116+
cmd_output["name"],
117117
)
118118
self.assertEqual(
119119
1,
@@ -155,7 +155,7 @@ def test_volume_set_and_unset(self):
155155
))
156156
self.assertEqual(
157157
new_name,
158-
cmd_output["display_name"],
158+
cmd_output["name"],
159159
)
160160
self.assertEqual(
161161
2,
@@ -191,6 +191,49 @@ def test_volume_set_and_unset(self):
191191
cmd_output["properties"],
192192
)
193193

194+
def test_volume_create_and_list_and_show_backward_compatibility(self):
195+
"""Test backward compatibility of create, list, show"""
196+
name1 = uuid.uuid4().hex
197+
json_output = json.loads(self.openstack(
198+
'volume create -f json ' +
199+
'-c display_name -c id ' +
200+
'--size 1 ' +
201+
name1
202+
))
203+
self.assertIn('display_name', json_output)
204+
self.assertEqual(name1, json_output['display_name'])
205+
self.assertIn('id', json_output)
206+
volume_id = json_output['id']
207+
self.assertIsNotNone(volume_id)
208+
self.assertNotIn('name', json_output)
209+
self.addCleanup(self.openstack, 'volume delete ' + volume_id)
210+
211+
self.wait_for("volume", name1, "available")
212+
213+
json_output = json.loads(self.openstack(
214+
'volume list -f json ' +
215+
'-c "Display Name"'
216+
))
217+
for each_volume in json_output:
218+
self.assertIn('Display Name', each_volume)
219+
220+
json_output = json.loads(self.openstack(
221+
'volume list -f json ' +
222+
'-c "Name"'
223+
))
224+
for each_volume in json_output:
225+
self.assertIn('Name', each_volume)
226+
227+
json_output = json.loads(self.openstack(
228+
'volume show -f json ' +
229+
'-c display_name -c id ' +
230+
name1
231+
))
232+
self.assertIn('display_name', json_output)
233+
self.assertEqual(name1, json_output['display_name'])
234+
self.assertIn('id', json_output)
235+
self.assertNotIn('name', json_output)
236+
194237
def wait_for(self, check_type, check_name, desired_status, wait=120,
195238
interval=5, failures=['ERROR']):
196239
status = "notset"

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

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def test_volume_list(self):
9090
'volume list -f json ' +
9191
'--long'
9292
))
93-
names = [x["Display Name"] for x in cmd_output]
93+
names = [x["Name"] for x in cmd_output]
9494
self.assertIn(name1, names)
9595
self.assertIn(name2, names)
9696

@@ -99,7 +99,7 @@ def test_volume_list(self):
9999
'volume list -f json ' +
100100
'--status error'
101101
))
102-
names = [x["Display Name"] for x in cmd_output]
102+
names = [x["Name"] for x in cmd_output]
103103
self.assertNotIn(name1, names)
104104
self.assertIn(name2, names)
105105

@@ -249,6 +249,37 @@ def test_volume_snapshot(self):
249249
'volume snapshot delete ' + snapshot_name)
250250
self.assertOutput('', raw_output)
251251

252+
def test_volume_list_backward_compatibility(self):
253+
"""Test backward compatibility of list command"""
254+
name1 = uuid.uuid4().hex
255+
cmd_output = json.loads(self.openstack(
256+
'volume create -f json ' +
257+
'--size 1 ' +
258+
name1
259+
))
260+
self.addCleanup(self.openstack, 'volume delete ' + name1)
261+
self.assertEqual(
262+
1,
263+
cmd_output["size"],
264+
)
265+
self.wait_for("volume", name1, "available")
266+
267+
# Test list -c "Display Name"
268+
cmd_output = json.loads(self.openstack(
269+
'volume list -f json ' +
270+
'-c "Display Name"'
271+
))
272+
for each_volume in cmd_output:
273+
self.assertIn('Display Name', each_volume)
274+
275+
# Test list -c "Name"
276+
cmd_output = json.loads(self.openstack(
277+
'volume list -f json ' +
278+
'-c "Name"'
279+
))
280+
for each_volume in cmd_output:
281+
self.assertIn('Name', each_volume)
282+
252283
def wait_for(self, check_type, check_name, desired_status, wait=120,
253284
interval=5, failures=['ERROR']):
254285
status = "notset"

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

Lines changed: 78 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ class TestVolumeCreate(TestVolume):
6868
'bootable',
6969
'created_at',
7070
'display_description',
71-
'display_name',
7271
'id',
72+
'name',
7373
'properties',
7474
'size',
7575
'snapshot_id',
@@ -86,8 +86,8 @@ def setUp(self):
8686
self.new_volume.bootable,
8787
self.new_volume.created_at,
8888
self.new_volume.display_description,
89-
self.new_volume.display_name,
9089
self.new_volume.id,
90+
self.new_volume.display_name,
9191
utils.format_dict(self.new_volume.metadata),
9292
self.new_volume.size,
9393
self.new_volume.snapshot_id,
@@ -598,6 +598,38 @@ def test_volume_create_with_multi_source(self):
598598
self.assertRaises(tests_utils.ParserException, self.check_parser,
599599
self.cmd, arglist, verifylist)
600600

601+
def test_volume_create_backward_compatibility(self):
602+
arglist = [
603+
'-c', 'display_name',
604+
'--size', str(self.new_volume.size),
605+
self.new_volume.display_name,
606+
]
607+
verifylist = [
608+
('columns', ['display_name']),
609+
('size', self.new_volume.size),
610+
('name', self.new_volume.display_name),
611+
]
612+
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
613+
614+
columns, data = self.cmd.take_action(parsed_args)
615+
616+
self.volumes_mock.create.assert_called_with(
617+
self.new_volume.size,
618+
None,
619+
None,
620+
self.new_volume.display_name,
621+
None,
622+
None,
623+
None,
624+
None,
625+
None,
626+
None,
627+
None,
628+
)
629+
self.assertIn('display_name', columns)
630+
self.assertNotIn('name', columns)
631+
self.assertIn(self.new_volume.display_name, data)
632+
601633

602634
class TestVolumeDelete(TestVolume):
603635

@@ -695,7 +727,7 @@ class TestVolumeList(TestVolume):
695727
_volume = volume_fakes.FakeVolume.create_one_volume()
696728
columns = (
697729
'ID',
698-
'Display Name',
730+
'Name',
699731
'Status',
700732
'Size',
701733
'Attached to',
@@ -806,7 +838,7 @@ def test_volume_list_long(self):
806838

807839
collist = (
808840
'ID',
809-
'Display Name',
841+
'Name',
810842
'Status',
811843
'Size',
812844
'Type',
@@ -863,6 +895,27 @@ def test_volume_list_negative_limit(self):
863895
self.assertRaises(argparse.ArgumentTypeError, self.check_parser,
864896
self.cmd, arglist, verifylist)
865897

898+
def test_volume_list_backward_compatibility(self):
899+
arglist = [
900+
'-c', 'Display Name',
901+
]
902+
verifylist = [
903+
('columns', ['Display Name']),
904+
('long', False),
905+
('all_projects', False),
906+
('name', None),
907+
('status', None),
908+
('limit', None),
909+
]
910+
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
911+
912+
columns, data = self.cmd.take_action(parsed_args)
913+
914+
self.assertIn('Display Name', columns)
915+
self.assertNotIn('Name', columns)
916+
for each_volume in data:
917+
self.assertIn(self._volume.display_name, each_volume)
918+
866919

867920
class TestVolumeMigrate(TestVolume):
868921

@@ -1178,8 +1231,8 @@ class TestVolumeShow(TestVolume):
11781231
'bootable',
11791232
'created_at',
11801233
'display_description',
1181-
'display_name',
11821234
'id',
1235+
'name',
11831236
'properties',
11841237
'size',
11851238
'snapshot_id',
@@ -1196,8 +1249,8 @@ def setUp(self):
11961249
self._volume.bootable,
11971250
self._volume.created_at,
11981251
self._volume.display_description,
1199-
self._volume.display_name,
12001252
self._volume.id,
1253+
self._volume.display_name,
12011254
utils.format_dict(self._volume.metadata),
12021255
self._volume.size,
12031256
self._volume.snapshot_id,
@@ -1223,6 +1276,25 @@ def test_volume_show(self):
12231276
self.assertEqual(self.columns, columns)
12241277
self.assertEqual(self.datalist, data)
12251278

1279+
def test_volume_show_backward_compatibility(self):
1280+
arglist = [
1281+
'-c', 'display_name',
1282+
self._volume.id,
1283+
]
1284+
verifylist = [
1285+
('columns', ['display_name']),
1286+
('volume', self._volume.id),
1287+
]
1288+
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
1289+
1290+
columns, data = self.cmd.take_action(parsed_args)
1291+
1292+
self.volumes_mock.get.assert_called_with(self._volume.id)
1293+
1294+
self.assertIn('display_name', columns)
1295+
self.assertNotIn('name', columns)
1296+
self.assertIn(self._volume.display_name, data)
1297+
12261298

12271299
class TestVolumeUnset(TestVolume):
12281300

0 commit comments

Comments
 (0)