OpenStack Orchestration (Heat)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
2.9 KiB

# 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
# 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.
from stevedore import extension
from heat.engine import clients
from heat.engine import environment
from heat.engine import plugin_manager
def _register_resources(env, type_pairs):
for res_name, res_class in type_pairs:
env.register_class(res_name, res_class)
def _register_constraints(env, type_pairs):
for constraint_name, constraint in type_pairs:
env.register_constraint(constraint_name, constraint)
def _register_stack_lifecycle_plugins(env, type_pairs):
for stack_lifecycle_name, stack_lifecycle_class in type_pairs:
def _get_mapping(namespace):
mgr = extension.ExtensionManager(
return [[name, mgr[name].plugin] for name in mgr.names()]
_environment = None
def global_env():
if _environment is None:
return _environment
def initialise():
global _environment
if _environment is not None:
global_env = environment.Environment({}, user_env=False)
_environment = global_env
def _load_global_environment(env):
def _load_global_resources(env):
_register_constraints(env, _get_mapping('heat.constraints'))
manager = plugin_manager.PluginManager(__name__)
# Sometimes resources should not be available for registration in Heat due
# to unsatisfied dependencies. We look first for the function
# 'available_resource_mapping', which should return the filtered resources.
# If it is not found, we look for the legacy 'resource_mapping'.
resource_mapping = plugin_manager.PluginMapping(['available_resource',
constraint_mapping = plugin_manager.PluginMapping('constraint')
_register_resources(env, resource_mapping.load_all(manager))
_register_constraints(env, constraint_mapping.load_all(manager))
def list_opts():
from import loadbalancer
yield None, loadbalancer.loadbalancer_opts