summaryrefslogtreecommitdiff
path: root/heat/engine/hot
diff options
context:
space:
mode:
authorAngus Salkeld <asalkeld@mirantis.com>2014-09-09 11:13:43 +1000
committerAngus Salkeld <asalkeld@mirantis.com>2014-09-11 12:52:06 +1000
commitb49f283a4dd2009f4a5baeb16bc6eb5a8ff69594 (patch)
treebd41bb5592596abff9b2bc6a4998930a6493cc81 /heat/engine/hot
parentb3cb23e5b33c99db5e80d639a56e7dec4ea27e65 (diff)
downloadheat-b49f283a4dd2009f4a5baeb16bc6eb5a8ff69594.tar.gz
Convert functions into a fixed part of the template
http://www.mail-archive.com/openstack-dev@lists.openstack.org/msg28987.html part of blueprint stevedore-plugins Change-Id: Iabfa077077fa2170f5da8e7752e05e00db91a692
Diffstat (limited to 'heat/engine/hot')
-rw-r--r--heat/engine/hot/functions.py47
-rw-r--r--heat/engine/hot/template.py53
2 files changed, 49 insertions, 51 deletions
diff --git a/heat/engine/hot/functions.py b/heat/engine/hot/functions.py
index 23c333bb7..599f7b3d2 100644
--- a/heat/engine/hot/functions.py
+++ b/heat/engine/hot/functions.py
@@ -261,50 +261,3 @@ class Removed(function.Function):
def result(self):
return super(Removed, self).result()
-
-
-def function_mapping(version_key, version):
- if version_key != 'heat_template_version':
- return {}
-
- if version == '2013-05-23':
- return {
- 'Fn::GetAZs': cfn_funcs.GetAZs,
- 'get_param': GetParam,
- 'get_resource': cfn_funcs.ResourceRef,
- 'Ref': cfn_funcs.Ref,
- 'get_attr': GetAttThenSelect,
- 'Fn::Select': cfn_funcs.Select,
- 'Fn::Join': cfn_funcs.Join,
- 'Fn::Split': cfn_funcs.Split,
- 'str_replace': Replace,
- 'Fn::Replace': cfn_funcs.Replace,
- 'Fn::Base64': cfn_funcs.Base64,
- 'Fn::MemberListToMap': cfn_funcs.MemberListToMap,
- 'resource_facade': ResourceFacade,
- 'Fn::ResourceFacade': cfn_funcs.ResourceFacade,
- 'get_file': GetFile,
- }
- if version == '2014-10-16':
- return {
- 'get_param': GetParam,
- 'get_resource': cfn_funcs.ResourceRef,
- 'get_attr': GetAtt,
- 'list_join': Join,
- 'str_replace': Replace,
- 'resource_facade': ResourceFacade,
- 'get_file': GetFile,
-
- 'Fn::Select': cfn_funcs.Select,
-
- 'Fn::GetAZs': Removed,
- 'Ref': Removed,
- 'Fn::Join': Removed,
- 'Fn::Split': Removed,
- 'Fn::Replace': Removed,
- 'Fn::Base64': Removed,
- 'Fn::MemberListToMap': Removed,
- 'Fn::ResourceFacade': Removed,
- }
-
- return {}
diff --git a/heat/engine/hot/template.py b/heat/engine/hot/template.py
index 7a313d493..eacdf2a38 100644
--- a/heat/engine/hot/template.py
+++ b/heat/engine/hot/template.py
@@ -13,8 +13,10 @@
import collections
import six
+from heat.engine.cfn import functions as cfn_funcs
from heat.engine.cfn import template as cfn_template
from heat.engine import function
+from heat.engine.hot import functions as hot_funcs
from heat.engine.hot import parameters
from heat.engine import rsrc_defn
from heat.engine import template
@@ -30,7 +32,7 @@ _RESOURCE_KEYS = (
)
-class HOTemplate(template.Template):
+class HOTemplate20130523(template.Template):
"""
A Heat Orchestration Template format stack template.
"""
@@ -49,13 +51,32 @@ class HOTemplate(template.Template):
cfn_template.CfnTemplate.RESOURCES: RESOURCES,
cfn_template.CfnTemplate.OUTPUTS: OUTPUTS}
+ functions = {
+ 'Fn::GetAZs': cfn_funcs.GetAZs,
+ 'get_param': hot_funcs.GetParam,
+ 'get_resource': cfn_funcs.ResourceRef,
+ 'Ref': cfn_funcs.Ref,
+ 'get_attr': hot_funcs.GetAttThenSelect,
+ 'Fn::Select': cfn_funcs.Select,
+ 'Fn::Join': cfn_funcs.Join,
+ 'list_join': hot_funcs.Join,
+ 'Fn::Split': cfn_funcs.Split,
+ 'str_replace': hot_funcs.Replace,
+ 'Fn::Replace': cfn_funcs.Replace,
+ 'Fn::Base64': cfn_funcs.Base64,
+ 'Fn::MemberListToMap': cfn_funcs.MemberListToMap,
+ 'resource_facade': hot_funcs.ResourceFacade,
+ 'Fn::ResourceFacade': cfn_funcs.ResourceFacade,
+ 'get_file': hot_funcs.GetFile,
+ }
+
def __getitem__(self, section):
""""Get the relevant section in the template."""
#first translate from CFN into HOT terminology if necessary
if section not in self.SECTIONS:
- section = HOTemplate._translate(section, self._CFN_TO_HOT_SECTIONS,
- _('"%s" is not a valid template '
- 'section'))
+ section = HOTemplate20130523._translate(
+ section, self._CFN_TO_HOT_SECTIONS,
+ _('"%s" is not a valid template section'))
if section not in self.SECTIONS:
raise KeyError(_('"%s" is not a valid template section') % section)
@@ -226,3 +247,27 @@ class HOTemplate(template.Template):
if self.t.get(self.RESOURCES) is None:
self.t[self.RESOURCES] = {}
self.t[self.RESOURCES][name] = definition.render_hot()
+
+
+class HOTemplate20141016(HOTemplate20130523):
+ functions = {
+ 'get_attr': hot_funcs.GetAtt,
+ 'get_file': hot_funcs.GetFile,
+ 'get_param': hot_funcs.GetParam,
+ 'get_resource': cfn_funcs.ResourceRef,
+ 'list_join': hot_funcs.Join,
+ 'resource_facade': hot_funcs.ResourceFacade,
+ 'str_replace': hot_funcs.Replace,
+
+ 'Fn::Select': cfn_funcs.Select,
+
+ # functions removed from 20130523
+ 'Fn::GetAZs': hot_funcs.Removed,
+ 'Fn::Join': hot_funcs.Removed,
+ 'Fn::Split': hot_funcs.Removed,
+ 'Fn::Replace': hot_funcs.Removed,
+ 'Fn::Base64': hot_funcs.Removed,
+ 'Fn::MemberListToMap': hot_funcs.Removed,
+ 'Fn::ResourceFacade': hot_funcs.Removed,
+ 'Ref': hot_funcs.Removed,
+ }