Merge "Added refs_map attribute to resource groups"
This commit is contained in:
commit
63abfbb4cc
@ -109,9 +109,9 @@ class ResourceGroup(stack_resource.StackResource):
|
||||
)
|
||||
|
||||
ATTRIBUTES = (
|
||||
REFS, ATTR_ATTRIBUTES,
|
||||
REFS, REFS_MAP, ATTR_ATTRIBUTES,
|
||||
) = (
|
||||
'refs', 'attributes',
|
||||
'refs', 'refs_map', 'attributes',
|
||||
)
|
||||
|
||||
properties_schema = {
|
||||
@ -200,6 +200,12 @@ class ResourceGroup(stack_resource.StackResource):
|
||||
_("A list of resource IDs for the resources in the group."),
|
||||
type=attributes.Schema.LIST
|
||||
),
|
||||
REFS_MAP: attributes.Schema(
|
||||
_("A map of resource names to IDs for the resources in "
|
||||
"the group."),
|
||||
type=attributes.Schema.MAP,
|
||||
support_status=support.SupportStatus(version='7.0.0'),
|
||||
),
|
||||
ATTR_ATTRIBUTES: attributes.Schema(
|
||||
_("A map of resource names to the specified attribute of each "
|
||||
"individual resource. "
|
||||
@ -418,6 +424,10 @@ class ResourceGroup(stack_resource.StackResource):
|
||||
if key == self.REFS:
|
||||
vals = [grouputils.get_rsrc_id(self, key, False, n) for n in names]
|
||||
return attributes.select_from_attribute(vals, path)
|
||||
if key == self.REFS_MAP:
|
||||
refs_map = {n: grouputils.get_rsrc_id(self, key, False, n)
|
||||
for n in names}
|
||||
return refs_map
|
||||
if key == self.ATTR_ATTRIBUTES:
|
||||
if not path:
|
||||
raise exception.InvalidTemplateAttribute(
|
||||
|
@ -786,6 +786,12 @@ class ResourceGroupAttrTest(common.HeatTestCase):
|
||||
self.assertEqual(expected[1], resg.FnGetAtt("refs", 1))
|
||||
self.assertIsNone(resg.FnGetAtt("refs", 2))
|
||||
|
||||
def test_aggregate_refs_map(self):
|
||||
resg = self._create_dummy_stack()
|
||||
found = resg.FnGetAtt("refs_map")
|
||||
expected = {'0': 'ID-0', '1': 'ID-1'}
|
||||
self.assertEqual(expected, found)
|
||||
|
||||
def test_aggregate_outputs(self):
|
||||
"""Test outputs aggregation."""
|
||||
expected = {'0': ['foo', 'bar'], '1': ['foo', 'bar']}
|
||||
|
Loading…
x
Reference in New Issue
Block a user