Remove deprecated 'enable_image_import' option
Change-Id: I7752b30f0fabed07282d959e1ad313af072fdea5
This commit is contained in:
parent
2a1ce3a498
commit
95327964e3
@ -14,10 +14,8 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
import webob.exc
|
|
||||||
|
|
||||||
from glance.common import wsgi
|
from glance.common import wsgi
|
||||||
from glance.i18n import _
|
|
||||||
|
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
@ -25,12 +23,6 @@ CONF = cfg.CONF
|
|||||||
|
|
||||||
class InfoController(object):
|
class InfoController(object):
|
||||||
def get_image_import(self, req):
|
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.
|
# TODO(jokke): All the rest of the boundaries should be implemented.
|
||||||
import_methods = {
|
import_methods = {
|
||||||
'description': 'Import methods available.',
|
'description': 'Import methods available.',
|
||||||
|
@ -382,8 +382,8 @@ class RequestDeserializer(wsgi.JSONRequestDeserializer):
|
|||||||
return {'size': image_size, 'data': request.body_file}
|
return {'size': image_size, 'data': request.body_file}
|
||||||
|
|
||||||
def stage(self, request):
|
def stage(self, request):
|
||||||
if not CONF.enable_image_import:
|
if "glance-direct" not in CONF.enabled_import_methods:
|
||||||
msg = _("Image import is not supported at this site.")
|
msg = _("'glance-direct' method is not available at this site.")
|
||||||
raise webob.exc.HTTPNotFound(explanation=msg)
|
raise webob.exc.HTTPNotFound(explanation=msg)
|
||||||
try:
|
try:
|
||||||
request.get_content_type(('application/octet-stream',))
|
request.get_content_type(('application/octet-stream',))
|
||||||
|
@ -287,9 +287,7 @@ class ImagesController(object):
|
|||||||
try:
|
try:
|
||||||
image = image_repo.get(image_id)
|
image = image_repo.get(image_id)
|
||||||
|
|
||||||
# NOTE(abhishekk): If 'image-import' is supported and image status
|
if image.status == 'uploading':
|
||||||
# is uploading then delete image data from the staging area.
|
|
||||||
if CONF.enable_image_import and image.status == 'uploading':
|
|
||||||
file_path = str(CONF.node_staging_uri + '/' + image.image_id)
|
file_path = str(CONF.node_staging_uri + '/' + image.image_id)
|
||||||
self.store_api.delete_from_backend(file_path)
|
self.store_api.delete_from_backend(file_path)
|
||||||
|
|
||||||
@ -822,9 +820,6 @@ class RequestDeserializer(wsgi.JSONRequestDeserializer):
|
|||||||
raise webob.exc.HTTPBadRequest(explanation=msg)
|
raise webob.exc.HTTPBadRequest(explanation=msg)
|
||||||
|
|
||||||
def import_image(self, request):
|
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)
|
body = self._get_request_body(request)
|
||||||
self._validate_import_body(body)
|
self._validate_import_body(body)
|
||||||
return {'body': body}
|
return {'body': body}
|
||||||
@ -902,9 +897,6 @@ class ResponseSerializer(wsgi.JSONResponseSerializer):
|
|||||||
response.status_int = http.CREATED
|
response.status_int = http.CREATED
|
||||||
self.show(response, image)
|
self.show(response, image)
|
||||||
response.location = self._get_image_href(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
|
# according to RFC7230, headers should not have empty fields
|
||||||
# see http://httpwg.org/specs/rfc7230.html#field.components
|
# see http://httpwg.org/specs/rfc7230.html#field.components
|
||||||
if CONF.enabled_import_methods:
|
if CONF.enabled_import_methods:
|
||||||
|
@ -700,32 +700,8 @@ Possible values:
|
|||||||
|
|
||||||
Related options:
|
Related options:
|
||||||
* [task]/work_dir
|
* [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',
|
cfg.ListOpt('enabled_import_methods',
|
||||||
item_type=cfg.types.String(quotes=True),
|
item_type=cfg.types.String(quotes=True),
|
||||||
bounds=True,
|
bounds=True,
|
||||||
@ -736,8 +712,7 @@ List of enabled Image Import Methods
|
|||||||
Both 'glance-direct' and 'web-download' are enabled by default.
|
Both 'glance-direct' and 'web-download' are enabled by default.
|
||||||
|
|
||||||
Related options:
|
Related options:
|
||||||
* [DEFAULT]/node_staging_uri
|
* [DEFAULT]/node_staging_uri""")),
|
||||||
* [DEFAULT]/enable_image_import""")),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
|
@ -76,9 +76,6 @@ class Server(object):
|
|||||||
self.property_protection_file = ''
|
self.property_protection_file = ''
|
||||||
self.enable_v1_api = True
|
self.enable_v1_api = True
|
||||||
self.enable_v2_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_v1_registry = True
|
||||||
self.enable_v2_registry = True
|
self.enable_v2_registry = True
|
||||||
self.needs_database = False
|
self.needs_database = False
|
||||||
@ -351,7 +348,6 @@ show_multiple_locations = %(show_multiple_locations)s
|
|||||||
user_storage_quota = %(user_storage_quota)s
|
user_storage_quota = %(user_storage_quota)s
|
||||||
enable_v1_api = %(enable_v1_api)s
|
enable_v1_api = %(enable_v1_api)s
|
||||||
enable_v2_api = %(enable_v2_api)s
|
enable_v2_api = %(enable_v2_api)s
|
||||||
enable_image_import = %(enable_image_import)s
|
|
||||||
lock_path = %(lock_path)s
|
lock_path = %(lock_path)s
|
||||||
property_protection_file = %(property_protection_file)s
|
property_protection_file = %(property_protection_file)s
|
||||||
property_protection_rule_format = %(property_protection_rule_format)s
|
property_protection_rule_format = %(property_protection_rule_format)s
|
||||||
|
@ -137,7 +137,6 @@ class TestImages(functional.FunctionalTest):
|
|||||||
self.stop_servers()
|
self.stop_servers()
|
||||||
|
|
||||||
def test_image_import_using_glance_direct(self):
|
def test_image_import_using_glance_direct(self):
|
||||||
self.api_server.enable_image_import = True
|
|
||||||
self.start_servers(**self.__dict__.copy())
|
self.start_servers(**self.__dict__.copy())
|
||||||
|
|
||||||
# Image list should be empty
|
# Image list should be empty
|
||||||
@ -278,7 +277,6 @@ class TestImages(functional.FunctionalTest):
|
|||||||
self.stop_servers()
|
self.stop_servers()
|
||||||
|
|
||||||
def test_image_import_using_web_download(self):
|
def test_image_import_using_web_download(self):
|
||||||
self.api_server.enable_image_import = True
|
|
||||||
self.config(node_staging_uri="file:///tmp/staging/")
|
self.config(node_staging_uri="file:///tmp/staging/")
|
||||||
self.start_servers(**self.__dict__.copy())
|
self.start_servers(**self.__dict__.copy())
|
||||||
|
|
||||||
|
@ -208,12 +208,6 @@ class VersionNegotiationTest(base.IsolatedUnitTest):
|
|||||||
resp = self.middleware.process_request(request)
|
resp = self.middleware.process_request(request)
|
||||||
self.assertIsInstance(resp, versions.Controller)
|
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):
|
class VersionsAndNegotiationTest(VersionNegotiationTest, VersionsTest):
|
||||||
|
|
||||||
|
@ -13,8 +13,6 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import webob.exc
|
|
||||||
|
|
||||||
import glance.api.v2.discovery
|
import glance.api.v2.discovery
|
||||||
import glance.tests.unit.utils as unit_test_utils
|
import glance.tests.unit.utils as unit_test_utils
|
||||||
import glance.tests.utils as test_utils
|
import glance.tests.utils as test_utils
|
||||||
@ -26,20 +24,19 @@ class TestInfoControllers(test_utils.BaseTestCase):
|
|||||||
super(TestInfoControllers, self).setUp()
|
super(TestInfoControllers, self).setUp()
|
||||||
self.controller = glance.api.v2.discovery.InfoController()
|
self.controller = glance.api.v2.discovery.InfoController()
|
||||||
|
|
||||||
def test_get_import_info_when_import_not_enabled(self):
|
def test_get_import_info_with_empty_method_list(self):
|
||||||
"""When import not enabled, should return 404 just like v2.5"""
|
"""When methods list is empty, should still return import methods"""
|
||||||
self.config(enable_image_import=False)
|
self.config(enabled_import_methods=[])
|
||||||
req = unit_test_utils.get_fake_request()
|
req = unit_test_utils.get_fake_request()
|
||||||
self.assertRaises(webob.exc.HTTPNotFound,
|
output = self.controller.get_image_import(req)
|
||||||
self.controller.get_image_import,
|
self.assertIn('import-methods', output)
|
||||||
req)
|
self.assertEqual([], output['import-methods']['value'])
|
||||||
|
|
||||||
def test_get_import_info(self):
|
def test_get_import_info(self):
|
||||||
# TODO(rosmaita): change this when import methods are
|
# TODO(rosmaita): change this when import methods are
|
||||||
# listed in the config file
|
# listed in the config file
|
||||||
import_methods = ['glance-direct', 'web-download']
|
import_methods = ['glance-direct', 'web-download']
|
||||||
|
|
||||||
self.config(enable_image_import=True)
|
|
||||||
req = unit_test_utils.get_fake_request()
|
req = unit_test_utils.get_fake_request()
|
||||||
output = self.controller.get_image_import(req)
|
output = self.controller.get_image_import(req)
|
||||||
self.assertIn('import-methods', output)
|
self.assertIn('import-methods', output)
|
||||||
|
@ -671,7 +671,6 @@ class TestImageDataDeserializer(test_utils.BaseTestCase):
|
|||||||
self.deserializer.upload, request)
|
self.deserializer.upload, request)
|
||||||
|
|
||||||
def test_stage(self):
|
def test_stage(self):
|
||||||
self.config(enable_image_import=True)
|
|
||||||
req = unit_test_utils.get_fake_request()
|
req = unit_test_utils.get_fake_request()
|
||||||
req.headers['Content-Type'] = 'application/octet-stream'
|
req.headers['Content-Type'] = 'application/octet-stream'
|
||||||
req.headers['Content-Length'] = 4
|
req.headers['Content-Length'] = 4
|
||||||
@ -680,8 +679,8 @@ class TestImageDataDeserializer(test_utils.BaseTestCase):
|
|||||||
data = output.pop('data')
|
data = output.pop('data')
|
||||||
self.assertEqual(b'YYYY', data.read())
|
self.assertEqual(b'YYYY', data.read())
|
||||||
|
|
||||||
def test_stage_if_image_import_is_disabled(self):
|
def test_stage_without_glance_direct(self):
|
||||||
self.config(enable_image_import=False)
|
self.config(enabled_import_methods=['web-download'])
|
||||||
req = unit_test_utils.get_fake_request()
|
req = unit_test_utils.get_fake_request()
|
||||||
self.assertRaises(webob.exc.HTTPNotFound,
|
self.assertRaises(webob.exc.HTTPNotFound,
|
||||||
self.deserializer.stage,
|
self.deserializer.stage,
|
||||||
@ -690,7 +689,6 @@ class TestImageDataDeserializer(test_utils.BaseTestCase):
|
|||||||
def test_stage_raises_invalid_content_type(self):
|
def test_stage_raises_invalid_content_type(self):
|
||||||
# TODO(abhishekk): change this when import methods are
|
# TODO(abhishekk): change this when import methods are
|
||||||
# listed in the config file
|
# listed in the config file
|
||||||
self.config(enable_image_import=True)
|
|
||||||
req = unit_test_utils.get_fake_request()
|
req = unit_test_utils.get_fake_request()
|
||||||
req.headers['Content-Type'] = 'application/json'
|
req.headers['Content-Type'] = 'application/json'
|
||||||
self.assertRaises(webob.exc.HTTPUnsupportedMediaType,
|
self.assertRaises(webob.exc.HTTPUnsupportedMediaType,
|
||||||
|
@ -2222,7 +2222,6 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||||||
|
|
||||||
def test_delete_uploading_status_image(self):
|
def test_delete_uploading_status_image(self):
|
||||||
"""Ensure status of uploading image is updated (LP bug #1733289)"""
|
"""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)
|
request = unit_test_utils.get_fake_request(is_admin=True)
|
||||||
image = self.db.image_create(request.context, {'status': 'uploading'})
|
image = self.db.image_create(request.context, {'status': 'uploading'})
|
||||||
image_id = image['id']
|
image_id = image['id']
|
||||||
@ -3164,7 +3163,6 @@ class TestImagesDeserializer(test_utils.BaseTestCase):
|
|||||||
sorted(output['filters']['tags']))
|
sorted(output['filters']['tags']))
|
||||||
|
|
||||||
def test_image_import(self):
|
def test_image_import(self):
|
||||||
self.config(enable_image_import=True)
|
|
||||||
# Bug 1754634: make sure that what's considered valid
|
# Bug 1754634: make sure that what's considered valid
|
||||||
# is determined by the config option
|
# is determined by the config option
|
||||||
self.config(enabled_import_methods=['party-time'])
|
self.config(enabled_import_methods=['party-time'])
|
||||||
@ -3179,15 +3177,7 @@ class TestImagesDeserializer(test_utils.BaseTestCase):
|
|||||||
expected = {"body": import_body}
|
expected = {"body": import_body}
|
||||||
self.assertEqual(expected, output)
|
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):
|
def test_import_image_invalid_body(self):
|
||||||
self.config(enable_image_import=True)
|
|
||||||
request = unit_test_utils.get_fake_request()
|
request = unit_test_utils.get_fake_request()
|
||||||
import_body = {
|
import_body = {
|
||||||
"method1": {
|
"method1": {
|
||||||
@ -3200,7 +3190,6 @@ class TestImagesDeserializer(test_utils.BaseTestCase):
|
|||||||
request)
|
request)
|
||||||
|
|
||||||
def test_import_image_invalid_input(self):
|
def test_import_image_invalid_input(self):
|
||||||
self.config(enable_image_import=True)
|
|
||||||
request = unit_test_utils.get_fake_request()
|
request = unit_test_utils.get_fake_request()
|
||||||
import_body = {
|
import_body = {
|
||||||
"method": {
|
"method": {
|
||||||
@ -3225,7 +3214,6 @@ class TestImagesDeserializer(test_utils.BaseTestCase):
|
|||||||
KNOWN_IMPORT_METHODS = ['glance-direct', 'web-download']
|
KNOWN_IMPORT_METHODS = ['glance-direct', 'web-download']
|
||||||
|
|
||||||
def test_import_image_invalid_import_method(self):
|
def test_import_image_invalid_import_method(self):
|
||||||
self.config(enable_image_import=True)
|
|
||||||
# Bug 1754634: make sure that what's considered valid
|
# Bug 1754634: make sure that what's considered valid
|
||||||
# is determined by the config option. So put known bad
|
# is determined by the config option. So put known bad
|
||||||
# name in config, and known good name in request
|
# name in config, and known good name in request
|
||||||
@ -3624,17 +3612,6 @@ class TestImagesSerializer(test_utils.BaseTestCase):
|
|||||||
headers = response.headers.keys()
|
headers = response.headers.keys()
|
||||||
self.assertNotIn(header_name, headers)
|
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):
|
def test_update(self):
|
||||||
expected = {
|
expected = {
|
||||||
'id': UUID1,
|
'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
Block a user