Merge "Added refs_map attribute to AutoScalingGroup"
This commit is contained in:
commit
b7d59bbb1b
@ -47,9 +47,9 @@ class AutoScalingResourceGroup(aws_asg.AutoScalingGroup):
|
|||||||
)
|
)
|
||||||
|
|
||||||
ATTRIBUTES = (
|
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 = {
|
properties_schema = {
|
||||||
@ -142,6 +142,13 @@ class AutoScalingResourceGroup(aws_asg.AutoScalingGroup):
|
|||||||
type=attributes.Schema.LIST,
|
type=attributes.Schema.LIST,
|
||||||
support_status=support.SupportStatus(version='7.0.0'),
|
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 = {}
|
update_policy_schema = {}
|
||||||
|
|
||||||
@ -173,6 +180,10 @@ class AutoScalingResourceGroup(aws_asg.AutoScalingGroup):
|
|||||||
if key == self.REFS:
|
if key == self.REFS:
|
||||||
refs = grouputils.get_member_refids(self)
|
refs = grouputils.get_member_refids(self)
|
||||||
return refs
|
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:
|
if path:
|
||||||
members = grouputils.get_members(self)
|
members = grouputils.get_members(self)
|
||||||
attrs = ((rsrc.name, rsrc.FnGetAtt(*path)) for rsrc in members)
|
attrs = ((rsrc.name, rsrc.FnGetAtt(*path)) for rsrc in members)
|
||||||
|
@ -413,6 +413,24 @@ class HeatScalingGroupAttrTest(common.HeatTestCase):
|
|||||||
self.assertEqual(expected, found)
|
self.assertEqual(expected, found)
|
||||||
mock_get.assert_called_once_with(self.group)
|
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):
|
def test_output_attribute_dict(self):
|
||||||
mock_members = self.patchobject(grouputils, 'get_members')
|
mock_members = self.patchobject(grouputils, 'get_members')
|
||||||
members = []
|
members = []
|
||||||
|
Loading…
Reference in New Issue
Block a user