summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Hardy <shardy@redhat.com>2014-12-02 12:04:59 +0000
committerSteven Hardy <shardy@redhat.com>2015-01-06 12:50:42 +0000
commitedf0198151214336ab0d04bfc0e48e30c12864dd (patch)
tree8b5115f20a1cb7c10a05688e02432601b4de7aad
parent4ee5264d54b7307d36e0fe169327cac488cc3986 (diff)
downloadheat-edf0198151214336ab0d04bfc0e48e30c12864dd.tar.gz
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 (cherry picked from commit d5c84e5defdaccf6292ad154641a1197f827a949)
-rw-r--r--heat/engine/resources/resource_group.py3
-rw-r--r--heat/tests/test_resource_group.py21
2 files changed, 23 insertions, 1 deletions
diff --git a/heat/engine/resources/resource_group.py b/heat/engine/resources/resource_group.py
index f4f0d8dfe..158f34091 100644
--- a/heat/engine/resources/resource_group.py
+++ b/heat/engine/resources/resource_group.py
@@ -121,7 +121,8 @@ class ResourceGroup(stack_resource.StackResource):
_('Property values for the resources in the group')
),
},
- required=True
+ required=True,
+ update_allowed=True
),
}
diff --git a/heat/tests/test_resource_group.py b/heat/tests/test_resource_group.py
index 2346747d9..ce22a4715 100644
--- a/heat/tests/test_resource_group.py
+++ b/heat/tests/test_resource_group.py
@@ -379,6 +379,27 @@ class ResourceGroupTest(common.HeatTestCase):
self.assertEqual((resg.UPDATE, resg.COMPLETE), resg.nested().state)
self.assertEqual(3, len(resg.nested()))
+ 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()