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

This commit is contained in:
Zuul 2017-12-15 18:41:20 +00:00 committed by Gerrit Code Review
commit b5b46d35a6
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
}