Don't load nested stack to get TemplateResource template
In the worst-case scenario if we can't find the template for an existing TemplateResource, we fetch it from the extant nested stack. Rather than do this by loading the nested stack in-memory, fetch the template via RPC. Change-Id: Ide96ef861ef4cbb6afd9ab09e7b51b69e03e5520 Partial-Bug: #1731349
This commit is contained in:
parent
94b62e5910
commit
c6b0d58888
|
@ -205,8 +205,11 @@ class TemplateResource(stack_resource.StackResource):
|
|||
reported_excp = err
|
||||
|
||||
if t_data is None:
|
||||
if self.resource_id is not None:
|
||||
t_data = jsonutils.dumps(self.nested().t.t)
|
||||
nested_identifier = self.nested_identifier()
|
||||
if nested_identifier is not None:
|
||||
nested_t = self.rpc_client().get_template(self.context,
|
||||
nested_identifier)
|
||||
t_data = jsonutils.dumps(nested_t)
|
||||
|
||||
if t_data is not None:
|
||||
if t_data != stored_t_data:
|
||||
|
|
|
@ -952,13 +952,12 @@ class TemplateDataTest(common.HeatTestCase):
|
|||
|
||||
def test_template_data_in_create_without_template_file(self):
|
||||
self.res.action = self.res.CREATE
|
||||
self.res.nested = mock.MagicMock()
|
||||
self.res.resource_id = 'dummy_id'
|
||||
self.res.resource_id = None
|
||||
self.res.get_template_file = mock.Mock(
|
||||
side_effect=exception.NotFound(
|
||||
msg_fmt='Could not fetch remote template '
|
||||
'"test_resource.template": file not found'))
|
||||
self.assertEqual('{}', self.res.template_data())
|
||||
self.assertRaises(exception.NotFound, self.res.template_data)
|
||||
|
||||
|
||||
class TemplateResourceCrudTest(common.HeatTestCase):
|
||||
|
|
Loading…
Reference in New Issue