diff --git a/novaclient/tests/unit/v2/test_flavors.py b/novaclient/tests/unit/v2/test_flavors.py index 4fe43c10a..b78d6cde9 100644 --- a/novaclient/tests/unit/v2/test_flavors.py +++ b/novaclient/tests/unit/v2/test_flavors.py @@ -45,6 +45,10 @@ class FlavorsTest(utils.TestCase): for flavor in fl: self.assertIsInstance(flavor, self.flavor_type) + def test_list_flavors_with_marker_limit(self): + self.cs.flavors.list(marker=1234, limit=4) + self.cs.assert_called('GET', '/flavors/detail?limit=4&marker=1234') + def test_list_flavors_is_public_none(self): fl = self.cs.flavors.list(is_public=None) self.cs.assert_called('GET', '/flavors/detail?is_public=None') diff --git a/novaclient/tests/unit/v2/test_images.py b/novaclient/tests/unit/v2/test_images.py index 4c25e8af8..f4a6ef86b 100644 --- a/novaclient/tests/unit/v2/test_images.py +++ b/novaclient/tests/unit/v2/test_images.py @@ -35,9 +35,9 @@ class ImagesTest(utils.FixturedTestCase): for i in il: self.assertIsInstance(i, images.Image) - def test_list_images_with_limit(self): - self.cs.images.list(limit=4) - self.assert_called('GET', '/images/detail?limit=4') + def test_list_images_with_marker_limit(self): + self.cs.images.list(marker=1234, limit=4) + self.assert_called('GET', '/images/detail?limit=4&marker=1234') def test_get_image_details(self): i = self.cs.images.get(1) diff --git a/novaclient/v2/flavors.py b/novaclient/v2/flavors.py index 1db42e24e..cf8591d74 100644 --- a/novaclient/v2/flavors.py +++ b/novaclient/v2/flavors.py @@ -93,18 +93,26 @@ class FlavorManager(base.ManagerWithFind): resource_class = Flavor is_alphanum_id_allowed = True - def list(self, detailed=True, is_public=True): + def list(self, detailed=True, is_public=True, marker=None, limit=None): """ Get a list of all flavors. :rtype: list of :class:`Flavor`. + :param limit: maximum number of flavors to return (optional). + :param marker: Begin returning flavors that appear later in the flavor + list than that represented by this flavor id (optional). """ qparams = {} # is_public is ternary - None means give all flavors. # By default Nova assumes True and gives admins public flavors # and flavors from their own projects only. + if marker: + qparams['marker'] = str(marker) + if limit: + qparams['limit'] = int(limit) if not is_public: qparams['is_public'] = is_public + qparams = sorted(qparams.items(), key=lambda x: x[0]) query_string = "?%s" % parse.urlencode(qparams) if qparams else "" detail = "" diff --git a/novaclient/v2/images.py b/novaclient/v2/images.py index 2d413a6bf..32001b465 100644 --- a/novaclient/v2/images.py +++ b/novaclient/v2/images.py @@ -52,12 +52,14 @@ class ImageManager(base.ManagerWithFind): """ return self._get("/images/%s" % base.getid(image), "image") - def list(self, detailed=True, limit=None): + def list(self, detailed=True, limit=None, marker=None): """ Get a list of all images. :rtype: list of :class:`Image` :param limit: maximum number of images to return. + :param marker: Begin returning images that appear later in the image + list than that represented by this image id (optional). """ params = {} detail = '' @@ -65,6 +67,9 @@ class ImageManager(base.ManagerWithFind): detail = '/detail' if limit: params['limit'] = int(limit) + if marker: + params['marker'] = str(marker) + params = sorted(params.items(), key=lambda x: x[0]) query = '?%s' % parse.urlencode(params) if params else '' return self._list('/images%s%s' % (detail, query), 'images')