Adds filter support to images.list().
This existed in glance.client, and should exist in the new client as well! :-) Change-Id: Iea8c55fcb0f0d30d6dc138072354c3f20d1288cf
This commit is contained in:
parent
1f106a3bd9
commit
3344eac545
1
AUTHORS
1
AUTHORS
@ -2,3 +2,4 @@ Brian Waldon <bcwaldon@gmail.com>
|
||||
Jay Pipes <jaypipes@gmail.com>
|
||||
Monty Taylor <mordred@inaugust.com>
|
||||
Dean Troyer <dtroyer@gmail.com>
|
||||
Gabriel Hurley <gabriel@strikeawe.com>
|
||||
|
@ -71,7 +71,7 @@ class ImageManager(base.Manager):
|
||||
meta = self._image_meta_from_headers(resp)
|
||||
return Image(self, meta)
|
||||
|
||||
def list(self, limit=None, marker=None):
|
||||
def list(self, limit=None, marker=None, filters=None):
|
||||
"""Get a list of images.
|
||||
|
||||
:param limit: maximum number of images to return. Used for pagination.
|
||||
@ -83,6 +83,8 @@ class ImageManager(base.Manager):
|
||||
params['limit'] = int(limit)
|
||||
if marker:
|
||||
params['marker'] = marker
|
||||
if filters:
|
||||
params.update(filters)
|
||||
query = '?%s' % urllib.urlencode(params) if params else ''
|
||||
return self._list('/v1/images/detail%s' % query, "images")
|
||||
|
||||
|
@ -32,6 +32,11 @@ class ImageManagerTest(unittest.TestCase):
|
||||
expect = [('GET', '/v1/images/detail?marker=20', {}, None)]
|
||||
self.assertEqual(self.api.calls, expect)
|
||||
|
||||
def test_list_with_filter(self):
|
||||
self.mgr.list(filters={'name': "foo"})
|
||||
expect = [('GET', '/v1/images/detail?name=foo', {}, None)]
|
||||
self.assertEqual(self.api.calls, expect)
|
||||
|
||||
def test_get(self):
|
||||
image = self.mgr.get('1')
|
||||
expect = [('HEAD', '/v1/images/1', {}, None)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user