diff options
author | Oleksii Chuprykov <ochuprykov@mirantis.com> | 2016-07-06 17:20:47 +0300 |
---|---|---|
committer | Anant Patil <anant.patil@hpe.com> | 2016-07-12 08:06:54 +0000 |
commit | 81ba9a6e6850ba7273e8f652a65affd38632b5c7 (patch) | |
tree | adc272fe73052df46db30051bb553a5f771043af | |
parent | 1dbce6c12d4027509a877a08c6c0594f89f86770 (diff) | |
download | heat-81ba9a6e6850ba7273e8f652a65affd38632b5c7.tar.gz |
Do not show HIDDEN props in res type show
Also do not display hidden attributes.
Closes-Bug: #1599093
Change-Id: I5fae1708c8140cd61436f80cdf595f05f4a2b2a4
(cherry picked from commit fa33a1d4e3fbb77c7891324f29584f69e047849a)
-rw-r--r-- | heat/engine/service.py | 6 | ||||
-rw-r--r-- | heat/tests/common.py | 3 | ||||
-rw-r--r-- | heat/tests/engine/test_resource_type.py | 31 | ||||
-rw-r--r-- | heat/tests/generic_resource.py | 19 |
4 files changed, 57 insertions, 2 deletions
diff --git a/heat/engine/service.py b/heat/engine/service.py index fac7b6849..27c8c4bf1 100644 --- a/heat/engine/service.py +++ b/heat/engine/service.py @@ -1480,7 +1480,8 @@ class EngineService(service.Service): def properties_schema(): for name, schema_dict in resource_class.properties_schema.items(): schema = properties.Schema.from_legacy(schema_dict) - if schema.implemented: + if (schema.implemented + and schema.support_status.status != support.HIDDEN): yield name, dict(schema) def attributes_schema(): @@ -1488,7 +1489,8 @@ class EngineService(service.Service): resource_class.attributes_schema.items(), resource_class.base_attributes_schema.items()): schema = attributes.Schema.from_attribute(schema_data) - yield name, dict(schema) + if schema.support_status.status != support.HIDDEN: + yield name, dict(schema) return { rpc_api.RES_SCHEMA_RES_TYPE: type_name, diff --git a/heat/tests/common.py b/heat/tests/common.py index cfa8c6310..7f786f1ea 100644 --- a/heat/tests/common.py +++ b/heat/tests/common.py @@ -193,6 +193,9 @@ class HeatTestCase(testscenarios.WithScenarios, generic_rsrc.ResourceTypeSupportedKilo) resource._register_class('ResourceTypeHidden', generic_rsrc.ResourceTypeHidden) + resource._register_class( + 'ResourceWithHiddenPropertyAndAttribute', + generic_rsrc.ResourceWithHiddenPropertyAndAttribute) def patchobject(self, obj, attr, **kwargs): mockfixture = self.useFixture(mockpatch.PatchObject(obj, attr, diff --git a/heat/tests/engine/test_resource_type.py b/heat/tests/engine/test_resource_type.py index 242347cf0..35a76eaca 100644 --- a/heat/tests/engine/test_resource_type.py +++ b/heat/tests/engine/test_resource_type.py @@ -136,6 +136,37 @@ class ResourceTypeTest(common.HeatTestCase): schema = self.eng.resource_schema(self.ctx, type_name=type_name) self.assertEqual(expected, schema) + def test_resource_schema_with_hidden(self): + + type_name = 'ResourceWithHiddenPropertyAndAttribute' + expected = { + 'resource_type': type_name, + 'properties': { + 'supported': { + 'description': "Supported property.", + 'type': 'list', + 'immutable': False, + 'required': False, + 'update_allowed': False + } + }, + 'attributes': { + 'supported': {'description': 'Supported attribute.', + 'type': 'string'}, + 'show': { + 'description': 'Detailed information about resource.', + 'type': 'map'}, + }, + 'support_status': { + 'status': 'SUPPORTED', + 'version': None, + 'message': None, + 'previous_status': None + } + } + schema = self.eng.resource_schema(self.ctx, type_name=type_name) + self.assertEqual(expected, schema) + def _no_template_file(self, function): env = environment.Environment() info = environment.ResourceInfo(env.registry, diff --git a/heat/tests/generic_resource.py b/heat/tests/generic_resource.py index 5e81352d2..2b7fc2393 100644 --- a/heat/tests/generic_resource.py +++ b/heat/tests/generic_resource.py @@ -268,6 +268,25 @@ class ResourceWithListProp(ResourceWithFnGetRefIdType): properties_schema = {"listprop": properties.Schema(properties.Schema.LIST)} +class ResourceWithHiddenPropertyAndAttribute(GenericResource): + properties_schema = { + "supported": properties.Schema(properties.Schema.LIST, + "Supported property."), + "hidden": properties.Schema( + properties.Schema.LIST, + "Hidden property.", + support_status=support.SupportStatus(status=support.HIDDEN)) + } + attributes_schema = { + 'supported': attributes.Schema(type=attributes.Schema.STRING, + description='Supported attribute.'), + 'hidden': attributes.Schema( + type=attributes.Schema.STRING, + description='Hidden attribute', + support_status=support.SupportStatus(status=support.HIDDEN)) + } + + class StackResourceType(stack_resource.StackResource, GenericResource): def physical_resource_name(self): return "cb2f2b28-a663-4683-802c-4b40c916e1ff" |