Merge "zun image-list issue"

This commit is contained in:
Jenkins 2017-01-27 06:44:37 +00:00 committed by Gerrit Code Review
commit 3252ade706
5 changed files with 3 additions and 55 deletions

View File

@ -21,7 +21,6 @@ from zun.api.controllers.v1.schemas import images as schema
from zun.api.controllers.v1.views import images_view as view
from zun.api import utils as api_utils
from zun.common import exception
from zun.common.i18n import _LE
from zun.common import policy
from zun.common import utils
from zun.common import validation
@ -85,13 +84,6 @@ class ImagesController(rest.RestController):
sort_key,
sort_dir,
filters=filters)
for i, c in enumerate(images):
try:
images[i] = pecan.request.compute_api.image_show(context, c)
except Exception as e:
LOG.exception(_LE("Error while list image %(uuid)s: "
"%(e)s."), {'uuid': c.uuid, 'e': e})
return ImageCollection.convert_with_links(images, limit,
url=resource_url,
expand=expand,

View File

@ -87,9 +87,6 @@ class API(object):
def container_update(self, context, container, *args):
return self.rpcapi.container_update(context, container, *args)
def image_show(self, context, image, *args):
return self.rpcapi.image_show(context, image, *args)
def image_pull(self, context, image, *args):
return self.rpcapi.image_pull(context, image, *args)

View File

@ -371,16 +371,6 @@ class Manager(object):
six.text_type(e))
raise
@translate_exception
def image_show(self, context, image):
LOG.debug('Listing image...')
try:
self.image.list()
return image
except Exception as e:
LOG.exception(_LE("Unexpected exception: %s"), six.text_type(e))
raise
@translate_exception
def image_search(self, context, image, exact_match):
LOG.debug('Searching image...', image=image)

View File

@ -82,13 +82,6 @@ class API(rpc_service.API):
return self._call(container.host, 'container_update',
container=container, patch=patch)
def image_show(self, context, image):
# NOTE(hongbin): Image API doesn't support multiple compute nodes
# scenario yet, so we temporarily set host to None and rpc will
# choose an arbitrary host.
host = None
return self._call(host, 'image_show', image=image)
def image_pull(self, context, image):
# NOTE(hongbin): Image API doesn't support multiple compute nodes
# scenario yet, so we temporarily set host to None and rpc will

View File

@ -94,13 +94,11 @@ class TestImageController(api_base.FunctionalTest):
self.assertEqual(202, response.status_int)
self.assertTrue(mock_image_pull.called)
@patch('zun.compute.api.API.image_show')
@patch('zun.objects.Image.list')
def test_get_all_images(self, mock_image_list, mock_image_show):
def test_get_all_images(self, mock_image_list):
test_image = utils.get_test_image()
images = [objects.Image(self.context, **test_image)]
mock_image_list.return_value = images
mock_image_show.return_value = images[0]
response = self.app.get('/v1/images/')
@ -113,10 +111,9 @@ class TestImageController(api_base.FunctionalTest):
self.assertEqual(test_image['uuid'],
actual_images[0].get('uuid'))
@patch('zun.compute.api.API.image_show')
@patch('zun.objects.Image.list')
def test_get_all_images_with_pagination_marker(self, mock_image_list,
mock_image_show):
def test_get_all_images_with_pagination_marker(self, mock_image_list
):
image_list = []
for id_ in range(4):
test_image = utils.create_test_image(
@ -126,7 +123,6 @@ class TestImageController(api_base.FunctionalTest):
uuid=uuidutils.generate_uuid())
image_list.append(objects.Image(self.context, **test_image))
mock_image_list.return_value = image_list[-1:]
mock_image_show.return_value = image_list[-1]
response = self.app.get('/v1/images/?limit=3&marker=%s'
% image_list[2].uuid)
@ -136,26 +132,6 @@ class TestImageController(api_base.FunctionalTest):
self.assertEqual(image_list[-1].uuid,
actual_images[0].get('uuid'))
@patch('zun.compute.api.API.image_show')
@patch('zun.objects.Image.list')
def test_get_all_images_with_exception(self, mock_image_list,
mock_image_show):
test_image = utils.get_test_image()
images = [objects.Image(self.context, **test_image)]
mock_image_list.return_value = images
mock_image_show.side_effect = Exception
response = self.app.get('/v1/images/')
mock_image_list.assert_called_once_with(mock.ANY, 1000,
None, 'id', 'asc',
filters=None)
self.assertEqual(200, response.status_int)
actual_images = response.json['images']
self.assertEqual(1, len(actual_images))
self.assertEqual(test_image['uuid'],
actual_images[0].get('uuid'))
@patch('zun.compute.api.API.image_search')
def test_search_image(self, mock_image_search):
mock_image_search.return_value = {'name': 'redis', 'stars': 2000}