diff options
author | tyagi <ishant.tyagi@hp.com> | 2015-04-13 10:20:46 -0700 |
---|---|---|
committer | tyagi <ishant.tyagi@hp.com> | 2015-05-06 00:50:47 -0700 |
commit | cafd53be11f8e556fcb19e7a35f9a426852eb1b0 (patch) | |
tree | 9b0ca7f4a5dd4c4d6d4335c3c630699e301d478c /heat/tests/generic_resource.py | |
parent | 477d331f67027440469c9d05134b9e202cf0a677 (diff) | |
download | heat-cafd53be11f8e556fcb19e7a35f9a426852eb1b0.tar.gz |
Add type field to the resource attributes schema
Add data type for the attributes. This will help
1) validating the attibute against its type
2) resource-schema api will show the attribute type
3) template authors will know what type of value to
expect making indexing and mapping easier
4) generating docs for the attribute type
Implements: blueprint add-type-in-attributes-schema
Change-Id: Ifc92c57ec1ddd2ab5f810587a1d33e762308dd8a
Diffstat (limited to 'heat/tests/generic_resource.py')
-rw-r--r-- | heat/tests/generic_resource.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/heat/tests/generic_resource.py b/heat/tests/generic_resource.py index 456e67dab..c1fc6969b 100644 --- a/heat/tests/generic_resource.py +++ b/heat/tests/generic_resource.py @@ -162,3 +162,18 @@ class ResourceWithCustomConstraint(GenericResource): 'Foo': properties.Schema( properties.Schema.STRING, constraints=[constraints.CustomConstraint('neutron.network')])} + + +class ResourceWithAttributeType(GenericResource): + attributes_schema = { + 'attr1': attributes.Schema('A generic attribute', + type=attributes.Schema.STRING), + 'attr2': attributes.Schema('Another generic attribute', + type=attributes.Schema.MAP) + } + + def _resolve_attribute(self, name): + if name == 'attr1': + return "valid_sting" + elif name == 'attr2': + return "invalid_type" |