Merge "ResourceGroup don't special-case zero count"

This commit is contained in:
Jenkins 2014-11-18 12:07:36 +00:00 committed by Gerrit Code Review
commit 4f095c5688
2 changed files with 15 additions and 9 deletions

View File

@ -237,11 +237,8 @@ class ResourceGroup(stack_resource.StackResource):
def handle_create(self): def handle_create(self):
names = self._resource_names() names = self._resource_names()
if names: return self.create_with_template(self._assemble_nested(names),
return self.create_with_template( {}, self.stack.timeout_mins)
self._assemble_nested(names),
{},
self.stack.timeout_mins)
def handle_update(self, json_snippet, tmpl_diff, prop_diff): def handle_update(self, json_snippet, tmpl_diff, prop_diff):
if prop_diff: if prop_diff:

View File

@ -252,6 +252,18 @@ class ResourceGroupTest(common.HeatTestCase):
self.assertEqual( self.assertEqual(
expect, resg._assemble_nested(['0'], include_all=True)) expect, resg._assemble_nested(['0'], include_all=True))
def test_assemble_nested_zero(self):
templ = copy.deepcopy(template)
templ['resources']['group1']['properties']['count'] = 0
stack = utils.parse_stack(templ)
snip = stack.t.resource_definitions(stack)['group1']
resg = resource_group.ResourceGroup('test', snip, stack)
expect = {
"heat_template_version": "2013-05-23",
"resources": {}
}
self.assertEqual(expect, resg._assemble_nested([]))
def test_index_var(self): def test_index_var(self):
stack = utils.parse_stack(template_repl) stack = utils.parse_stack(template_repl)
snip = stack.t.resource_definitions(stack)['group1'] snip = stack.t.resource_definitions(stack)['group1']
@ -662,10 +674,7 @@ class ResourceGroupTest(common.HeatTestCase):
resg = stack['group1'] resg = stack['group1']
scheduler.TaskRunner(resg.create)() scheduler.TaskRunner(resg.create)()
self.stack = resg.nested() self.stack = resg.nested()
if expect_count > 0: self.assertEqual(expect_count, len(resg.nested()))
self.assertEqual(expect_count, len(resg.nested()))
else:
self.assertIsNone(resg.nested())
self.assertEqual((resg.CREATE, resg.COMPLETE), resg.state) self.assertEqual((resg.CREATE, resg.COMPLETE), resg.state)
return resg return resg