Update template paths for environment-mapped TemplateResources
When updating a template resource, we weren't taking into account the possibility that the new environment could be mapping the resource to a different template path. This change ensures we recalculate the template name from the new environment before reloading the template during an update. Change-Id: I5f84f6fd60925d3dba0b8e8dec867657c8c5c9ef Closes-Bug: #1452534
This commit is contained in:
parent
b86f3d573a
commit
686f317cca
@ -50,9 +50,21 @@ class TemplateResource(stack_resource.StackResource):
|
||||
self.stack = stack
|
||||
self.validation_exception = None
|
||||
|
||||
tri = stack.env.get_resource_info(
|
||||
json_snippet['Type'],
|
||||
resource_name=name,
|
||||
tri = self._get_resource_info(json_snippet)
|
||||
|
||||
self.properties_schema = {}
|
||||
self.attributes_schema = {}
|
||||
|
||||
# run Resource.__init__() so we can call self.nested()
|
||||
super(TemplateResource, self).__init__(name, json_snippet, stack)
|
||||
self.resource_info = tri
|
||||
if self.validation_exception is None:
|
||||
self._generate_schema(self.t)
|
||||
|
||||
def _get_resource_info(self, rsrc_defn):
|
||||
tri = self.stack.env.get_resource_info(
|
||||
rsrc_defn.resource_type,
|
||||
resource_name=rsrc_defn.name,
|
||||
registry_type=environment.TemplateResourceInfo)
|
||||
if tri is None:
|
||||
self.validation_exception = ValueError(_(
|
||||
@ -66,13 +78,7 @@ class TemplateResource(stack_resource.StackResource):
|
||||
else:
|
||||
self.allowed_schemes = ('http', 'https', 'file')
|
||||
|
||||
# run Resource.__init__() so we can call self.nested()
|
||||
self.properties_schema = {}
|
||||
self.attributes_schema = {}
|
||||
super(TemplateResource, self).__init__(name, json_snippet, stack)
|
||||
self.resource_info = tri
|
||||
if self.validation_exception is None:
|
||||
self._generate_schema(self.t)
|
||||
return tri
|
||||
|
||||
@staticmethod
|
||||
def get_template_file(template_name, allowed_schemes):
|
||||
@ -261,6 +267,7 @@ class TemplateResource(stack_resource.StackResource):
|
||||
self.metadata_set(self.t.metadata())
|
||||
|
||||
def handle_update(self, json_snippet, tmpl_diff, prop_diff):
|
||||
self._get_resource_info(json_snippet)
|
||||
self._generate_schema(json_snippet)
|
||||
return self.update_with_template(self.child_template(),
|
||||
self.child_params())
|
||||
|
Loading…
Reference in New Issue
Block a user