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
This commit is contained in:
Oleksii Chuprykov 2016-07-11 21:04:05 +03:00
parent da7823208f
commit f629fb5ffa
4 changed files with 27 additions and 5 deletions

View File

@ -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)

View File

@ -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,

View File

@ -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,

View File

@ -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 = {