4d525b4ec1
/reshaper provides a way to atomically modify some allocations and inventory in a single transaction, allowing operations like migrating some inventory from a parent provider to a new child. A fair amount of code is reused from handler/inventory.py, some refactoring is in order before things get too far with that. In handler/allocation.py some code is extracted to its own methods so it can be reused from reshaper.py. This is done as microversion 1.30. A suite of gabbi tests is provided which attempt to cover various failures including schema violations, generation conflicts, and data conflicts. api-ref, release notes and rest history are updated Change-Id: I5b33ac3572bc3789878174ffc86ca42ae8035cfa Partially-Implements: blueprint reshape-provider-tree
48 lines
1.7 KiB
Python
48 lines
1.7 KiB
Python
# 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.
|
|
"""Reshaper schema for Placement API."""
|
|
|
|
import copy
|
|
|
|
from nova.api.openstack.placement.schemas import allocation
|
|
from nova.api.openstack.placement.schemas import common
|
|
from nova.api.openstack.placement.schemas import inventory
|
|
|
|
|
|
ALLOCATIONS = copy.deepcopy(allocation.POST_ALLOCATIONS_V1_28)
|
|
# In the reshaper we need to allow allocations to be an empty dict
|
|
# because it may be the case that there simply are no allocations
|
|
# (now) for any of the inventory being moved.
|
|
ALLOCATIONS['minProperties'] = 0
|
|
POST_RESHAPER_SCHEMA = {
|
|
"type": "object",
|
|
"properties": {
|
|
"inventories": {
|
|
"type": "object",
|
|
"patternProperties": {
|
|
# resource provider uuid
|
|
common.UUID_PATTERN: inventory.PUT_INVENTORY_SCHEMA,
|
|
},
|
|
# We expect at least one inventories, otherwise there is no reason
|
|
# to call the reshaper.
|
|
"minProperties": 1,
|
|
"additionalProperties": False,
|
|
},
|
|
"allocations": ALLOCATIONS,
|
|
},
|
|
"required": [
|
|
"inventories",
|
|
"allocations",
|
|
],
|
|
"additionalProperties": False,
|
|
}
|