Skip to content

Commit ba66cdf

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Fix --limit option in image list sub-command"
2 parents a71cb02 + aaf73cb commit ba66cdf

3 files changed

Lines changed: 15 additions & 4 deletions

File tree

openstackclient/image/v2/image.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,9 @@ def take_action(self, parsed_args):
643643

644644
# List of image data received
645645
data = []
646+
limit = None
647+
if 'limit' in kwargs:
648+
limit = kwargs['limit']
646649
if 'marker' in kwargs:
647650
data = image_client.api.image_list(**kwargs)
648651
else:
@@ -655,6 +658,8 @@ def take_action(self, parsed_args):
655658
data.extend(page)
656659
# Set the marker to the id of the last item we received
657660
marker = page[-1]['id']
661+
if limit:
662+
break
658663

659664
if parsed_args.property:
660665
for attr, value in parsed_args.property.items():

openstackclient/tests/unit/image/v2/test_image.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -787,21 +787,22 @@ def test_image_list_sort_option(self, si_mock):
787787
self.assertEqual(self.datalist, tuple(data))
788788

789789
def test_image_list_limit_option(self):
790+
ret_limit = 1
790791
arglist = [
791-
'--limit', str(1),
792+
'--limit', str(ret_limit),
792793
]
793794
verifylist = [
794-
('limit', 1),
795+
('limit', ret_limit),
795796
]
796797
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
797798

798799
columns, data = self.cmd.take_action(parsed_args)
799800
self.api_mock.image_list.assert_called_with(
800-
limit=1, marker=self._image.id
801+
limit=ret_limit, marker=None
801802
)
802803

803804
self.assertEqual(self.columns, columns)
804-
self.assertEqual(len(self.datalist), len(tuple(data)))
805+
self.assertEqual(ret_limit, len(tuple(data)))
805806

806807
@mock.patch('osc_lib.utils.find_resource')
807808
def test_image_list_marker_option(self, fr_mock):
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
fixes:
3+
- |
4+
The ``--limit`` option of the ``image list`` command was previously ignored.
5+
[Bug `https://storyboard.openstack.org/#!/story/2004314`]

0 commit comments

Comments
 (0)