Merge "Fix image_search request"
This commit is contained in:
@@ -149,7 +149,7 @@ class Manager(object):
|
||||
if qparams:
|
||||
url = "%s?%s" % (url, urlparse.urlencode(qparams))
|
||||
|
||||
resp, body = self.api.json_request('SEARCH', url, body=body)
|
||||
resp, body = self.api.json_request('GET', url, body=body)
|
||||
data = self._format_body_data(body, response_key)
|
||||
if obj_class is None:
|
||||
obj_class = self.resource_class
|
||||
|
||||
@@ -48,10 +48,6 @@ fake_responses = {
|
||||
{},
|
||||
{'images': [IMAGE1, IMAGE2]},
|
||||
),
|
||||
'SEARCH': (
|
||||
{},
|
||||
{'images': [IMAGE3]},
|
||||
),
|
||||
},
|
||||
'/v1/images/?limit=2':
|
||||
{
|
||||
@@ -95,6 +91,13 @@ fake_responses = {
|
||||
{'images': [IMAGE2, IMAGE1]},
|
||||
),
|
||||
},
|
||||
'/v1/images/%s/search' % IMAGE3['image']:
|
||||
{
|
||||
'GET': (
|
||||
{},
|
||||
{'images': [IMAGE3]},
|
||||
),
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -180,9 +183,8 @@ class ImageManagerTest(testtools.TestCase):
|
||||
def test_image_search(self):
|
||||
images = self.mgr.search_image(**SEARCH_IMAGE)
|
||||
expect = [
|
||||
('SEARCH', '/v1/images/', {},
|
||||
{'image': IMAGE3['image'],
|
||||
'image_driver': IMAGE3['image_driver']}),
|
||||
('GET', '/v1/images/%s/search' % IMAGE3['image'], {},
|
||||
{'image_driver': IMAGE3['image_driver']}),
|
||||
]
|
||||
self.assertEqual(expect, self.api.calls)
|
||||
self.assertThat(images, matchers.HasLength(1))
|
||||
|
||||
@@ -96,7 +96,7 @@ class ImageManager(base.Manager):
|
||||
"Key must be in %s" % ','.join(PULL_ATTRIBUTES))
|
||||
return self._create(self._path(), new)
|
||||
|
||||
def search_image(self, **kwargs):
|
||||
def search_image(self, image, **kwargs):
|
||||
"""Retrieves list of images based on image name and image_driver name
|
||||
|
||||
:returns: A list of images based on the search query
|
||||
@@ -110,5 +110,4 @@ class ImageManager(base.Manager):
|
||||
else:
|
||||
raise exceptions.InvalidAttribute(
|
||||
"Key must be in %s" % ','.join(IMAGE_SEARCH_ATTRIBUTES))
|
||||
path = ''
|
||||
return self._search(self._path(path), image_query)
|
||||
return self._search(self._path(image) + '/search', image_query)
|
||||
|
||||
@@ -80,10 +80,9 @@ def do_image_show(cs, args):
|
||||
def do_image_search(cs, args):
|
||||
"""Print list of available images from repository based on user query."""
|
||||
opts = {}
|
||||
opts['image'] = args.image
|
||||
opts['image_driver'] = args.image_driver
|
||||
opts['exact_match'] = args.exact_match
|
||||
images = cs.images.search_image(**opts)
|
||||
images = cs.images.search_image(args.image, **opts)
|
||||
columns = ('ID', 'Name', 'Tags', 'Status', 'Size', 'Metadata')
|
||||
utils.print_list(images, columns,
|
||||
{'versions': zun_utils.print_list_field('versions')},
|
||||
|
||||
Reference in New Issue
Block a user