Fix updating from an empty stack
Change-Id: Ic63e1998316b27a431e856fe43b9ad8cc9dd887a Closes-bug: #1343171
This commit is contained in:
parent
36fca51163
commit
604a1ed70e
@ -148,5 +148,6 @@ class CfnTemplate(template.Template):
|
|||||||
if len(cfn_tmpl.get(RES_DEPENDS_ON, [])) == 1:
|
if len(cfn_tmpl.get(RES_DEPENDS_ON, [])) == 1:
|
||||||
cfn_tmpl[RES_DEPENDS_ON] = cfn_tmpl[RES_DEPENDS_ON][0]
|
cfn_tmpl[RES_DEPENDS_ON] = cfn_tmpl[RES_DEPENDS_ON][0]
|
||||||
|
|
||||||
self.t.setdefault(self.RESOURCES, {})
|
if self.t.get(self.RESOURCES) is None:
|
||||||
|
self.t[self.RESOURCES] = {}
|
||||||
self.t[self.RESOURCES][name] = cfn_tmpl
|
self.t[self.RESOURCES][name] = cfn_tmpl
|
||||||
|
@ -222,5 +222,6 @@ class HOTemplate(template.Template):
|
|||||||
if name is None:
|
if name is None:
|
||||||
name = definition.name
|
name = definition.name
|
||||||
|
|
||||||
self.t.setdefault(self.RESOURCES, {})
|
if self.t.get(self.RESOURCES) is None:
|
||||||
|
self.t[self.RESOURCES] = {}
|
||||||
self.t[self.RESOURCES][name] = definition.render_hot()
|
self.t[self.RESOURCES][name] = definition.render_hot()
|
||||||
|
@ -25,12 +25,13 @@ class StackTest(common.HeatTestCase):
|
|||||||
self.ctx = utils.dummy_context()
|
self.ctx = utils.dummy_context()
|
||||||
|
|
||||||
def _assert_can_create(self, templ):
|
def _assert_can_create(self, templ):
|
||||||
stack = parser.Stack(self.ctx, 'update_stack_arn_test',
|
stack = parser.Stack(self.ctx, utils.random_name(),
|
||||||
template.Template(templ))
|
template.Template(templ))
|
||||||
stack.store()
|
stack.store()
|
||||||
stack.create()
|
stack.create()
|
||||||
self.assertEqual((parser.Stack.CREATE, parser.Stack.COMPLETE),
|
self.assertEqual((parser.Stack.CREATE, parser.Stack.COMPLETE),
|
||||||
stack.state)
|
stack.state)
|
||||||
|
return stack
|
||||||
|
|
||||||
def test_heat_empty_json(self):
|
def test_heat_empty_json(self):
|
||||||
tmpl = {'HeatTemplateFormatVersion': '2012-12-12',
|
tmpl = {'HeatTemplateFormatVersion': '2012-12-12',
|
||||||
@ -73,3 +74,47 @@ resources:
|
|||||||
outputs:
|
outputs:
|
||||||
''')
|
''')
|
||||||
self._assert_can_create(t)
|
self._assert_can_create(t)
|
||||||
|
|
||||||
|
def test_update_hot_empty_yaml(self):
|
||||||
|
t = template_format.parse('''
|
||||||
|
heat_template_version: 2013-05-23
|
||||||
|
parameters:
|
||||||
|
resources:
|
||||||
|
outputs:
|
||||||
|
''')
|
||||||
|
ut = template_format.parse('''
|
||||||
|
heat_template_version: 2013-05-23
|
||||||
|
parameters:
|
||||||
|
resources:
|
||||||
|
rand:
|
||||||
|
type: OS::Heat::RandomString
|
||||||
|
outputs:
|
||||||
|
''')
|
||||||
|
stack = self._assert_can_create(t)
|
||||||
|
updated = parser.Stack(self.ctx, utils.random_name(),
|
||||||
|
template.Template(ut))
|
||||||
|
stack.update(updated)
|
||||||
|
self.assertEqual((parser.Stack.UPDATE, parser.Stack.COMPLETE),
|
||||||
|
stack.state)
|
||||||
|
|
||||||
|
def test_update_cfn_empty_yaml(self):
|
||||||
|
t = template_format.parse('''
|
||||||
|
AWSTemplateFormatVersion: 2010-09-09
|
||||||
|
Parameters:
|
||||||
|
Resources:
|
||||||
|
Outputs:
|
||||||
|
''')
|
||||||
|
ut = template_format.parse('''
|
||||||
|
AWSTemplateFormatVersion: 2010-09-09
|
||||||
|
Parameters:
|
||||||
|
Resources:
|
||||||
|
rand:
|
||||||
|
Type: OS::Heat::RandomString
|
||||||
|
Outputs:
|
||||||
|
''')
|
||||||
|
stack = self._assert_can_create(t)
|
||||||
|
updated = parser.Stack(self.ctx, utils.random_name(),
|
||||||
|
template.Template(ut))
|
||||||
|
stack.update(updated)
|
||||||
|
self.assertEqual((parser.Stack.UPDATE, parser.Stack.COMPLETE),
|
||||||
|
stack.state)
|
||||||
|
Loading…
Reference in New Issue
Block a user