Added refs_map attribute to AutoScalingGroup
Change-Id: I3085e72623b3c110c225224d17cff3fb2008140a Closes-Bug: #1585316
This commit is contained in:
parent
0864664209
commit
a5cda7aeaf
@ -47,9 +47,9 @@ class AutoScalingResourceGroup(aws_asg.AutoScalingGroup):
|
||||
)
|
||||
|
||||
ATTRIBUTES = (
|
||||
OUTPUTS, OUTPUTS_LIST, CURRENT_SIZE, REFS,
|
||||
OUTPUTS, OUTPUTS_LIST, CURRENT_SIZE, REFS, REFS_MAP,
|
||||
) = (
|
||||
'outputs', 'outputs_list', 'current_size', 'refs',
|
||||
'outputs', 'outputs_list', 'current_size', 'refs', 'refs_map',
|
||||
)
|
||||
|
||||
properties_schema = {
|
||||
@ -142,6 +142,13 @@ class AutoScalingResourceGroup(aws_asg.AutoScalingGroup):
|
||||
type=attributes.Schema.LIST,
|
||||
support_status=support.SupportStatus(version='7.0.0'),
|
||||
),
|
||||
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'),
|
||||
),
|
||||
|
||||
}
|
||||
update_policy_schema = {}
|
||||
|
||||
@ -173,6 +180,10 @@ class AutoScalingResourceGroup(aws_asg.AutoScalingGroup):
|
||||
if key == self.REFS:
|
||||
refs = grouputils.get_member_refids(self)
|
||||
return refs
|
||||
if key == self.REFS_MAP:
|
||||
members = grouputils.get_members(self)
|
||||
refs_map = {m.name: m.resource_id for m in members}
|
||||
return refs_map
|
||||
if path:
|
||||
members = grouputils.get_members(self)
|
||||
attrs = ((rsrc.name, rsrc.FnGetAtt(*path)) for rsrc in members)
|
||||
|
@ -413,6 +413,24 @@ class HeatScalingGroupAttrTest(common.HeatTestCase):
|
||||
self.assertEqual(expected, found)
|
||||
mock_get.assert_called_once_with(self.group)
|
||||
|
||||
def test_output_refs_map(self):
|
||||
# Setup
|
||||
mock_members = self.patchobject(grouputils, 'get_members')
|
||||
members = [mock.MagicMock(), mock.MagicMock()]
|
||||
members[0].name = 'resource-1-name'
|
||||
members[0].resource_id = 'resource-1-id'
|
||||
members[1].name = 'resource-2-name'
|
||||
members[1].resource_id = 'resource-2-id'
|
||||
mock_members.return_value = members
|
||||
|
||||
# Test
|
||||
found = self.group.FnGetAtt('refs_map')
|
||||
|
||||
# Verify
|
||||
expected = {'resource-1-name': 'resource-1-id',
|
||||
'resource-2-name': 'resource-2-id'}
|
||||
self.assertEqual(expected, found)
|
||||
|
||||
def test_output_attribute_dict(self):
|
||||
mock_members = self.patchobject(grouputils, 'get_members')
|
||||
members = []
|
||||
|
Loading…
Reference in New Issue
Block a user