diff options
author | Rabi Mishra <ramishra@redhat.com> | 2015-08-13 11:04:17 +0530 |
---|---|---|
committer | Rabi Mishra <ramishra@redhat.com> | 2015-08-14 08:52:54 +0530 |
commit | a7e473bcc89da0f3191d542fadf8328a48c78b88 (patch) | |
tree | 1762d4ce9bba0613f08f29ef3549e643dc2be7ff /heat | |
parent | 5fcec9b23754f048de2fbbefece6730ffe34f95c (diff) | |
download | heat-a7e473bcc89da0f3191d542fadf8328a48c78b88.tar.gz |
Add option to specify metadata for RG resources
Provides an optional property to specify metadata
for the resources.
Change-Id: I6cd19f759a907bf913e53aa0ca26a12ee157a86e
Diffstat (limited to 'heat')
-rw-r--r-- | heat/engine/resources/openstack/heat/resource_group.py | 12 | ||||
-rw-r--r-- | heat/tests/test_resource_group.py | 26 |
2 files changed, 36 insertions, 2 deletions
diff --git a/heat/engine/resources/openstack/heat/resource_group.py b/heat/engine/resources/openstack/heat/resource_group.py index 12d570c20..673dc32f6 100644 --- a/heat/engine/resources/openstack/heat/resource_group.py +++ b/heat/engine/resources/openstack/heat/resource_group.py @@ -83,9 +83,9 @@ class ResourceGroup(stack_resource.StackResource): ) _RESOURCE_DEF_KEYS = ( - RESOURCE_DEF_TYPE, RESOURCE_DEF_PROPERTIES, + RESOURCE_DEF_TYPE, RESOURCE_DEF_PROPERTIES, RESOURCE_DEF_METADATA, ) = ( - 'type', 'properties', + 'type', 'properties', 'metadata', ) _REMOVAL_POLICIES_KEYS = ( @@ -146,6 +146,12 @@ class ResourceGroup(stack_resource.StackResource): properties.Schema.MAP, _('Property values for the resources in the group') ), + RESOURCE_DEF_METADATA: properties.Schema( + properties.Schema.MAP, + _('Supplied metadata for the resources in the group'), + support_status=support.SupportStatus(version='5.0.0') + ), + }, required=True, update_allowed=True @@ -411,6 +417,8 @@ class ResourceGroup(stack_resource.StackResource): res_def = self.properties[self.RESOURCE_DEF] if res_def[self.RESOURCE_DEF_PROPERTIES] is None: res_def[self.RESOURCE_DEF_PROPERTIES] = {} + if res_def[self.RESOURCE_DEF_METADATA] is None: + del res_def[self.RESOURCE_DEF_METADATA] if not include_all: resource_def_props = res_def[self.RESOURCE_DEF_PROPERTIES] clean = dict((k, v) for k, v in resource_def_props.items() diff --git a/heat/tests/test_resource_group.py b/heat/tests/test_resource_group.py index 52e1c5996..346b44dda 100644 --- a/heat/tests/test_resource_group.py +++ b/heat/tests/test_resource_group.py @@ -187,6 +187,32 @@ class ResourceGroupTest(common.HeatTestCase): } self.assertEqual(expect, resg._assemble_nested([])) + def test_assemble_nested_with_metadata(self): + templ = copy.deepcopy(template) + res_def = templ["resources"]["group1"]["properties"]['resource_def'] + res_def['properties']['Foo'] = None + res_def['metadata'] = { + 'priority': 'low', + 'role': 'webserver' + } + stack = utils.parse_stack(templ) + snip = stack.t.resource_definitions(stack)['group1'] + resg = resource_group.ResourceGroup('test', snip, stack) + expect = { + "heat_template_version": "2013-05-23", + "resources": { + "0": { + "type": "OverwrittenFnGetRefIdType", + "properties": {}, + "metadata": { + 'priority': 'low', + 'role': 'webserver' + } + } + } + } + self.assertEqual(expect, resg._assemble_nested(['0'])) + def test_assemble_nested_rolling_update(self): expect = { "heat_template_version": "2013-05-23", |