Merge "Change template loading to use stevedore extensions"

This commit is contained in:
Jenkins 2014-07-07 14:25:12 +00:00 committed by Gerrit Code Review
commit d6bdbcc71e
4 changed files with 13 additions and 15 deletions

View File

@ -147,10 +147,3 @@ class CfnTemplate(template.Template):
self.t.setdefault(self.RESOURCES, {}) self.t.setdefault(self.RESOURCES, {})
self.t[self.RESOURCES][name] = cfn_tmpl self.t[self.RESOURCES][name] = cfn_tmpl
def template_mapping():
return {
('HeatTemplateFormatVersion', '2012-12-12'): CfnTemplate,
('AWSTemplateFormatVersion', '2010-09-09'): CfnTemplate,
}

View File

@ -223,9 +223,3 @@ class HOTemplate(template.Template):
self.t.setdefault(self.RESOURCES, {}) self.t.setdefault(self.RESOURCES, {})
self.t[self.RESOURCES][name] = definition.render_hot() self.t[self.RESOURCES][name] = definition.render_hot()
def template_mapping():
return {
('heat_template_version', '2013-05-23'): HOTemplate,
}

View File

@ -15,6 +15,7 @@ import abc
import collections import collections
import copy import copy
import functools import functools
from stevedore import extension
from heat.common import exception from heat.common import exception
from heat.db import api as db_api from heat.db import api as db_api
@ -76,8 +77,12 @@ def get_template_class(plugin_mgr, template_data):
global _template_classes global _template_classes
if _template_classes is None: if _template_classes is None:
tmpl_mapping = plugin_manager.PluginMapping('template') mgr = extension.ExtensionManager(
_template_classes = dict(tmpl_mapping.load_all(plugin_mgr)) namespace='heat.templates',
invoke_on_load=False,
verify_requirements=True)
_template_classes = dict((tuple(name.split('.')), mgr[name].plugin)
for name in mgr.names())
available_versions = _template_classes.keys() available_versions = _template_classes.keys()
version = get_version(template_data, available_versions) version = get_version(template_data, available_versions)

View File

@ -45,6 +45,12 @@ heat.constraints =
nova.keypair = heat.engine.resources.nova_keypair:KeypairConstraint nova.keypair = heat.engine.resources.nova_keypair:KeypairConstraint
heat.templates =
heat_template_version.2013-05-23 = heat.engine.hot.template:HOTemplate
HeatTemplateFormatVersion.2012-12-12 = heat.engine.cfn.template:CfnTemplate
AWSTemplateFormatVersion.2010-09-09 = heat.engine.cfn.template:CfnTemplate
[global] [global]
setup-hooks = setup-hooks =
pbr.hooks.setup_hook pbr.hooks.setup_hook