Merge "Populate default image driver in API layer"
This commit is contained in:
commit
ca081aad0c
|
@ -393,9 +393,10 @@ class ContainersController(base.Controller):
|
|||
'are: %s') % bools)
|
||||
|
||||
# Valiadtion accepts 'None' so need to convert it to None
|
||||
if container_dict.get('image_driver'):
|
||||
container_dict['image_driver'] = api_utils.string_or_none(
|
||||
container_dict.get('image_driver'))
|
||||
container_dict['image_driver'] = api_utils.string_or_none(
|
||||
container_dict.get('image_driver'))
|
||||
if not container_dict['image_driver']:
|
||||
container_dict['image_driver'] = CONF.default_image_driver
|
||||
|
||||
container_dict['project_id'] = context.project_id
|
||||
container_dict['user_id'] = context.user_id
|
||||
|
|
|
@ -25,8 +25,10 @@ from zun.common import exception
|
|||
from zun.common.i18n import _
|
||||
from zun.common import policy
|
||||
from zun.common import utils
|
||||
import zun.conf
|
||||
from zun import objects
|
||||
|
||||
CONF = zun.conf.CONF
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
@ -173,8 +175,9 @@ class ImagesController(base.Controller):
|
|||
raise exception.InvalidValue(_('Valid exact_match values are: %s')
|
||||
% bools)
|
||||
# Valiadtion accepts 'None' so need to convert it to None
|
||||
if image_driver:
|
||||
image_driver = api_utils.string_or_none(image_driver)
|
||||
image_driver = api_utils.string_or_none(image_driver)
|
||||
if not image_driver:
|
||||
image_driver = CONF.default_image_driver
|
||||
|
||||
return pecan.request.compute_api.image_search(context, image,
|
||||
image_driver,
|
||||
|
|
|
@ -17,11 +17,15 @@ from webtest.app import AppError
|
|||
from oslo_utils import uuidutils
|
||||
|
||||
from zun.common import exception
|
||||
import zun.conf
|
||||
from zun import objects
|
||||
from zun.tests.unit.api import base as api_base
|
||||
from zun.tests.unit.db import utils
|
||||
|
||||
|
||||
CONF = zun.conf.CONF
|
||||
|
||||
|
||||
class TestImageController(api_base.FunctionalTest):
|
||||
@mock.patch('zun.common.policy.enforce', return_value=True)
|
||||
@patch('zun.compute.api.API.image_pull')
|
||||
|
@ -174,7 +178,7 @@ class TestImageController(api_base.FunctionalTest):
|
|||
response = self.get('/v1/images/redis/search/')
|
||||
self.assertEqual(200, response.status_int)
|
||||
mock_image_search.assert_called_once_with(
|
||||
mock.ANY, 'redis', None, False)
|
||||
mock.ANY, 'redis', CONF.default_image_driver, False)
|
||||
|
||||
@patch('zun.compute.api.API.image_search')
|
||||
def test_search_image_with_tag(self, mock_image_search):
|
||||
|
@ -182,14 +186,14 @@ class TestImageController(api_base.FunctionalTest):
|
|||
response = self.get('/v1/images/redis:test/search/')
|
||||
self.assertEqual(200, response.status_int)
|
||||
mock_image_search.assert_called_once_with(
|
||||
mock.ANY, 'redis:test', None, False)
|
||||
mock.ANY, 'redis:test', CONF.default_image_driver, False)
|
||||
|
||||
@patch('zun.compute.api.API.image_search')
|
||||
def test_search_image_not_found(self, mock_image_search):
|
||||
mock_image_search.side_effect = exception.ImageNotFound
|
||||
self.assertRaises(AppError, self.get, '/v1/images/redis/search/')
|
||||
mock_image_search.assert_called_once_with(
|
||||
mock.ANY, 'redis', None, False)
|
||||
mock.ANY, 'redis', CONF.default_image_driver, False)
|
||||
|
||||
@patch('zun.compute.rpcapi.API.image_search')
|
||||
def test_search_image_with_exact_match_true(self, mock_image_search):
|
||||
|
|
Loading…
Reference in New Issue