From ea01f13be21f0243711bc8eef6d84ecba39d7164 Mon Sep 17 00:00:00 2001 From: Brad Pokorny Date: Mon, 15 Jun 2015 13:00:17 -0700 Subject: [PATCH] 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 --- glanceclient/tests/unit/v2/test_images.py | 6 ++++++ glanceclient/v2/images.py | 3 +++ 2 files changed, 9 insertions(+) diff --git a/glanceclient/tests/unit/v2/test_images.py b/glanceclient/tests/unit/v2/test_images.py index 26ee792f..7260f47e 100644 --- a/glanceclient/tests/unit/v2/test_images.py +++ b/glanceclient/tests/unit/v2/test_images.py @@ -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)) diff --git a/glanceclient/v2/images.py b/glanceclient/v2/images.py index 01ce40b9..0cbd0d52 100644 --- a/glanceclient/v2/images.py +++ b/glanceclient/v2/images.py @@ -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