From bbb3ede89596fb8d9dd10754f91dcdac76bd52f1 Mon Sep 17 00:00:00 2001 From: Erno Kuvaja Date: Tue, 30 Jun 2020 16:44:10 +0100 Subject: [PATCH] Removal of 'enable_v2_api' Removal of config option 'enable_v2_api' and its related operations and tests. Change-Id: Ic83e7e8077b3fc939990c1f8e9c99b13b7fcd7ad --- glance/api/__init__.py | 2 - glance/api/middleware/version_negotiation.py | 25 ++++++------- glance/api/versions.py | 37 +++++++++---------- glance/common/config.py | 24 ------------ glance/tests/functional/__init__.py | 3 -- glance/tests/functional/test_api.py | 1 - glance/tests/functional/v2/test_images.py | 16 -------- ...leanup-enable_v2_api-9b9b467f4ae8c3b1.yaml | 5 +++ 8 files changed, 35 insertions(+), 78 deletions(-) create mode 100644 releasenotes/notes/cleanup-enable_v2_api-9b9b467f4ae8c3b1.yaml diff --git a/glance/api/__init__.py b/glance/api/__init__.py index b62d4a11a8..8327ae7624 100644 --- a/glance/api/__init__.py +++ b/glance/api/__init__.py @@ -20,6 +20,4 @@ CONF = cfg.CONF def root_app_factory(loader, global_conf, **local_conf): - if not CONF.enable_v2_api and '/v2' in local_conf: - del local_conf['/v2'] return paste.urlmap.urlmap_factory(loader, global_conf, **local_conf) diff --git a/glance/api/middleware/version_negotiation.py b/glance/api/middleware/version_negotiation.py index 7e452ed9cd..2cd3dad1d2 100644 --- a/glance/api/middleware/version_negotiation.py +++ b/glance/api/middleware/version_negotiation.py @@ -72,19 +72,18 @@ class VersionNegotiationFilter(wsgi.Middleware): def _get_allowed_versions(self): allowed_versions = {} - if CONF.enable_v2_api: - allowed_versions['v2'] = 2 - allowed_versions['v2.0'] = 2 - allowed_versions['v2.1'] = 2 - allowed_versions['v2.2'] = 2 - allowed_versions['v2.3'] = 2 - allowed_versions['v2.4'] = 2 - allowed_versions['v2.5'] = 2 - allowed_versions['v2.6'] = 2 - allowed_versions['v2.7'] = 2 - allowed_versions['v2.9'] = 2 - if CONF.enabled_backends: - allowed_versions['v2.8'] = 2 + allowed_versions['v2'] = 2 + allowed_versions['v2.0'] = 2 + allowed_versions['v2.1'] = 2 + allowed_versions['v2.2'] = 2 + allowed_versions['v2.3'] = 2 + allowed_versions['v2.4'] = 2 + allowed_versions['v2.5'] = 2 + allowed_versions['v2.6'] = 2 + allowed_versions['v2.7'] = 2 + allowed_versions['v2.9'] = 2 + if CONF.enabled_backends: + allowed_versions['v2.8'] = 2 return allowed_versions def _match_version_string(self, subject): diff --git a/glance/api/versions.py b/glance/api/versions.py index 308dd6e29b..f3b923d0f9 100644 --- a/glance/api/versions.py +++ b/glance/api/versions.py @@ -76,27 +76,26 @@ class Controller(object): } version_objs = [] - if CONF.enable_v2_api: - if CONF.enabled_backends: - version_objs.extend([ - build_version_object(2.10, 'v2', 'CURRENT'), - build_version_object(2.9, 'v2', 'SUPPORTED'), - build_version_object(2.8, 'v2', 'SUPPORTED') - ]) - else: - version_objs.extend([ - build_version_object(2.9, 'v2', 'CURRENT'), - ]) + if CONF.enabled_backends: version_objs.extend([ - build_version_object(2.7, 'v2', 'SUPPORTED'), - build_version_object(2.6, 'v2', 'SUPPORTED'), - build_version_object(2.5, 'v2', 'SUPPORTED'), - build_version_object(2.4, 'v2', 'SUPPORTED'), - build_version_object(2.3, 'v2', 'SUPPORTED'), - build_version_object(2.2, 'v2', 'SUPPORTED'), - build_version_object(2.1, 'v2', 'SUPPORTED'), - build_version_object(2.0, 'v2', 'SUPPORTED'), + build_version_object(2.10, 'v2', 'CURRENT'), + build_version_object(2.9, 'v2', 'SUPPORTED'), + build_version_object(2.8, 'v2', 'SUPPORTED') ]) + else: + version_objs.extend([ + build_version_object(2.9, 'v2', 'CURRENT'), + ]) + version_objs.extend([ + build_version_object(2.7, 'v2', 'SUPPORTED'), + build_version_object(2.6, 'v2', 'SUPPORTED'), + build_version_object(2.5, 'v2', 'SUPPORTED'), + build_version_object(2.4, 'v2', 'SUPPORTED'), + build_version_object(2.3, 'v2', 'SUPPORTED'), + build_version_object(2.2, 'v2', 'SUPPORTED'), + build_version_object(2.1, 'v2', 'SUPPORTED'), + build_version_object(2.0, 'v2', 'SUPPORTED'), + ]) status = explicit and http_client.OK or http_client.MULTIPLE_CHOICES response = webob.Response(request=req, diff --git a/glance/common/config.py b/glance/common/config.py index c2f6b0a994..2f9bf9193b 100644 --- a/glance/common/config.py +++ b/glance/common/config.py @@ -457,30 +457,6 @@ Possible values: Related options: * None -""")), - cfg.BoolOpt('enable_v2_api', - default=True, - deprecated_reason=_('The Images (Glance) version 1 API has ' - 'been DEPRECATED in the Newton release. ' - 'It will be removed on or after Pike ' - 'release, following the standard ' - 'OpenStack deprecation policy. Once we ' - 'remove the Images (Glance) v1 API, only ' - 'the Images (Glance) v2 API can be ' - 'deployed and will be enabled by default ' - 'making this option redundant.'), - deprecated_since='Newton', - help=_(""" -Deploy the v2 OpenStack Images API. - -When this option is set to ``True``, Glance service will respond -to requests on registered endpoints conforming to the v2 OpenStack -Images API. - -Possible values: - * True - * False - """)), cfg.HostAddressOpt('pydev_worker_debug_host', sample_default='localhost', diff --git a/glance/tests/functional/__init__.py b/glance/tests/functional/__init__.py index 793b8279c9..50f11778b2 100644 --- a/glance/tests/functional/__init__.py +++ b/glance/tests/functional/__init__.py @@ -88,7 +88,6 @@ class BaseServer(object): self.show_image_direct_url = False self.show_multiple_locations = False self.property_protection_file = '' - self.enable_v2_api = True self.needs_database = False self.log_file = None self.sock = sock @@ -428,7 +427,6 @@ sql_connection = %(sql_connection)s show_image_direct_url = %(show_image_direct_url)s show_multiple_locations = %(show_multiple_locations)s user_storage_quota = %(user_storage_quota)s -enable_v2_api = %(enable_v2_api)s lock_path = %(lock_path)s property_protection_file = %(property_protection_file)s property_protection_rule_format = %(property_protection_rule_format)s @@ -602,7 +600,6 @@ sql_connection = %(sql_connection)s show_image_direct_url = %(show_image_direct_url)s show_multiple_locations = %(show_multiple_locations)s user_storage_quota = %(user_storage_quota)s -enable_v2_api = %(enable_v2_api)s lock_path = %(lock_path)s property_protection_file = %(property_protection_file)s property_protection_rule_format = %(property_protection_rule_format)s diff --git a/glance/tests/functional/test_api.py b/glance/tests/functional/test_api.py index c60b6e529c..35b06266e7 100644 --- a/glance/tests/functional/test_api.py +++ b/glance/tests/functional/test_api.py @@ -100,7 +100,6 @@ class TestApiVersions(functional.FunctionalTest): self.assertEqual(versions, content) def test_v2_api_configuration(self): - self.api_server.enable_v2_api = True self.start_servers(**self.__dict__.copy()) url = 'http://127.0.0.1:%d/v%%s/' % self.api_port diff --git a/glance/tests/functional/v2/test_images.py b/glance/tests/functional/v2/test_images.py index 4dbaf7f43e..7b6c3cda67 100644 --- a/glance/tests/functional/v2/test_images.py +++ b/glance/tests/functional/v2/test_images.py @@ -3640,22 +3640,6 @@ class TestImageDirectURLVisibility(functional.FunctionalTest): base_headers.update(custom_headers or {}) return base_headers - def test_v2_not_enabled(self): - self.api_server.enable_v2_api = False - self.start_servers(**self.__dict__.copy()) - path = self._url('/v2/images') - response = requests.get(path, headers=self._headers()) - self.assertEqual(http.MULTIPLE_CHOICES, response.status_code) - self.stop_servers() - - def test_v2_enabled(self): - self.api_server.enable_v2_api = True - self.start_servers(**self.__dict__.copy()) - path = self._url('/v2/images') - response = requests.get(path, headers=self._headers()) - self.assertEqual(http.OK, response.status_code) - self.stop_servers() - def test_image_direct_url_visible(self): self.api_server.show_image_direct_url = True diff --git a/releasenotes/notes/cleanup-enable_v2_api-9b9b467f4ae8c3b1.yaml b/releasenotes/notes/cleanup-enable_v2_api-9b9b467f4ae8c3b1.yaml new file mode 100644 index 0000000000..bd96f04382 --- /dev/null +++ b/releasenotes/notes/cleanup-enable_v2_api-9b9b467f4ae8c3b1.yaml @@ -0,0 +1,5 @@ +--- +deprecations: + - | + The deprecated 'enable_v2_api' config option has been + removed.