[placement] Separate API schemas (aggregate)

In compute APIs, they have their schemas in the
independent directory (nova/api/openstack/compute/schemas).
Placement APIs should be like that as well.

This patch separates API schemas to an independent directory
(nova/api/openstack/placement/schemas)
from nova/api/openstack/placement/handlers/aggregate.py.

Subsequent patches will move schemas of other handlers.

Change-Id: I1b526b1df28c281bd456f35bc0f5c5d9c2464c7e
This commit is contained in:
Takashi NATSUME 2017-11-16 23:45:14 +09:00
parent 4253e676fa
commit 337d402df2
2 changed files with 24 additions and 11 deletions
nova/api/openstack/placement

@ -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)

@ -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
}