From 8639559f61b52f98715d6899ed3e543e2be280ea Mon Sep 17 00:00:00 2001 From: He Jie Xu Date: Wed, 27 Jul 2016 10:10:56 +0800 Subject: [PATCH] Remove the useless version calculation for proxy api deprecated version This patch use constant instead of the calculation for the proxy API deprecated version. This is more readable. Partially implements blueprint deprecate-api-proxies Change-Id: I5e9972643a7dd2e2559f7f9593b85618df2647c3 --- nova/api/openstack/api_version_request.py | 3 ++- nova/api/openstack/compute/limits.py | 17 +++-------------- nova/api/openstack/compute/quota_sets.py | 20 ++++++-------------- 3 files changed, 11 insertions(+), 29 deletions(-) diff --git a/nova/api/openstack/api_version_request.py b/nova/api/openstack/api_version_request.py index 52f7256cad78..11f7280332da 100644 --- a/nova/api/openstack/api_version_request.py +++ b/nova/api/openstack/api_version_request.py @@ -102,8 +102,9 @@ _MAX_API_VERSION = "2.36" DEFAULT_API_VERSION = _MIN_API_VERSION # All the proxy APIs which related network, images and baremetal -# were deprecated after this version. +# were deprecated from 2.36. MAX_PROXY_API_SUPPORT_VERSION = '2.35' +MIN_WITHOUT_PROXY_API_SUPPORT_VERSION = '2.36' # NOTE(cyeoh): min and max versions declared as functions so we can diff --git a/nova/api/openstack/compute/limits.py b/nova/api/openstack/compute/limits.py index 3ee2557f856b..6027d9ed74a8 100644 --- a/nova/api/openstack/compute/limits.py +++ b/nova/api/openstack/compute/limits.py @@ -13,9 +13,10 @@ # License for the specific language governing permissions and limitations # under the License. -from nova.api.openstack import api_version_request from nova.api.openstack.api_version_request \ import MAX_PROXY_API_SUPPORT_VERSION +from nova.api.openstack.api_version_request \ + import MIN_WITHOUT_PROXY_API_SUPPORT_VERSION from nova.api.openstack.compute.views import limits as limits_views from nova.api.openstack import extensions from nova.api.openstack import wsgi @@ -27,18 +28,6 @@ QUOTAS = quota.QUOTAS ALIAS = 'limits' -def _get_filter_result_version(): - """Calculate the start API version which needs to filter the network - related limits. MAX_PROXY_API_SUPPORT_VERSION is the end API version - of supporting those network related limits. So we return - MAX_PROXY_API_SUPPORT_VERSION +1 in this method. - """ - filter_result_version = api_version_request.APIVersionRequest( - MAX_PROXY_API_SUPPORT_VERSION) - filter_result_version.ver_minor = filter_result_version.ver_minor + 1 - return filter_result_version.get_string() - - class LimitsController(wsgi.Controller): """Controller for accessing limits in the OpenStack API.""" @@ -47,7 +36,7 @@ class LimitsController(wsgi.Controller): def index(self, req): return self._index(req) - @wsgi.Controller.api_version(_get_filter_result_version()) # noqa + @wsgi.Controller.api_version(MIN_WITHOUT_PROXY_API_SUPPORT_VERSION) # noqa @extensions.expected_errors(()) def index(self, req): return self._index(req, filter_result=True) diff --git a/nova/api/openstack/compute/quota_sets.py b/nova/api/openstack/compute/quota_sets.py index 4236ae287757..88833f770296 100644 --- a/nova/api/openstack/compute/quota_sets.py +++ b/nova/api/openstack/compute/quota_sets.py @@ -18,9 +18,10 @@ import six import six.moves.urllib.parse as urlparse import webob -from nova.api.openstack import api_version_request from nova.api.openstack.api_version_request \ import MAX_PROXY_API_SUPPORT_VERSION +from nova.api.openstack.api_version_request \ + import MIN_WITHOUT_PROXY_API_SUPPORT_VERSION from nova.api.openstack.compute.schemas import quota_sets from nova.api.openstack import extensions from nova.api.openstack import wsgi @@ -38,15 +39,6 @@ QUOTAS = quota.QUOTAS FILTERED_QUOTAS = ["fixed_ips", "floating_ips", "networks", "security_group_rules", "security_groups"] -max_proxy_api_version_obj = api_version_request.APIVersionRequest( - MAX_PROXY_API_SUPPORT_VERSION) -api_version_without_proxy_api_obj = api_version_request.APIVersionRequest() -api_version_without_proxy_api_obj.ver_major = ( - max_proxy_api_version_obj.ver_major) -api_version_without_proxy_api_obj.ver_minor = ( - max_proxy_api_version_obj.ver_minor + 1) -API_VERSION_WITHOUT_PROXY_API = api_version_without_proxy_api_obj.get_string() - class QuotaSetsController(wsgi.Controller): @@ -103,7 +95,7 @@ class QuotaSetsController(wsgi.Controller): def show(self, req, id): return self._show(req, id, []) - @wsgi.Controller.api_version(API_VERSION_WITHOUT_PROXY_API) # noqa + @wsgi.Controller.api_version(MIN_WITHOUT_PROXY_API_SUPPORT_VERSION) # noqa def show(self, req, id): return self._show(req, id, FILTERED_QUOTAS) @@ -121,7 +113,7 @@ class QuotaSetsController(wsgi.Controller): def detail(self, req, id): return self._detail(req, id, []) - @wsgi.Controller.api_version(API_VERSION_WITHOUT_PROXY_API) # noqa + @wsgi.Controller.api_version(MIN_WITHOUT_PROXY_API_SUPPORT_VERSION) # noqa @extensions.expected_errors(()) def detail(self, req, id): return self._detail(req, id, FILTERED_QUOTAS) @@ -141,7 +133,7 @@ class QuotaSetsController(wsgi.Controller): def update(self, req, id, body): return self._update(req, id, body, []) - @wsgi.Controller.api_version(API_VERSION_WITHOUT_PROXY_API) # noqa + @wsgi.Controller.api_version(MIN_WITHOUT_PROXY_API_SUPPORT_VERSION) # noqa @extensions.expected_errors(400) @validation.schema(quota_sets.update_v236) def update(self, req, id, body): @@ -199,7 +191,7 @@ class QuotaSetsController(wsgi.Controller): def defaults(self, req, id): return self._defaults(req, id, []) - @wsgi.Controller.api_version(API_VERSION_WITHOUT_PROXY_API) # noqa + @wsgi.Controller.api_version(MIN_WITHOUT_PROXY_API_SUPPORT_VERSION) # noqa @extensions.expected_errors(()) def defaults(self, req, id): return self._defaults(req, id, FILTERED_QUOTAS)