From 2e69bc5b2cba35a91a7fa404c9899672205f3659 Mon Sep 17 00:00:00 2001 From: wanghao Date: Tue, 20 Aug 2019 11:24:42 +0800 Subject: [PATCH] Modify api schema for remove pool group Since we added the pool_list instead of pool_group, but we didn't support pool_list in 1.1 api. So we need to change the API schema for compatibility. Change-Id: Ic05fc730ca2858fa6846a67af4c19f6b6130d575 --- zaqar/common/api/schemas/v1_1/__init__.py | 0 zaqar/common/api/schemas/v1_1/flavors.py | 51 +++++++++++++++++++++++ zaqar/transport/wsgi/v1_1/flavors.py | 2 +- 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 zaqar/common/api/schemas/v1_1/__init__.py create mode 100644 zaqar/common/api/schemas/v1_1/flavors.py diff --git a/zaqar/common/api/schemas/v1_1/__init__.py b/zaqar/common/api/schemas/v1_1/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/zaqar/common/api/schemas/v1_1/flavors.py b/zaqar/common/api/schemas/v1_1/flavors.py new file mode 100644 index 000000000..15748d284 --- /dev/null +++ b/zaqar/common/api/schemas/v1_1/flavors.py @@ -0,0 +1,51 @@ +# Copyright (c) 2013 Rackspace Hosting, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""flavors: JSON schema for zaqar-queues flavors resources.""" + +# NOTE(flaper87): capabilities can be anything. These will be unique to +# each storage driver, so we don't perform any further validation at +# the transport layer. +patch_capabilities = { + 'type': 'object', + 'properties': { + 'capabilities': { + 'type': 'object' + } + } +} + +# NOTE(gengchc): Add pool_list in flavor creation for removing pool_group +patch_pool_list = { + 'type': 'object', + 'properties': { + 'pool_list': { + 'type': 'array' + }, + 'additionalProperties': False + } +} + +create = { + 'type': 'object', + 'properties': { + 'capabilities': patch_capabilities['properties']['capabilities'] + }, + # NOTE(flaper87): capabilities need not be present. Storage drivers + # must provide reasonable defaults. + # NOTE(wanghao): remove the whole folder when we remove the 1.1 API + # totally. + 'additionalProperties': False +} diff --git a/zaqar/transport/wsgi/v1_1/flavors.py b/zaqar/transport/wsgi/v1_1/flavors.py index 7a90dd287..9a1aedc68 100644 --- a/zaqar/transport/wsgi/v1_1/flavors.py +++ b/zaqar/transport/wsgi/v1_1/flavors.py @@ -18,7 +18,7 @@ import jsonschema from oslo_log import log import six -from zaqar.common.api.schemas import flavors as schema +from zaqar.common.api.schemas.v1_1 import flavors as schema from zaqar.common import utils as common_utils from zaqar.i18n import _ from zaqar.storage import errors