From f629fb5ffa7ed2cb530c5f469e3e6c1348edfb46 Mon Sep 17 00:00:00 2001 From: Oleksii Chuprykov Date: Mon, 11 Jul 2016 21:04:05 +0300 Subject: [PATCH] Do not show HIDDEN props in res type template Hidden properties and attributes shouldn't be presented in output of "heat resource-type-template". Closes-Bug: #1601921 Change-Id: I7d20cd4119b9001094f7b503c7c0940f93287f6e --- heat/engine/attributes.py | 10 +++++++--- heat/engine/resource.py | 10 ++++++++-- heat/tests/test_attributes.py | 3 +++ heat/tests/test_resource.py | 9 +++++++++ 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/heat/engine/attributes.py b/heat/engine/attributes.py index e5cae33697..78ba4f787d 100644 --- a/heat/engine/attributes.py +++ b/heat/engine/attributes.py @@ -150,9 +150,13 @@ class Attributes(collections.Mapping): :returns: The attributes of the specified resource_class as a template Output map """ - schema = resource_class.attributes_schema.copy() - schema.update(resource_class.base_attributes_schema) - attribs = Attributes._make_attributes(schema).items() + attr_schema = {} + for name, schema_data in resource_class.attributes_schema.items(): + schema = Schema.from_attribute(schema_data) + if schema.support_status.status != support.HIDDEN: + attr_schema[name] = schema + attr_schema.update(resource_class.base_attributes_schema) + attribs = Attributes._make_attributes(attr_schema).items() return dict((n, att.as_output(resource_name, template_type)) for n, att in attribs) diff --git a/heat/engine/resource.py b/heat/engine/resource.py index 8aea30b4f9..f163c220ed 100644 --- a/heat/engine/resource.py +++ b/heat/engine/resource.py @@ -2034,9 +2034,15 @@ class Resource(object): as parameters, and the resource's attributes_schema is mapped as outputs """ - schema = cls.properties_schema + + props_schema = {} + for name, schema_dict in cls.properties_schema.items(): + schema = properties.Schema.from_legacy(schema_dict) + if schema.support_status.status != support.HIDDEN: + props_schema[name] = schema + params, props = (properties.Properties. - schema_to_parameters_and_properties(schema, + schema_to_parameters_and_properties(props_schema, template_type)) resource_name = cls.__name__ outputs = attributes.Attributes.as_outputs(resource_name, cls, diff --git a/heat/tests/test_attributes.py b/heat/tests/test_attributes.py index bf4d76a58a..6c7b63fa83 100644 --- a/heat/tests/test_attributes.py +++ b/heat/tests/test_attributes.py @@ -169,6 +169,9 @@ class AttributesTest(common.HeatTestCase): "test1": attributes.Schema("Test attrib 1"), "test2": attributes.Schema("Test attrib 2"), "test3": attributes.Schema("Test attrib 3"), + "test4": attributes.Schema( + "Test attrib 4", + support_status=support.SupportStatus(status=support.HIDDEN)) } self.assertEqual( expected, diff --git a/heat/tests/test_resource.py b/heat/tests/test_resource.py index 07d518b5c3..720cd7972c 100644 --- a/heat/tests/test_resource.py +++ b/heat/tests/test_resource.py @@ -42,6 +42,7 @@ from heat.engine.resources.openstack.heat import test_resource from heat.engine import rsrc_defn from heat.engine import scheduler from heat.engine import stack as parser +from heat.engine import support from heat.engine import template from heat.engine import translation from heat.objects import resource as resource_objects @@ -1256,6 +1257,10 @@ class ResourceTest(common.HeatTestCase): 'list': {'Type': 'List', 'Schema': {'Type': 'Map', 'Schema': list_schema}}, 'map': {'Type': 'Map', 'Schema': map_schema}, + 'hidden': properties.Schema( + properties.Schema.STRING, + support_status=support.SupportStatus( + status=support.HIDDEN)) } attributes_schema = { @@ -1339,6 +1344,10 @@ class ResourceTest(common.HeatTestCase): 'list': {'Type': 'List', 'Schema': {'Type': 'Map', 'Schema': list_schema}}, 'map': {'Type': 'Map', 'Schema': map_schema}, + 'hidden': properties.Schema( + properties.Schema.STRING, + support_status=support.SupportStatus( + status=support.HIDDEN)) } attributes_schema = {