Merge "Allow access to attributes of resumed resources"

This commit is contained in:
Jenkins 2013-09-23 18:03:52 +00:00 committed by Gerrit Code Review
commit 9f6ca49d36
4 changed files with 21 additions and 5 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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']}},

View File

@ -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)