From 1830870718fe7472b47037f3331cfe59b5bdda07 Mon Sep 17 00:00:00 2001 From: Ken'ichi Ohmichi Date: Mon, 13 Apr 2015 09:21:46 +0000 Subject: [PATCH] Add min/max of API microversions to version API As nova-spec api-microversions, versions API needs to expose minimum and maximum microversions to version API, because clients need to know available microversions through the API. That is very important for the interoperability. This patch adds these versions as the nova-spec mentioned. Note: As v2(not v2.1) API change manner, we have added new extensions if changing API. However, this patch doesn't add a new extension even if adding new parameters "version" and "min_version" because version API is independent from both v2 and v2.1 APIs. Closes-Bug: #1443375 Change-Id: Id464a07d624d0e228fe0aa66a04c8e51f292ba0c --- doc/api_samples/versions/versions-get-resp.json | 4 ++++ nova/api/openstack/compute/versions.py | 5 +++++ nova/api/openstack/compute/views/versions.py | 2 ++ .../versions/versions-get-resp.json.tpl | 4 ++++ .../unit/api/openstack/compute/test_versions.py | 14 ++++++++++++++ 5 files changed, 29 insertions(+) diff --git a/doc/api_samples/versions/versions-get-resp.json b/doc/api_samples/versions/versions-get-resp.json index 371e0ccc95d5..2b456fd73ab1 100644 --- a/doc/api_samples/versions/versions-get-resp.json +++ b/doc/api_samples/versions/versions-get-resp.json @@ -9,6 +9,8 @@ } ], "status": "SUPPORTED", + "version": "", + "min_version": "", "updated": "2011-01-21T11:33:21Z" }, { @@ -20,6 +22,8 @@ } ], "status": "CURRENT", + "version": "2.3", + "min_version": "2.1", "updated": "2013-07-23T11:33:21Z" } ] diff --git a/nova/api/openstack/compute/versions.py b/nova/api/openstack/compute/versions.py index d6a633f3ba53..4b727de32061 100644 --- a/nova/api/openstack/compute/versions.py +++ b/nova/api/openstack/compute/versions.py @@ -15,6 +15,7 @@ from oslo_config import cfg +from nova.api.openstack import api_version_request from nova.api.openstack.compute.views import versions as views_versions from nova.api.openstack import wsgi @@ -36,6 +37,8 @@ VERSIONS = { "v2.0": { "id": "v2.0", "status": "SUPPORTED", + "version": "", + "min_version": "", "updated": "2011-01-21T11:33:21Z", "links": [ { @@ -54,6 +57,8 @@ VERSIONS = { "v2.1": { "id": "v2.1", "status": "CURRENT", + "version": api_version_request._MAX_API_VERSION, + "min_version": api_version_request._MIN_API_VERSION, "updated": "2013-07-23T11:33:21Z", "links": [ { diff --git a/nova/api/openstack/compute/views/versions.py b/nova/api/openstack/compute/views/versions.py index cf76c2be8d85..237826a344aa 100644 --- a/nova/api/openstack/compute/views/versions.py +++ b/nova/api/openstack/compute/views/versions.py @@ -55,6 +55,8 @@ class ViewBuilder(common.ViewBuilder): version_objs.append({ "id": version['id'], "status": version['status'], + "version": version['version'], + "min_version": version['min_version'], "updated": version['updated'], "links": self._build_links(version), }) diff --git a/nova/tests/functional/api_samples/versions/versions-get-resp.json.tpl b/nova/tests/functional/api_samples/versions/versions-get-resp.json.tpl index 371e0ccc95d5..2b456fd73ab1 100644 --- a/nova/tests/functional/api_samples/versions/versions-get-resp.json.tpl +++ b/nova/tests/functional/api_samples/versions/versions-get-resp.json.tpl @@ -9,6 +9,8 @@ } ], "status": "SUPPORTED", + "version": "", + "min_version": "", "updated": "2011-01-21T11:33:21Z" }, { @@ -20,6 +22,8 @@ } ], "status": "CURRENT", + "version": "2.3", + "min_version": "2.1", "updated": "2013-07-23T11:33:21Z" } ] diff --git a/nova/tests/unit/api/openstack/compute/test_versions.py b/nova/tests/unit/api/openstack/compute/test_versions.py index 46cd4f91e71a..9b235c782a7d 100644 --- a/nova/tests/unit/api/openstack/compute/test_versions.py +++ b/nova/tests/unit/api/openstack/compute/test_versions.py @@ -45,6 +45,8 @@ EXP_VERSIONS = { "v2.0": { "id": "v2.0", "status": "SUPPORTED", + "version": "", + "min_version": "", "updated": "2011-01-21T11:33:21Z", "links": [ { @@ -63,6 +65,8 @@ EXP_VERSIONS = { "v2.1": { "id": "v2.1", "status": "CURRENT", + "version": "2.3", + "min_version": "2.1", "updated": "2013-07-23T11:33:21Z", "links": [ { @@ -98,6 +102,8 @@ class VersionsTestV20(test.NoDBTestCase): { "id": "v2.0", "status": "SUPPORTED", + "version": "", + "min_version": "", "updated": "2011-01-21T11:33:21Z", "links": [ { @@ -108,6 +114,8 @@ class VersionsTestV20(test.NoDBTestCase): { "id": "v2.1", "status": "CURRENT", + "version": "2.3", + "min_version": "2.1", "updated": "2013-07-23T11:33:21Z", "links": [ { @@ -139,6 +147,8 @@ class VersionsTestV20(test.NoDBTestCase): "version": { "id": "v2.0", "status": "SUPPORTED", + "version": "", + "min_version": "", "updated": "2011-01-21T11:33:21Z", "links": [ { @@ -291,6 +301,8 @@ class VersionsViewBuilderTests(test.NoDBTestCase): "v3.2.1": { "id": "3.2.1", "status": "CURRENT", + "version": "2.3", + "min_version": "2.1", "updated": "2011-07-18T11:30:00Z", } } @@ -300,6 +312,8 @@ class VersionsViewBuilderTests(test.NoDBTestCase): { "id": "3.2.1", "status": "CURRENT", + "version": "2.3", + "min_version": "2.1", "updated": "2011-07-18T11:30:00Z", "links": [ {