summaryrefslogtreecommitdiff
path: root/heat
diff options
context:
space:
mode:
authorZane Bitter <zbitter@redhat.com>2014-05-01 18:53:07 -0400
committerZane Bitter <zbitter@redhat.com>2014-06-05 13:45:14 -0400
commit599dd3869e1666f565de5ea69b6afc2237460336 (patch)
treec31726240ba84dd911632e5c4cc45f2a209318fb /heat
parent54f1bee042597c490776656b11dfe38777b0db5e (diff)
downloadheat-599dd3869e1666f565de5ea69b6afc2237460336.tar.gz
Support passing a Template object to StackResource
The create_with_template() and update_with_template() methods of the StackResource class previously took raw template data as an argument; this change allows them to accept Template objects also. Change-Id: I7af5d516d4d0c4085144ed53c962cfc6ca3c69bb
Diffstat (limited to 'heat')
-rw-r--r--heat/engine/stack_resource.py14
-rw-r--r--heat/tests/test_stack_resource.py3
2 files changed, 12 insertions, 5 deletions
diff --git a/heat/engine/stack_resource.py b/heat/engine/stack_resource.py
index 5563fe66d..760b6cb2e 100644
--- a/heat/engine/stack_resource.py
+++ b/heat/engine/stack_resource.py
@@ -151,7 +151,12 @@ class StackResource(resource.Resource):
msg = _("Recursion depth exceeds %d.") % \
cfg.CONF.max_nested_stack_depth
raise exception.RequestLimitExceeded(message=msg)
- template = parser.Template(child_template, files=self.stack.t.files)
+ if isinstance(child_template, parser.Template):
+ template = child_template
+ template.files = self.stack.t.files
+ else:
+ template = parser.Template(child_template,
+ files=self.stack.t.files)
self._validate_nested_resources(template)
self._outputs_to_attribs(template)
@@ -195,7 +200,12 @@ class StackResource(resource.Resource):
def update_with_template(self, child_template, user_params,
timeout_mins=None):
"""Update the nested stack with the new template."""
- template = parser.Template(child_template, files=self.stack.t.files)
+ if isinstance(child_template, parser.Template):
+ template = child_template
+ template.files = self.stack.t.files
+ else:
+ template = parser.Template(child_template,
+ files=self.stack.t.files)
nested_stack = self.nested()
if nested_stack is None:
raise exception.Error(_('Cannot update %s, stack not created')
diff --git a/heat/tests/test_stack_resource.py b/heat/tests/test_stack_resource.py
index cc6647127..e260c8672 100644
--- a/heat/tests/test_stack_resource.py
+++ b/heat/tests/test_stack_resource.py
@@ -492,9 +492,6 @@ class StackResourceTest(HeatTestCase):
disable_rollback=True,
parent_resource=self.parent_resource)
- self.m.StubOutWithMock(parser, 'Template')
- parser.Template(self.templ, files={}).AndReturn(templ)
-
self.m.StubOutWithMock(environment, 'Environment')
environment.Environment().AndReturn(env)