From de82ded117910b7a7dbbc72c669c2040f10325cd Mon Sep 17 00:00:00 2001 From: Kevin Benton Date: Tue, 12 Sep 2017 14:03:50 -0700 Subject: [PATCH] Remove dead versions code The versions endpoint is now handled by Pecan and there is no way to reach this old endpoint now that we have dropped the web_framework option. Change-Id: I5d493623b107f125cb9426310f2e43612c94bb7f --- etc/api-paste.ini | 2 +- neutron/api/versions.py | 45 ++----------------- neutron/tests/etc/api-paste.ini | 2 +- .../noneutronversions-fbbdb98f350767d8.yaml | 8 ++++ 4 files changed, 13 insertions(+), 44 deletions(-) create mode 100644 releasenotes/notes/noneutronversions-fbbdb98f350767d8.yaml diff --git a/etc/api-paste.ini b/etc/api-paste.ini index 1c98cfe3676..f79088c3582 100644 --- a/etc/api-paste.ini +++ b/etc/api-paste.ini @@ -36,7 +36,7 @@ paste.filter_factory = keystonemiddleware.auth_token:filter_factory paste.filter_factory = neutron.api.extensions:plugin_aware_extension_middleware_factory [app:neutronversions] -paste.app_factory = neutron.api.versions:Versions.factory +paste.app_factory = neutron.pecan_wsgi.app:versions_factory [app:neutronapiapp_v2_0] paste.app_factory = neutron.api.v2.router:APIRouter.factory diff --git a/neutron/api/versions.py b/neutron/api/versions.py index 48f9f16321f..6d986181303 100644 --- a/neutron/api/versions.py +++ b/neutron/api/versions.py @@ -13,54 +13,15 @@ # License for the specific language governing permissions and limitations # under the License. -import oslo_i18n -import webob.dec +from debtcollector import removals -from neutron._i18n import _ -from neutron.api.views import versions as versions_view from neutron.pecan_wsgi import app as pecan_app -from neutron import wsgi class Versions(object): + @removals.remove(version="Queens", removal_version="Rocky", + message="Use neutron.pecan_wsgi.app:versions_factory") @classmethod def factory(cls, global_config, **local_config): - # TODO(kevinbenton): get rid of whole class return pecan_app.versions_factory(global_config, **local_config) - - @webob.dec.wsgify(RequestClass=wsgi.Request) - def __call__(self, req): - """Respond to a request for all Neutron API versions.""" - version_objs = [ - { - "id": "v2.0", - "status": "CURRENT", - }, - ] - - if req.path != '/': - if self.app: - return req.get_response(self.app) - language = req.best_match_language() - msg = _('Unknown API version specified') - msg = oslo_i18n.translate(msg, language) - return webob.exc.HTTPNotFound(explanation=msg) - - builder = versions_view.get_view_builder(req) - versions = [builder.build(version) for version in version_objs] - response = dict(versions=versions) - metadata = {} - - content_type = req.best_match_content_type() - body = (wsgi.Serializer(metadata=metadata). - serialize(response, content_type)) - - response = webob.Response() - response.content_type = content_type - response.body = wsgi.encode_body(body) - - return response - - def __init__(self, app): - self.app = app diff --git a/neutron/tests/etc/api-paste.ini b/neutron/tests/etc/api-paste.ini index 1c98cfe3676..f79088c3582 100644 --- a/neutron/tests/etc/api-paste.ini +++ b/neutron/tests/etc/api-paste.ini @@ -36,7 +36,7 @@ paste.filter_factory = keystonemiddleware.auth_token:filter_factory paste.filter_factory = neutron.api.extensions:plugin_aware_extension_middleware_factory [app:neutronversions] -paste.app_factory = neutron.api.versions:Versions.factory +paste.app_factory = neutron.pecan_wsgi.app:versions_factory [app:neutronapiapp_v2_0] paste.app_factory = neutron.api.v2.router:APIRouter.factory diff --git a/releasenotes/notes/noneutronversions-fbbdb98f350767d8.yaml b/releasenotes/notes/noneutronversions-fbbdb98f350767d8.yaml new file mode 100644 index 00000000000..a807eb65881 --- /dev/null +++ b/releasenotes/notes/noneutronversions-fbbdb98f350767d8.yaml @@ -0,0 +1,8 @@ +--- +deprecations: + - | + The api-paste entrypoint ``neutron.api.versions:Versions.factory`` has been + deprecated and will be removed in the Rocky release. Please update your + api-paste.ini file to use the one that ships with Queens or update any + references to the Versions factory to point to + ``neutron.pecan_wsgi.app:versions_factory`` instead.