diff --git a/heat/engine/hot.py b/heat/engine/hot.py index f3755d2eda..3599fa0e5e 100644 --- a/heat/engine/hot.py +++ b/heat/engine/hot.py @@ -248,7 +248,7 @@ class HOTemplate(template.Template): _('"params" parameter must be a dictionary')) for key in params.iterkeys(): value = params.get(key, '') or "" - text = text.replace(key, value) + text = text.replace(key, str(value)) return text match_str_replace = lambda k, v: k in ['str_replace', 'Fn::Replace'] diff --git a/heat/tests/test_hot.py b/heat/tests/test_hot.py index 401c0fa1f9..0919f320cf 100644 --- a/heat/tests/test_hot.py +++ b/heat/tests/test_hot.py @@ -177,6 +177,18 @@ class HOTemplateTest(HeatTestCase): self.assertEqual(snippet_resolved, tmpl.resolve_replace(snippet)) + def test_str_replace_number(self): + """Test str_replace function with numbers.""" + + snippet = {'str_replace': {'template': 'Template number string bar', + 'params': {'number': 1}}} + snippet_resolved = 'Template 1 string bar' + + tmpl = parser.Template(hot_tpl_empty) + + self.assertEqual(snippet_resolved, + tmpl.resolve_replace(snippet)) + def test_str_fn_replace(self): """Test Fn:Replace function."""