-
-
Save therve/5975e01a4238d45032b8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/heat/engine/cfn/template.py b/heat/engine/cfn/template.py | |
index cbde6d7..84e2318 100644 | |
--- a/heat/engine/cfn/template.py | |
+++ b/heat/engine/cfn/template.py | |
@@ -83,6 +83,9 @@ class CfnTemplate(template.Template): | |
return dict((name, parameters.Schema.from_dict(name, schema)) | |
for name, schema in six.iteritems(params)) | |
+ def get_section_name(self, section): | |
+ return section | |
+ | |
def parameters(self, stack_identifier, user_params, param_defaults=None): | |
return parameters.Parameters(stack_identifier, self, | |
user_params=user_params, | |
diff --git a/heat/engine/hot/template.py b/heat/engine/hot/template.py | |
index fdb5580..0189829 100644 | |
--- a/heat/engine/hot/template.py | |
+++ b/heat/engine/hot/template.py | |
@@ -74,6 +74,13 @@ class HOTemplate20130523(template.Template): | |
'Fn::ResourceFacade': cfn_funcs.ResourceFacade, | |
'get_file': hot_funcs.GetFile, | |
} | |
+ HOT_TO_CFN_ATTRS = {'type': 'Type', | |
+ 'properties': 'Properties', | |
+ 'metadata': 'Metadata', | |
+ 'depends_on': 'DependsOn', | |
+ 'deletion_policy': 'DeletionPolicy', | |
+ 'update_policy': 'UpdatePolicy'} | |
+ | |
def __getitem__(self, section): | |
""""Get the relevant section in the template.""" | |
@@ -157,15 +164,12 @@ class HOTemplate20130523(template.Template): | |
def _translate_resources(self, resources): | |
"""Get the resources of the template translated into CFN format.""" | |
- HOT_TO_CFN_ATTRS = {'type': 'Type', | |
- 'properties': 'Properties', | |
- 'metadata': 'Metadata', | |
- 'depends_on': 'DependsOn', | |
- 'deletion_policy': 'DeletionPolicy', | |
- 'update_policy': 'UpdatePolicy'} | |
- | |
return self._translate_section('resources', 'type', resources, | |
- HOT_TO_CFN_ATTRS) | |
+ self.HOT_TO_CFN_ATTRS) | |
+ | |
+ def get_section_name(self, section): | |
+ attrs = dict(zip(self.HOT_TO_CFN_ATTRS.values(), self.HOT_TO_CFN_ATTRS.keys())) | |
+ return attrs.get(section, section) | |
def _translate_outputs(self, outputs): | |
"""Get the outputs of the template translated into CFN format.""" | |
diff --git a/heat/engine/resource.py b/heat/engine/resource.py | |
index 5d7e6e5..f235b41 100644 | |
--- a/heat/engine/resource.py | |
+++ b/heat/engine/resource.py | |
@@ -879,15 +879,7 @@ class Resource(object): | |
with_value=self.stack.strict_validate) | |
except exception.StackValidationFailed as ex: | |
path = [self.stack.t.RESOURCES, ex.path[0]] | |
- if self.stack.t.VERSION == 'heat_template_version': | |
- if ex.path[1] == 'Properties': | |
- path.append('properties') | |
- elif ex.path[1] == 'UpdatePolicy': | |
- path.append('update_policy') | |
- else: | |
- path.append(ex.path[1]) | |
- else: | |
- path.append(ex.path[1]) | |
+ path.append(self.stack.t.get_section_name(ex.path[1])) | |
path += ex.path[2:] | |
raise exception.StackValidationFailed( | |
error=ex.error, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment