From 62b4d555073221407a34b91159e13009d34abd5e Mon Sep 17 00:00:00 2001 From: Liang Chen Date: Sat, 21 Sep 2013 21:42:13 +0800 Subject: [PATCH] Allow access to attributes of resumed resources RESUME COMPLETE|IN_PROGRESS were not treated as valid states while resolving attribute, thus causing Fn::GetAtt to fail after a stack is resumed. Fixes bug #1227025 Change-Id: I37b900c61b7d3017afe75fa726597f458be95d93 --- heat/engine/hot.py | 2 ++ heat/engine/template.py | 2 ++ heat/tests/test_hot.py | 20 +++++++++++++++----- heat/tests/test_parser.py | 2 ++ 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/heat/engine/hot.py b/heat/engine/hot.py index d48ef22ab..d4c8bf38b 100644 --- a/heat/engine/hot.py +++ b/heat/engine/hot.py @@ -224,6 +224,8 @@ class HOTemplate(template.Template): if r.state in ( (r.CREATE, r.IN_PROGRESS), (r.CREATE, r.COMPLETE), + (r.RESUME, r.IN_PROGRESS), + (r.RESUME, r.COMPLETE), (r.UPDATE, r.IN_PROGRESS), (r.UPDATE, r.COMPLETE)): return r.FnGetAtt(att) diff --git a/heat/engine/template.py b/heat/engine/template.py index 968e087ba..d4da014de 100644 --- a/heat/engine/template.py +++ b/heat/engine/template.py @@ -164,6 +164,8 @@ class Template(collections.Mapping): if r.state in ( (r.CREATE, r.IN_PROGRESS), (r.CREATE, r.COMPLETE), + (r.RESUME, r.IN_PROGRESS), + (r.RESUME, r.COMPLETE), (r.UPDATE, r.IN_PROGRESS), (r.UPDATE, r.COMPLETE)): return r.FnGetAtt(att) diff --git a/heat/tests/test_hot.py b/heat/tests/test_hot.py index 7111226ee..cb5f225c6 100644 --- a/heat/tests/test_hot.py +++ b/heat/tests/test_hot.py @@ -367,11 +367,21 @@ class StackTest(test_parser.StackTest): (parser.Stack.CREATE, parser.Stack.COMPLETE)) snippet = {'Value': {'get_attr': ['resource1', 'foo']}} - resolved = hot.HOTemplate.resolve_attributes(snippet, self.stack) - # GenericResourceType has an attribute 'foo' which yields the resource - # name. - self.assertEqual(resolved, {'Value': 'resource1'}) - # test invalid reference + rsrc = self.stack['resource1'] + for action, status in ( + (rsrc.CREATE, rsrc.IN_PROGRESS), + (rsrc.CREATE, rsrc.COMPLETE), + (rsrc.RESUME, rsrc.IN_PROGRESS), + (rsrc.RESUME, rsrc.COMPLETE), + (rsrc.UPDATE, rsrc.IN_PROGRESS), + (rsrc.UPDATE, rsrc.COMPLETE)): + rsrc.state_set(action, status) + + resolved = hot.HOTemplate.resolve_attributes(snippet, self.stack) + # GenericResourceType has an attribute 'foo' which yields the + # resource name. + self.assertEqual(resolved, {'Value': 'resource1'}) + # test invalid reference self.assertRaises(exception.InvalidTemplateAttribute, hot.HOTemplate.resolve_attributes, {'Value': {'get_attr': ['resource1', 'NotThere']}}, diff --git a/heat/tests/test_parser.py b/heat/tests/test_parser.py index 552143ead..e65543644 100644 --- a/heat/tests/test_parser.py +++ b/heat/tests/test_parser.py @@ -1684,6 +1684,8 @@ class StackTest(HeatTestCase): for action, status in ( (rsrc.CREATE, rsrc.IN_PROGRESS), (rsrc.CREATE, rsrc.COMPLETE), + (rsrc.RESUME, rsrc.IN_PROGRESS), + (rsrc.RESUME, rsrc.COMPLETE), (rsrc.UPDATE, rsrc.IN_PROGRESS), (rsrc.UPDATE, rsrc.COMPLETE)): rsrc.state_set(action, status)