Add v2 support for the marker attribute

The v2 Glance client implementation ignores the marker attribute if
it's passed to the client as part of the kwargs.  Include support
for the attribute, as the v1 client supports it and it makes it
easier to work with the Glance client.

Change-Id: Ifaa59129bc4178212b890ea591673cb154e0f110
Closes-bug: 1465373
This commit is contained in:
Brad Pokorny 2015-06-15 13:00:17 -07:00
parent 0d22e821f9
commit ea01f13be2
2 changed files with 9 additions and 0 deletions

View File

@ -555,6 +555,12 @@ class TestController(testtools.TestCase):
self.assertEqual('image-3', images[2].name)
self.assertEqual(3, len(images))
def test_list_images_with_marker(self):
images = list(self.controller.list(limit=1,
marker='3a4560a1-e585-443e-9b39-553b46ec92d1'))
self.assertEqual('6f99bf80-2ee6-47cf-acfe-1f1fabb7e810', images[0].id)
self.assertEqual('image-2', images[0].name)
def test_list_images_visibility_public(self):
filters = {'filters': {'visibility': 'public'}}
images = list(self.controller.list(**filters))

View File

@ -168,6 +168,9 @@ class Controller(object):
for dir in sort_dir:
url = '%s&sort_dir=%s' % (url, dir)
if isinstance(kwargs.get('marker'), six.string_types):
url = '%s&marker=%s' % (url, kwargs['marker'])
for image in paginate(url, page_size, limit):
yield image