diff --git a/heat/engine/update.py b/heat/engine/update.py index 335b66870..08afe83e4 100644 --- a/heat/engine/update.py +++ b/heat/engine/update.py @@ -144,8 +144,10 @@ class StackUpdate(object): # Note the new resource snippet is resolved in the context # of the existing stack (which is the stack being updated) + # but with the template of the new stack (in case the update + # is switching template implementations) new_snippet = new_res.t.reparse(self.existing_stack, - self.existing_stack.t) + self.new_stack.t) return existing_res.update(new_snippet, existing_snippet, prev_resource=prev_res) diff --git a/heat/tests/test_parser.py b/heat/tests/test_parser.py index 36f6488ac..d841bd6bf 100644 --- a/heat/tests/test_parser.py +++ b/heat/tests/test_parser.py @@ -3005,6 +3005,50 @@ class StackTest(HeatTestCase): self.assertEqual(resource_id, self.stack['AResource'].id) + def test_update_template_format_version(self): + tmpl = { + 'HeatTemplateFormatVersion': '2012-12-12', + 'Parameters': { + 'AParam': {'Type': 'String', 'Default': 'abc'}}, + 'Resources': { + 'AResource': { + 'Type': 'ResourceWithPropsType', + 'Properties': {'Foo': {'Ref': 'AParam'}} + }, + } + } + + self.stack = parser.Stack(self.ctx, 'update_test_stack', + template.Template(tmpl)) + self.stack.store() + self.stack.create() + self.assertEqual((parser.Stack.CREATE, parser.Stack.COMPLETE), + self.stack.state) + self.assertEqual('abc', self.stack['AResource'].properties['Foo']) + + tmpl2 = { + 'heat_template_version': '2013-05-23', + 'parameters': { + 'AParam': {'type': 'string', 'default': 'foo'}}, + 'resources': { + 'AResource': { + 'type': 'ResourceWithPropsType', + 'properties': {'Foo': {'get_param': 'AParam'}} + } + } + } + + updated_stack = parser.Stack(self.ctx, 'updated_stack', + template.Template(tmpl2)) + + self.m.ReplayAll() + + self.stack.update(updated_stack) + self.assertEqual((parser.Stack.UPDATE, parser.Stack.COMPLETE), + self.stack.state) + self.assertEqual('foo', self.stack['AResource'].properties['Foo']) + self.m.VerifyAll() + def test_stack_create_timeout(self): self.m.StubOutWithMock(scheduler.DependencyTaskGroup, '__call__') self.m.StubOutWithMock(scheduler, 'wallclock')