Create a new revision of HOT for Juno

The next revision of HOT, dated 2014-10-16 to coincide with the Juno
release date, will support the list_join function and remove support for
the CFN-style functions. There may also be other changes throughout the
Juno development cycle.

Change-Id: I20d9586201806ac34e303689660ff565cb9f2b5c
This commit is contained in:
Zane Bitter 2014-07-15 10:21:56 -04:00
parent 3b52484fcf
commit c26cf90325
5 changed files with 57 additions and 4 deletions

View File

@ -728,7 +728,8 @@ given as single parameter to the get_resource function.
list_join
--------
The *list_join* function joins a list of strings with the given delimiter.
The *list_join* function joins a list of strings with the given delimiter. This
function is available beginning with the `2014-10-16` version of HOT.
The syntax of the list_join function is as follows:
::

View File

@ -236,6 +236,21 @@ class ResourceFacade(cfn_funcs.ResourceFacade):
)
class Removed(function.Function):
'''
This function existed in previous versions of HOT, but has been removed.
Check the HOT guide for an equivalent native function.
'''
def validate(self):
exp = (_("The function %s is not supported in this version of HOT.") %
self.fn_name)
raise exception.InvalidTemplateVersion(explanation=exp)
def result(self):
return super(Removed, self).result()
def function_mapping(version_key, version):
if version_key != 'heat_template_version':
return {}
@ -249,7 +264,6 @@ def function_mapping(version_key, version):
'get_attr': GetAtt,
'Fn::Select': cfn_funcs.Select,
'Fn::Join': cfn_funcs.Join,
'list_join': Join,
'Fn::Split': cfn_funcs.Split,
'str_replace': Replace,
'Fn::Replace': cfn_funcs.Replace,
@ -259,5 +273,26 @@ def function_mapping(version_key, version):
'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 {}

View File

@ -39,6 +39,10 @@ hot_tpl_empty = template_format.parse('''
heat_template_version: 2013-05-23
''')
hot_juno_tpl_empty = template_format.parse('''
heat_template_version: 2014-10-16
''')
hot_tpl_empty_sections = template_format.parse('''
heat_template_version: 2013-05-23
parameters:
@ -582,9 +586,10 @@ class HOTemplateTest(HeatTestCase):
parent_resource = DummyClass()
parent_resource.metadata_set({"foo": "bar"})
tmpl = parser.Template(hot_juno_tpl_empty)
parent_resource.stack = parser.Stack(utils.dummy_context(),
'toplevel_stack',
parser.Template(hot_tpl_empty))
tmpl)
del_policy = hot_functions.Join(parent_resource.stack,
'list_join', ['eta', ['R', 'in']])
parent_resource.t = rsrc_defn.ResourceDefinition(
@ -621,6 +626,15 @@ class HOTemplateTest(HeatTestCase):
parent_resource=parent_resource)
self.assertEqual('Delete', self.resolve(snippet, stack.t, stack))
def test_removed_function(self):
snippet = {'Fn::GetAZs': ''}
stack = parser.Stack(utils.dummy_context(), 'test_stack',
parser.Template(hot_juno_tpl_empty))
error = self.assertRaises(exception.InvalidTemplateVersion,
function.validate,
stack.t.parse(stack, snippet))
self.assertIn(snippet.keys()[0], str(error))
def test_add_resource(self):
hot_tpl = template_format.parse('''
heat_template_version: 2013-05-23

View File

@ -199,9 +199,11 @@ class TemplateTest(HeatTestCase):
}''')
init_ex = self.assertRaises(exception.InvalidTemplateVersion,
parser.Template, invalid_hot_version_tmp)
valid_versions = ['2014-10-16', '2013-05-23']
ex_error_msg = ('The template version is invalid: '
'"heat_template_version: 2012-12-12". '
'"heat_template_version" should be: 2013-05-23')
'"heat_template_version" should be one of: %s'
% ', '.join(valid_versions))
self.assertEqual(ex_error_msg, str(init_ex))
def test_invalid_version_not_in_hot_versions(self):

View File

@ -53,6 +53,7 @@ heat.constraints =
heat.templates =
heat_template_version.2013-05-23 = heat.engine.hot.template:HOTemplate
heat_template_version.2014-10-16 = heat.engine.hot.template:HOTemplate
HeatTemplateFormatVersion.2012-12-12 = heat.engine.cfn.template:CfnTemplate
AWSTemplateFormatVersion.2010-09-09 = heat.engine.cfn.template:CfnTemplate