Merge "[placement] Separate API schemas (allocation_candidate)"

This commit is contained in:
Zuul 2017-12-20 17:07:33 +00:00 committed by Gerrit Code Review
commit cd2010e027
2 changed files with 29 additions and 17 deletions

View File

@ -21,6 +21,7 @@ from oslo_utils import timeutils
import webob import webob
from nova.api.openstack.placement import microversion from nova.api.openstack.placement import microversion
from nova.api.openstack.placement.schemas import allocation_candidate as schema
from nova.api.openstack.placement import util from nova.api.openstack.placement import util
from nova.api.openstack.placement import wsgi_wrapper from nova.api.openstack.placement import wsgi_wrapper
from nova import exception from nova import exception
@ -30,21 +31,6 @@ from nova.objects import resource_provider as rp_obj
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
# Represents the allowed query string parameters to the GET
# /allocation_candidates API call
_GET_SCHEMA_1_10 = {
"type": "object",
"properties": {
"resources": {
"type": "string"
},
},
"required": [
"resources",
],
"additionalProperties": False,
}
def _transform_allocation_requests_dict(alloc_reqs): def _transform_allocation_requests_dict(alloc_reqs):
"""Turn supplied list of AllocationRequest objects into a list of """Turn supplied list of AllocationRequest objects into a list of
@ -208,8 +194,7 @@ def list_allocation_candidates(req):
""" """
context = req.environ['placement.context'] context = req.environ['placement.context']
want_version = req.environ[microversion.MICROVERSION_ENVIRON] want_version = req.environ[microversion.MICROVERSION_ENVIRON]
schema = _GET_SCHEMA_1_10 util.validate_query_params(req, schema.GET_SCHEMA_1_10)
util.validate_query_params(req, schema)
requests = util.parse_qs_request_groups(req.GET) requests = util.parse_qs_request_groups(req.GET)

View File

@ -0,0 +1,27 @@
# 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.
"""Placement API schemas for getting allocation candidates."""
# Represents the allowed query string parameters to the GET
# /allocation_candidates API call
GET_SCHEMA_1_10 = {
"type": "object",
"properties": {
"resources": {
"type": "string"
},
},
"required": [
"resources",
],
"additionalProperties": False,
}