Merge "Use new template for resource update reparse"

This commit is contained in:
Jenkins 2014-08-14 00:47:59 +00:00 committed by Gerrit Code Review
commit cbcfe1cedf
2 changed files with 47 additions and 1 deletions

View File

@ -144,8 +144,10 @@ class StackUpdate(object):
# Note the new resource snippet is resolved in the context # Note the new resource snippet is resolved in the context
# of the existing stack (which is the stack being updated) # 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, 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, return existing_res.update(new_snippet, existing_snippet,
prev_resource=prev_res) prev_resource=prev_res)

View File

@ -3005,6 +3005,50 @@ class StackTest(HeatTestCase):
self.assertEqual(resource_id, self.stack['AResource'].id) 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): def test_stack_create_timeout(self):
self.m.StubOutWithMock(scheduler.DependencyTaskGroup, '__call__') self.m.StubOutWithMock(scheduler.DependencyTaskGroup, '__call__')
self.m.StubOutWithMock(scheduler, 'wallclock') self.m.StubOutWithMock(scheduler, 'wallclock')