From 85eff5fc3d03dce7d0d17d965f27246bd3306c53 Mon Sep 17 00:00:00 2001 From: Zane Bitter Date: Fri, 12 Oct 2018 12:24:16 -0400 Subject: [PATCH] Use OutputDefinition to generate attributes schema We have the OutputDefinition API now, and no longer need to treat templates like CFN JSON blobs to obtain information about outputs. Change-Id: I8dfea1e9855a56fb85d2e3af40996d5f337d7859 --- heat/engine/attributes.py | 8 +++----- heat/engine/resources/stack_resource.py | 4 ++-- heat/engine/resources/template_resource.py | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/heat/engine/attributes.py b/heat/engine/attributes.py index 47e50be56a..407547c1f3 100644 --- a/heat/engine/attributes.py +++ b/heat/engine/attributes.py @@ -200,11 +200,9 @@ class Attributes(collections.Mapping): return outp @staticmethod - def schema_from_outputs(json_snippet): - if json_snippet: - return dict((k, Schema(v.get("Description"))) - for k, v in json_snippet.items()) - return {} + def schema_from_outputs(outputs): + return dict((o.name, Schema(o.description())) + for o in outputs.values()) def _validate_type(self, attrib, value): if attrib.schema.type == attrib.schema.STRING: diff --git a/heat/engine/resources/stack_resource.py b/heat/engine/resources/stack_resource.py index 7def946c51..ec5bb7685a 100644 --- a/heat/engine/resources/stack_resource.py +++ b/heat/engine/resources/stack_resource.py @@ -92,8 +92,8 @@ class StackResource(resource.Resource): return "nested_stack" - def _outputs_to_attribs(self, json_snippet): - outputs = json_snippet.get('Outputs') + def _outputs_to_attribs(self, parsed_template): + outputs = parsed_template.outputs(None) if not self.attributes and outputs: self.attributes_schema = ( attributes.Attributes.schema_from_outputs(outputs)) diff --git a/heat/engine/resources/template_resource.py b/heat/engine/resources/template_resource.py index 44959e966b..43fb81ec7e 100644 --- a/heat/engine/resources/template_resource.py +++ b/heat/engine/resources/template_resource.py @@ -108,7 +108,7 @@ class TemplateResource(stack_resource.StackResource): return ((properties.Properties.schema_from_params( tmpl.param_schemata(param_defaults))), (attributes.Attributes.schema_from_outputs( - tmpl[tmpl.OUTPUTS]))) + tmpl.outputs(None)))) def _generate_schema(self): self._parsed_nested = None