diff --git a/nova/api/openstack/placement/handlers/usage.py b/nova/api/openstack/placement/handlers/usage.py index beec996ef..fe5e869ca 100644 --- a/nova/api/openstack/placement/handlers/usage.py +++ b/nova/api/openstack/placement/handlers/usage.py @@ -17,6 +17,7 @@ from oslo_utils import timeutils import webob from nova.api.openstack.placement import microversion +from nova.api.openstack.placement.schemas import usage as schema from nova.api.openstack.placement import util from nova.api.openstack.placement import wsgi_wrapper from nova import exception @@ -24,28 +25,6 @@ from nova.i18n import _ from nova.objects import resource_provider as rp_obj -# Represents the allowed query string parameters to GET /usages -GET_USAGES_SCHEMA_1_9 = { - "type": "object", - "properties": { - "project_id": { - "type": "string", - "minLength": 1, - "maxLength": 255, - }, - "user_id": { - "type": "string", - "minLength": 1, - "maxLength": 255, - }, - }, - "required": [ - "project_id" - ], - "additionalProperties": False, -} - - def _serialize_usages(resource_provider, usage): usage_dict = {resource.resource_class: resource.usage for resource in usage} @@ -111,9 +90,7 @@ def get_total_usages(req): context = req.environ['placement.context'] want_version = req.environ[microversion.MICROVERSION_ENVIRON] - schema = GET_USAGES_SCHEMA_1_9 - - util.validate_query_params(req, schema) + util.validate_query_params(req, schema.GET_USAGES_SCHEMA_1_9) project_id = req.GET.get('project_id') user_id = req.GET.get('user_id') diff --git a/nova/api/openstack/placement/schemas/__init__.py b/nova/api/openstack/placement/schemas/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/nova/api/openstack/placement/schemas/usage.py b/nova/api/openstack/placement/schemas/usage.py new file mode 100644 index 000000000..3b1a18450 --- /dev/null +++ b/nova/api/openstack/placement/schemas/usage.py @@ -0,0 +1,33 @@ +# 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 usage information.""" + +# Represents the allowed query string parameters to GET /usages +GET_USAGES_SCHEMA_1_9 = { + "type": "object", + "properties": { + "project_id": { + "type": "string", + "minLength": 1, + "maxLength": 255, + }, + "user_id": { + "type": "string", + "minLength": 1, + "maxLength": 255, + }, + }, + "required": [ + "project_id" + ], + "additionalProperties": False, +}