Merge "Do not show HIDDEN props in res type template"

This commit is contained in:
Jenkins 2016-07-18 19:09:13 +00:00 committed by Gerrit Code Review
commit ec36a7886d
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

@ -2052,9 +2052,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
@ -1331,6 +1332,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 = {
@ -1414,6 +1419,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 = {