From 48fe8d17e38193c63b6aea98d73ce13a835cd0d0 Mon Sep 17 00:00:00 2001 From: He Jie Xu Date: Fri, 30 Jun 2017 14:47:20 +0800 Subject: [PATCH] Ensure the JSON-Schema covers the legacy v2 API The legacy v2 API compatible mode support the protection of JSON-Schema. The input body will be validated with JSON-Schema, and the extra invalid parameters will be filtered out of the input body instead of return HTTPBadRequest 400. But some of API are missing that protection, the JSON-Schema validation was limited to the v2.1 API. This patch ensures those schema covers the legacy v2 API. Change-Id: Ie165b2a79efd56a299d2d4ebe40a6904a340414f Closes-Bug: #1701451 (cherry picked from commit aaeea4bf39377c4109f6b2857794ee0e7d51e786) --- nova/api/openstack/compute/evacuate.py | 2 +- nova/api/openstack/compute/migrate_server.py | 2 +- nova/api/openstack/compute/server_groups.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nova/api/openstack/compute/evacuate.py b/nova/api/openstack/compute/evacuate.py index cd847fad706f..72362afaaca2 100644 --- a/nova/api/openstack/compute/evacuate.py +++ b/nova/api/openstack/compute/evacuate.py @@ -74,7 +74,7 @@ class EvacuateController(wsgi.Controller): # backwards compatibility reasons. @extensions.expected_errors((400, 404, 409)) @wsgi.action('evacuate') - @validation.schema(evacuate.evacuate, "2.1", "2.13") + @validation.schema(evacuate.evacuate, "2.0", "2.13") @validation.schema(evacuate.evacuate_v214, "2.14", "2.28") @validation.schema(evacuate.evacuate_v2_29, "2.29") def _evacuate(self, req, id, body): diff --git a/nova/api/openstack/compute/migrate_server.py b/nova/api/openstack/compute/migrate_server.py index 4b5b81d5d837..44bf0a57f71c 100644 --- a/nova/api/openstack/compute/migrate_server.py +++ b/nova/api/openstack/compute/migrate_server.py @@ -65,7 +65,7 @@ class MigrateServerController(wsgi.Controller): @wsgi.response(202) @extensions.expected_errors((400, 404, 409)) @wsgi.action('os-migrateLive') - @validation.schema(migrate_server.migrate_live, "2.1", "2.24") + @validation.schema(migrate_server.migrate_live, "2.0", "2.24") @validation.schema(migrate_server.migrate_live_v2_25, "2.25", "2.29") @validation.schema(migrate_server.migrate_live_v2_30, "2.30") def _migrate_live(self, req, id, body): diff --git a/nova/api/openstack/compute/server_groups.py b/nova/api/openstack/compute/server_groups.py index 412912288cdc..dfd2380ec2ab 100644 --- a/nova/api/openstack/compute/server_groups.py +++ b/nova/api/openstack/compute/server_groups.py @@ -131,7 +131,7 @@ class ServerGroupController(wsgi.Controller): @wsgi.Controller.api_version("2.1") @extensions.expected_errors((400, 403)) - @validation.schema(schema.create, "2.1", "2.14") + @validation.schema(schema.create, "2.0", "2.14") @validation.schema(schema.create_v215, "2.15") def create(self, req, body): """Creates a new server group."""