From cafd53be11f8e556fcb19e7a35f9a426852eb1b0 Mon Sep 17 00:00:00 2001 From: tyagi Date: Mon, 13 Apr 2015 10:20:46 -0700 Subject: 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 --- heat/tests/generic_resource.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'heat/tests/generic_resource.py') 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" -- cgit v1.2.1