Revert "Remove marker and loop from "image list" command"
This reverts commit 0b6fdcbe4c
.
Adapt "image list" to not loop when --marker is specified on command
line.
Update tests to work with current state of code.
Change-Id: I8af58adf8637a9e34371c6280db40935d22bc3c3
This commit is contained in:
parent
307a847685
commit
42f33435ed
@ -485,7 +485,6 @@ class ListImage(command.Lister):
|
||||
if parsed_args.marker:
|
||||
kwargs['marker'] = utils.find_resource(image_client.images,
|
||||
parsed_args.marker).id
|
||||
|
||||
if parsed_args.long:
|
||||
columns = (
|
||||
'ID',
|
||||
@ -518,7 +517,19 @@ class ListImage(command.Lister):
|
||||
column_headers = columns
|
||||
|
||||
# List of image data received
|
||||
data = image_client.api.image_list(**kwargs)
|
||||
data = []
|
||||
if 'marker' in kwargs:
|
||||
data = image_client.api.image_list(**kwargs)
|
||||
else:
|
||||
# No pages received yet, so start the page marker at None.
|
||||
marker = None
|
||||
while True:
|
||||
page = image_client.api.image_list(marker=marker, **kwargs)
|
||||
if not page:
|
||||
break
|
||||
data.extend(page)
|
||||
# Set the marker to the id of the last item we received
|
||||
marker = page[-1]['id']
|
||||
|
||||
if parsed_args.property:
|
||||
# NOTE(dtroyer): coerce to a list to subscript it in py3
|
||||
|
@ -535,7 +535,9 @@ class TestImageList(TestImage):
|
||||
# returns a tuple containing the column names and an iterable
|
||||
# containing the data to be listed.
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.api_mock.image_list.assert_called_with()
|
||||
self.api_mock.image_list.assert_called_with(
|
||||
marker=self._image.id,
|
||||
)
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.datalist, tuple(data))
|
||||
@ -558,6 +560,7 @@ class TestImageList(TestImage):
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.api_mock.image_list.assert_called_with(
|
||||
public=True,
|
||||
marker=self._image.id,
|
||||
)
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
@ -581,6 +584,7 @@ class TestImageList(TestImage):
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.api_mock.image_list.assert_called_with(
|
||||
private=True,
|
||||
marker=self._image.id,
|
||||
)
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
@ -604,6 +608,7 @@ class TestImageList(TestImage):
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.api_mock.image_list.assert_called_with(
|
||||
shared=True,
|
||||
marker=self._image.id,
|
||||
)
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
@ -622,7 +627,9 @@ class TestImageList(TestImage):
|
||||
# returns a tuple containing the column names and an iterable
|
||||
# containing the data to be listed.
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.api_mock.image_list.assert_called_with()
|
||||
self.api_mock.image_list.assert_called_with(
|
||||
marker=self._image.id,
|
||||
)
|
||||
|
||||
collist = (
|
||||
'ID',
|
||||
@ -670,7 +677,9 @@ class TestImageList(TestImage):
|
||||
# returns a tuple containing the column names and an iterable
|
||||
# containing the data to be listed.
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.api_mock.image_list.assert_called_with()
|
||||
self.api_mock.image_list.assert_called_with(
|
||||
marker=self._image.id,
|
||||
)
|
||||
sf_mock.assert_called_with(
|
||||
[self._image],
|
||||
attr='a',
|
||||
@ -693,7 +702,9 @@ class TestImageList(TestImage):
|
||||
# returns a tuple containing the column names and an iterable
|
||||
# containing the data to be listed.
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.api_mock.image_list.assert_called_with()
|
||||
self.api_mock.image_list.assert_called_with(
|
||||
marker=self._image.id,
|
||||
)
|
||||
si_mock.assert_called_with(
|
||||
[self._image],
|
||||
'name:asc'
|
||||
@ -712,7 +723,7 @@ class TestImageList(TestImage):
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.api_mock.image_list.assert_called_with(
|
||||
limit=1,
|
||||
limit=1, marker=self._image.id
|
||||
)
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
|
Loading…
Reference in New Issue
Block a user