fb512cd3ab
Part of support for nested stacks and updates story To add nested stack support to Valet, make up for missing Heat resource Orchestration IDs in nested resources by generating a subset of Heat stack lifecycle scheduler hints for each resource in advance, store them as opaque metadata in Valet, then leverage the metadata at Nova scheduling time. Make additional accommodations in anticipation of complexities brought about by adding support for stack updates. To add a minimally viable amount of Heat `stack-update` support to Valet, significantly restrict the number of update use cases using a set of acceptance criteria. Skip holistic placement at `stack-update` time in favor of Valet's existing re-plan mechanism, placing or replacing resources one at a time, albeit still in consideration of other resources in the same stack hierarchy. Change-Id: I4654bcb4eacd5d64f76e262fe4c29553796e3f06 Story: #2001139 Task: #4858
96 lines
2.9 KiB
Python
96 lines
2.9 KiB
Python
#
|
|
# Copyright (c) 2014-2017 AT&T Intellectual Property
|
|
#
|
|
# 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.
|
|
|
|
"""GroupAssignment Heat Resource Plugin"""
|
|
|
|
import uuid
|
|
|
|
from heat.common.i18n import _
|
|
from heat.engine import properties
|
|
from heat.engine import resource
|
|
from heat.engine.resources import scheduler_hints as sh
|
|
from oslo_log import log as logging
|
|
|
|
LOG = logging.getLogger(__name__)
|
|
|
|
|
|
class GroupAssignment(resource.Resource, sh.SchedulerHintsMixin):
|
|
"""Valet Group Assignment Resource
|
|
|
|
A Group Assignment describes one or more resources (e.g., Server)
|
|
assigned to a particular group.
|
|
|
|
Caution: It is possible to declare multiple GroupAssignment resources
|
|
referring to the same servers, which can lead to problems when one
|
|
GroupAssignment is updated and a duplicate server reference is removed.
|
|
|
|
This resource is purely informational in nature and makes no changes
|
|
to heat, nova, or cinder. Instead, the Valet Heat stack lifecycle plugin
|
|
intercepts Heat's create/update/delete operations and invokes valet-api
|
|
as needed.
|
|
"""
|
|
|
|
PROPERTIES = (
|
|
GROUP, RESOURCES,
|
|
) = (
|
|
'group', 'resources',
|
|
)
|
|
|
|
properties_schema = {
|
|
GROUP: properties.Schema(
|
|
properties.Schema.STRING,
|
|
_('Group reference.'),
|
|
update_allowed=False
|
|
),
|
|
RESOURCES: properties.Schema(
|
|
properties.Schema.LIST,
|
|
_('List of one or more resource IDs.'),
|
|
required=True,
|
|
update_allowed=True
|
|
),
|
|
}
|
|
|
|
def handle_create(self):
|
|
"""Create resource"""
|
|
resource_id = str(uuid.uuid4())
|
|
self.resource_id_set(resource_id)
|
|
|
|
def handle_update(self, json_snippet, templ_diff, prop_diff):
|
|
"""Update resource"""
|
|
self.resource_id_set(self.resource_id)
|
|
|
|
def handle_delete(self):
|
|
"""Delete resource"""
|
|
self.resource_id_set(None)
|
|
|
|
|
|
# TODO(jdandrea): This resource is being pre-empted (not deprecated)
|
|
# and is unavailable in Valet 1.0.
|
|
#
|
|
# To assign a server to a Valet Group, specify metadata within that
|
|
# server's OS::Nova::Server resource properties like so. Declare
|
|
# groups in a separate template/stack using OS::Valet::Group.
|
|
#
|
|
# properties:
|
|
# metadata:
|
|
# valet:
|
|
# groups: [group1, group2, ..., groupN]
|
|
#
|
|
# def resource_mapping():
|
|
# """Map names to resources."""
|
|
# return {
|
|
# 'OS::Valet::GroupAssignment': GroupAssignment,
|
|
# }
|