ResourceGroup allow update of resource_def

Currently the group is replaced if the resource_def is updated,
but instead we should allow updates and update the underlying
nested stack instead.  This allows properties to be changed
such that non-replacement updates can be performed on the
resource-group members.

Change-Id: I471b7ebe71ed262a8b0e2c971a32afc7062699cb
Closes-Bug: #1396533
Closes-Bug: #1380612
This commit is contained in:
Steven Hardy 2014-12-02 12:04:59 +00:00
parent dcd27c89d6
commit d5c84e5def
2 changed files with 23 additions and 1 deletions

View File

@ -132,7 +132,8 @@ class ResourceGroup(stack_resource.StackResource):
_('Property values for the resources in the group')
),
},
required=True
required=True,
update_allowed=True
),
REMOVAL_POLICIES: properties.Schema(
properties.Schema.LIST,

View File

@ -409,6 +409,27 @@ class ResourceGroupTest(common.HeatTestCase):
resource_names = [r.name for r in resg.nested().iter_resources()]
self.assertEqual(['0', '1'], sorted(resource_names))
def test_props_update(self):
"""Test update of resource_def properties."""
resg = self._create_dummy_stack()
self.assertEqual(2, len(resg.nested()))
resource_names = [r.name for r in resg.nested().iter_resources()]
self.assertEqual(['0', '1'], sorted(resource_names))
new_snip = copy.deepcopy(resg.t)
new_snip['Properties']['resource_def']['properties']['Foo'] = 'xyz'
preupdate_resgid = resg.id
preupdate_nestedid = resg.nested().id
scheduler.TaskRunner(resg.update, new_snip)()
self.stack = resg.nested()
self.assertEqual((resg.UPDATE, resg.COMPLETE), resg.state)
self.assertEqual((resg.UPDATE, resg.COMPLETE), resg.nested().state)
self.assertEqual(2, len(resg.nested()))
resource_names = [r.name for r in resg.nested().iter_resources()]
self.assertEqual(['0', '1'], sorted(resource_names))
# resource_def update should recurse and update (not replace) nested
self.assertEqual(preupdate_resgid, resg.id)
self.assertEqual(preupdate_nestedid, resg.nested().id)
def test_update_nochange(self):
"""Test update with no properties change."""
resg = self._create_dummy_stack()