diff --git a/nova/api/openstack/placement/handlers/aggregate.py b/nova/api/openstack/placement/handlers/aggregate.py index 93897b720..07e445e42 100644 --- a/nova/api/openstack/placement/handlers/aggregate.py +++ b/nova/api/openstack/placement/handlers/aggregate.py @@ -16,21 +16,12 @@ from oslo_utils import encodeutils from oslo_utils import timeutils from nova.api.openstack.placement import microversion +from nova.api.openstack.placement.schemas import aggregate as schema from nova.api.openstack.placement import util from nova.api.openstack.placement import wsgi_wrapper from nova.objects import resource_provider as rp_obj -PUT_AGGREGATES_SCHEMA = { - "type": "array", - "items": { - "type": "string", - "format": "uuid" - }, - "uniqueItems": True -} - - def _send_aggregates(req, aggregate_uuids): want_version = req.environ[microversion.MICROVERSION_ENVIRON] response = req.response @@ -80,7 +71,7 @@ def set_aggregates(req): uuid = util.wsgi_path_item(req.environ, 'uuid') resource_provider = rp_obj.ResourceProvider.get_by_uuid( context, uuid) - aggregate_uuids = util.extract_json(req.body, PUT_AGGREGATES_SCHEMA) + aggregate_uuids = util.extract_json(req.body, schema.PUT_AGGREGATES_SCHEMA) resource_provider.set_aggregates(aggregate_uuids) return _send_aggregates(req, aggregate_uuids) diff --git a/nova/api/openstack/placement/schemas/aggregate.py b/nova/api/openstack/placement/schemas/aggregate.py new file mode 100644 index 000000000..3478d7249 --- /dev/null +++ b/nova/api/openstack/placement/schemas/aggregate.py @@ -0,0 +1,22 @@ +# 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. +"""Aggregate schemas for Placement API.""" + + +PUT_AGGREGATES_SCHEMA = { + "type": "array", + "items": { + "type": "string", + "format": "uuid" + }, + "uniqueItems": True +}