diff --git a/nova/api/openstack/placement/handlers/allocation_candidate.py b/nova/api/openstack/placement/handlers/allocation_candidate.py index 56635f54c..4ed1fec58 100644 --- a/nova/api/openstack/placement/handlers/allocation_candidate.py +++ b/nova/api/openstack/placement/handlers/allocation_candidate.py @@ -21,6 +21,7 @@ from oslo_utils import timeutils import webob 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 wsgi_wrapper from nova import exception @@ -30,21 +31,6 @@ from nova.objects import resource_provider as rp_obj 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): """Turn supplied list of AllocationRequest objects into a list of @@ -208,8 +194,7 @@ def list_allocation_candidates(req): """ context = req.environ['placement.context'] want_version = req.environ[microversion.MICROVERSION_ENVIRON] - schema = _GET_SCHEMA_1_10 - util.validate_query_params(req, schema) + util.validate_query_params(req, schema.GET_SCHEMA_1_10) requests = util.parse_qs_request_groups(req.GET) diff --git a/nova/api/openstack/placement/schemas/allocation_candidate.py b/nova/api/openstack/placement/schemas/allocation_candidate.py new file mode 100644 index 000000000..0d7766cc7 --- /dev/null +++ b/nova/api/openstack/placement/schemas/allocation_candidate.py @@ -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, +}