Merge "Remove deprecated 'enable_image_import' option"
This commit is contained in:
commit
0ec96bf910
|
@ -14,10 +14,8 @@
|
|||
# limitations under the License.
|
||||
|
||||
from oslo_config import cfg
|
||||
import webob.exc
|
||||
|
||||
from glance.common import wsgi
|
||||
from glance.i18n import _
|
||||
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
@ -25,12 +23,6 @@ CONF = cfg.CONF
|
|||
|
||||
class InfoController(object):
|
||||
def get_image_import(self, req):
|
||||
# TODO(jokke): Will be removed after the config option
|
||||
# is removed. (deprecated)
|
||||
if not CONF.enable_image_import:
|
||||
msg = _("Image import is not supported at this site.")
|
||||
raise webob.exc.HTTPNotFound(explanation=msg)
|
||||
|
||||
# TODO(jokke): All the rest of the boundaries should be implemented.
|
||||
import_methods = {
|
||||
'description': 'Import methods available.',
|
||||
|
|
|
@ -382,8 +382,8 @@ class RequestDeserializer(wsgi.JSONRequestDeserializer):
|
|||
return {'size': image_size, 'data': request.body_file}
|
||||
|
||||
def stage(self, request):
|
||||
if not CONF.enable_image_import:
|
||||
msg = _("Image import is not supported at this site.")
|
||||
if "glance-direct" not in CONF.enabled_import_methods:
|
||||
msg = _("'glance-direct' method is not available at this site.")
|
||||
raise webob.exc.HTTPNotFound(explanation=msg)
|
||||
try:
|
||||
request.get_content_type(('application/octet-stream',))
|
||||
|
|
|
@ -287,9 +287,7 @@ class ImagesController(object):
|
|||
try:
|
||||
image = image_repo.get(image_id)
|
||||
|
||||
# NOTE(abhishekk): If 'image-import' is supported and image status
|
||||
# is uploading then delete image data from the staging area.
|
||||
if CONF.enable_image_import and image.status == 'uploading':
|
||||
if image.status == 'uploading':
|
||||
file_path = str(CONF.node_staging_uri + '/' + image.image_id)
|
||||
self.store_api.delete_from_backend(file_path)
|
||||
|
||||
|
@ -822,9 +820,6 @@ class RequestDeserializer(wsgi.JSONRequestDeserializer):
|
|||
raise webob.exc.HTTPBadRequest(explanation=msg)
|
||||
|
||||
def import_image(self, request):
|
||||
if not CONF.enable_image_import:
|
||||
msg = _("Image import is not supported at this site.")
|
||||
raise webob.exc.HTTPNotFound(explanation=msg)
|
||||
body = self._get_request_body(request)
|
||||
self._validate_import_body(body)
|
||||
return {'body': body}
|
||||
|
@ -902,15 +897,12 @@ class ResponseSerializer(wsgi.JSONResponseSerializer):
|
|||
response.status_int = http.CREATED
|
||||
self.show(response, image)
|
||||
response.location = self._get_image_href(image)
|
||||
# TODO(rosmaita): remove the outer 'if' statement when the
|
||||
# enable_image_import config option is removed
|
||||
if CONF.enable_image_import:
|
||||
# according to RFC7230, headers should not have empty fields
|
||||
# see http://httpwg.org/specs/rfc7230.html#field.components
|
||||
if CONF.enabled_import_methods:
|
||||
import_methods = ("OpenStack-image-import-methods",
|
||||
','.join(CONF.enabled_import_methods))
|
||||
response.headerlist.append(import_methods)
|
||||
# according to RFC7230, headers should not have empty fields
|
||||
# see http://httpwg.org/specs/rfc7230.html#field.components
|
||||
if CONF.enabled_import_methods:
|
||||
import_methods = ("OpenStack-image-import-methods",
|
||||
','.join(CONF.enabled_import_methods))
|
||||
response.headerlist.append(import_methods)
|
||||
|
||||
def show(self, response, image):
|
||||
image_view = self._format_image(image)
|
||||
|
|
|
@ -700,32 +700,8 @@ Possible values:
|
|||
|
||||
Related options:
|
||||
* [task]/work_dir
|
||||
* [DEFAULT]/enable_image_import (*deprecated*)
|
||||
|
||||
""")),
|
||||
cfg.BoolOpt('enable_image_import',
|
||||
default=True,
|
||||
deprecated_for_removal=True,
|
||||
deprecated_reason=_("""
|
||||
This option is deprecated for removal in Rocky.
|
||||
|
||||
It was introduced to make sure that the API is not enabled
|
||||
before the '[DEFAULT]/node_staging_uri' is defined and is
|
||||
long term redundant."""),
|
||||
deprecated_since='Pike',
|
||||
help=_("""
|
||||
Enables the Image Import workflow introduced in Pike
|
||||
|
||||
As '[DEFAULT]/node_staging_uri' is required for the Image
|
||||
Import, it's disabled per default in Pike, enabled per
|
||||
default in Queens and removed in Rocky. This allows Glance to
|
||||
operate with previous version configs upon upgrade.
|
||||
|
||||
Setting this option to False will disable the endpoints related
|
||||
to Image Import Refactoring work.
|
||||
|
||||
Related options:
|
||||
* [DEFAULT]/node_staging_uri""")),
|
||||
cfg.ListOpt('enabled_import_methods',
|
||||
item_type=cfg.types.String(quotes=True),
|
||||
bounds=True,
|
||||
|
@ -736,8 +712,7 @@ List of enabled Image Import Methods
|
|||
Both 'glance-direct' and 'web-download' are enabled by default.
|
||||
|
||||
Related options:
|
||||
* [DEFAULT]/node_staging_uri
|
||||
* [DEFAULT]/enable_image_import""")),
|
||||
* [DEFAULT]/node_staging_uri""")),
|
||||
]
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
|
|
@ -76,9 +76,6 @@ class Server(object):
|
|||
self.property_protection_file = ''
|
||||
self.enable_v1_api = True
|
||||
self.enable_v2_api = True
|
||||
# TODO(rosmaita): remove in Queens when the option is removed
|
||||
# also, don't forget to remove it from ApiServer.conf_base
|
||||
self.enable_image_import = False
|
||||
self.enable_v1_registry = True
|
||||
self.enable_v2_registry = True
|
||||
self.needs_database = False
|
||||
|
@ -351,7 +348,6 @@ show_multiple_locations = %(show_multiple_locations)s
|
|||
user_storage_quota = %(user_storage_quota)s
|
||||
enable_v1_api = %(enable_v1_api)s
|
||||
enable_v2_api = %(enable_v2_api)s
|
||||
enable_image_import = %(enable_image_import)s
|
||||
lock_path = %(lock_path)s
|
||||
property_protection_file = %(property_protection_file)s
|
||||
property_protection_rule_format = %(property_protection_rule_format)s
|
||||
|
|
|
@ -137,7 +137,6 @@ class TestImages(functional.FunctionalTest):
|
|||
self.stop_servers()
|
||||
|
||||
def test_image_import_using_glance_direct(self):
|
||||
self.api_server.enable_image_import = True
|
||||
self.start_servers(**self.__dict__.copy())
|
||||
|
||||
# Image list should be empty
|
||||
|
@ -278,7 +277,6 @@ class TestImages(functional.FunctionalTest):
|
|||
self.stop_servers()
|
||||
|
||||
def test_image_import_using_web_download(self):
|
||||
self.api_server.enable_image_import = True
|
||||
self.config(node_staging_uri="file:///tmp/staging/")
|
||||
self.start_servers(**self.__dict__.copy())
|
||||
|
||||
|
|
|
@ -208,12 +208,6 @@ class VersionNegotiationTest(base.IsolatedUnitTest):
|
|||
resp = self.middleware.process_request(request)
|
||||
self.assertIsInstance(resp, versions.Controller)
|
||||
|
||||
def test_request_url_v2_7_unsupported_EXPERIMENTAL(self):
|
||||
request = webob.Request.blank('/v2.7/images')
|
||||
self.config(enable_image_import=True)
|
||||
resp = self.middleware.process_request(request)
|
||||
self.assertIsInstance(resp, versions.Controller)
|
||||
|
||||
|
||||
class VersionsAndNegotiationTest(VersionNegotiationTest, VersionsTest):
|
||||
|
||||
|
|
|
@ -13,8 +13,6 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import webob.exc
|
||||
|
||||
import glance.api.v2.discovery
|
||||
import glance.tests.unit.utils as unit_test_utils
|
||||
import glance.tests.utils as test_utils
|
||||
|
@ -26,20 +24,19 @@ class TestInfoControllers(test_utils.BaseTestCase):
|
|||
super(TestInfoControllers, self).setUp()
|
||||
self.controller = glance.api.v2.discovery.InfoController()
|
||||
|
||||
def test_get_import_info_when_import_not_enabled(self):
|
||||
"""When import not enabled, should return 404 just like v2.5"""
|
||||
self.config(enable_image_import=False)
|
||||
def test_get_import_info_with_empty_method_list(self):
|
||||
"""When methods list is empty, should still return import methods"""
|
||||
self.config(enabled_import_methods=[])
|
||||
req = unit_test_utils.get_fake_request()
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
self.controller.get_image_import,
|
||||
req)
|
||||
output = self.controller.get_image_import(req)
|
||||
self.assertIn('import-methods', output)
|
||||
self.assertEqual([], output['import-methods']['value'])
|
||||
|
||||
def test_get_import_info(self):
|
||||
# TODO(rosmaita): change this when import methods are
|
||||
# listed in the config file
|
||||
import_methods = ['glance-direct', 'web-download']
|
||||
|
||||
self.config(enable_image_import=True)
|
||||
req = unit_test_utils.get_fake_request()
|
||||
output = self.controller.get_image_import(req)
|
||||
self.assertIn('import-methods', output)
|
||||
|
|
|
@ -671,7 +671,6 @@ class TestImageDataDeserializer(test_utils.BaseTestCase):
|
|||
self.deserializer.upload, request)
|
||||
|
||||
def test_stage(self):
|
||||
self.config(enable_image_import=True)
|
||||
req = unit_test_utils.get_fake_request()
|
||||
req.headers['Content-Type'] = 'application/octet-stream'
|
||||
req.headers['Content-Length'] = 4
|
||||
|
@ -680,8 +679,8 @@ class TestImageDataDeserializer(test_utils.BaseTestCase):
|
|||
data = output.pop('data')
|
||||
self.assertEqual(b'YYYY', data.read())
|
||||
|
||||
def test_stage_if_image_import_is_disabled(self):
|
||||
self.config(enable_image_import=False)
|
||||
def test_stage_without_glance_direct(self):
|
||||
self.config(enabled_import_methods=['web-download'])
|
||||
req = unit_test_utils.get_fake_request()
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
self.deserializer.stage,
|
||||
|
@ -690,7 +689,6 @@ class TestImageDataDeserializer(test_utils.BaseTestCase):
|
|||
def test_stage_raises_invalid_content_type(self):
|
||||
# TODO(abhishekk): change this when import methods are
|
||||
# listed in the config file
|
||||
self.config(enable_image_import=True)
|
||||
req = unit_test_utils.get_fake_request()
|
||||
req.headers['Content-Type'] = 'application/json'
|
||||
self.assertRaises(webob.exc.HTTPUnsupportedMediaType,
|
||||
|
|
|
@ -2222,7 +2222,6 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
|
||||
def test_delete_uploading_status_image(self):
|
||||
"""Ensure status of uploading image is updated (LP bug #1733289)"""
|
||||
self.config(enable_image_import=True)
|
||||
request = unit_test_utils.get_fake_request(is_admin=True)
|
||||
image = self.db.image_create(request.context, {'status': 'uploading'})
|
||||
image_id = image['id']
|
||||
|
@ -3164,7 +3163,6 @@ class TestImagesDeserializer(test_utils.BaseTestCase):
|
|||
sorted(output['filters']['tags']))
|
||||
|
||||
def test_image_import(self):
|
||||
self.config(enable_image_import=True)
|
||||
# Bug 1754634: make sure that what's considered valid
|
||||
# is determined by the config option
|
||||
self.config(enabled_import_methods=['party-time'])
|
||||
|
@ -3179,15 +3177,7 @@ class TestImagesDeserializer(test_utils.BaseTestCase):
|
|||
expected = {"body": import_body}
|
||||
self.assertEqual(expected, output)
|
||||
|
||||
def test_import_image_disabled(self):
|
||||
self.config(enable_image_import=False)
|
||||
request = unit_test_utils.get_fake_request()
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
self.deserializer.import_image,
|
||||
request)
|
||||
|
||||
def test_import_image_invalid_body(self):
|
||||
self.config(enable_image_import=True)
|
||||
request = unit_test_utils.get_fake_request()
|
||||
import_body = {
|
||||
"method1": {
|
||||
|
@ -3200,7 +3190,6 @@ class TestImagesDeserializer(test_utils.BaseTestCase):
|
|||
request)
|
||||
|
||||
def test_import_image_invalid_input(self):
|
||||
self.config(enable_image_import=True)
|
||||
request = unit_test_utils.get_fake_request()
|
||||
import_body = {
|
||||
"method": {
|
||||
|
@ -3225,7 +3214,6 @@ class TestImagesDeserializer(test_utils.BaseTestCase):
|
|||
KNOWN_IMPORT_METHODS = ['glance-direct', 'web-download']
|
||||
|
||||
def test_import_image_invalid_import_method(self):
|
||||
self.config(enable_image_import=True)
|
||||
# Bug 1754634: make sure that what's considered valid
|
||||
# is determined by the config option. So put known bad
|
||||
# name in config, and known good name in request
|
||||
|
@ -3624,17 +3612,6 @@ class TestImagesSerializer(test_utils.BaseTestCase):
|
|||
headers = response.headers.keys()
|
||||
self.assertNotIn(header_name, headers)
|
||||
|
||||
# TODO(rosmaita): remove this test when the enable_image_import
|
||||
# option is removed
|
||||
def test_create_has_no_import_methods_header(self):
|
||||
header_name = 'OpenStack-image-import-methods'
|
||||
self.config(enable_image_import=False)
|
||||
response = webob.Response()
|
||||
self.serializer.create(response, self.fixtures[0])
|
||||
self.assertEqual(http.CREATED, response.status_int)
|
||||
headers = response.headers.keys()
|
||||
self.assertNotIn(header_name, headers)
|
||||
|
||||
def test_update(self):
|
||||
expected = {
|
||||
'id': UUID1,
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
---
|
||||
prelude: >
|
||||
Removed the deprecated 'enable_image_import' config option. Image import
|
||||
will be always enabled from this release onwards as designed.
|
||||
upgrade:
|
||||
- |
|
||||
As Image Import will be always enabled, care needs to be taken that it is
|
||||
configured properly from this release forward. The 'enable_image_import'
|
||||
option is silently ignored.
|
Loading…
Reference in New Issue