Merge "Fix --limit option in image list sub-command"
This commit is contained in:
commit
ba66cdfcfa
@ -643,6 +643,9 @@ class ListImage(command.Lister):
|
||||
|
||||
# List of image data received
|
||||
data = []
|
||||
limit = None
|
||||
if 'limit' in kwargs:
|
||||
limit = kwargs['limit']
|
||||
if 'marker' in kwargs:
|
||||
data = image_client.api.image_list(**kwargs)
|
||||
else:
|
||||
@ -655,6 +658,8 @@ class ListImage(command.Lister):
|
||||
data.extend(page)
|
||||
# Set the marker to the id of the last item we received
|
||||
marker = page[-1]['id']
|
||||
if limit:
|
||||
break
|
||||
|
||||
if parsed_args.property:
|
||||
for attr, value in parsed_args.property.items():
|
||||
|
@ -787,21 +787,22 @@ class TestImageList(TestImage):
|
||||
self.assertEqual(self.datalist, tuple(data))
|
||||
|
||||
def test_image_list_limit_option(self):
|
||||
ret_limit = 1
|
||||
arglist = [
|
||||
'--limit', str(1),
|
||||
'--limit', str(ret_limit),
|
||||
]
|
||||
verifylist = [
|
||||
('limit', 1),
|
||||
('limit', ret_limit),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.api_mock.image_list.assert_called_with(
|
||||
limit=1, marker=self._image.id
|
||||
limit=ret_limit, marker=None
|
||||
)
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(len(self.datalist), len(tuple(data)))
|
||||
self.assertEqual(ret_limit, len(tuple(data)))
|
||||
|
||||
@mock.patch('osc_lib.utils.find_resource')
|
||||
def test_image_list_marker_option(self, fr_mock):
|
||||
|
5
releasenotes/notes/bug-27882-402ced7ffe930058.yaml
Normal file
5
releasenotes/notes/bug-27882-402ced7ffe930058.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
The ``--limit`` option of the ``image list`` command was previously ignored.
|
||||
[Bug `https://storyboard.openstack.org/#!/story/2004314`]
|
Loading…
Reference in New Issue
Block a user