Enable query image by tag

This patch will enable Glance client to query images by user
defined tags.

Implement bp image-query-by-tag
Implement bp glance-client-v2

Change-Id: I6f54630c5b7c9c567d85485ad4289284e5486814
This commit is contained in:
Fei Long Wang
2013-08-11 11:02:32 +08:00
parent b6e117f151
commit 897ae3d795
4 changed files with 92 additions and 1 deletions
+10
View File
@@ -52,12 +52,22 @@ class Controller(object):
else:
filters['limit'] = kwargs['page_size']
tags = filters.pop('tag', [])
tags_url_params = []
for tag in tags:
if isinstance(tag, basestring):
tags_url_params.append({'tag': strutils.safe_encode(tag)})
for param, value in filters.iteritems():
if isinstance(value, basestring):
filters[param] = strutils.safe_encode(value)
url = '/v2/images?%s' % urllib.urlencode(filters)
for param in tags_url_params:
url = '%s&%s' % (url, urllib.urlencode(param))
for image in paginate(url):
#NOTE(bcwaldon): remove 'self' for now until we have an elegant
# way to pass it into the model constructor without conflict