diff --git a/heat/engine/attributes.py b/heat/engine/attributes.py index e72caf23b5..59fe0c59b0 100644 --- a/heat/engine/attributes.py +++ b/heat/engine/attributes.py @@ -122,6 +122,17 @@ class Attribute(object): } +def _stack_id_output(resource_name, template_type='cfn'): + if template_type == 'hot': + return { + "value": {"get_resource": resource_name}, + } + else: + return { + "Value": {"Ref": resource_name}, + } + + @repr_wrapper class Attributes(collections.Mapping): """Models a collection of Resource Attributes.""" @@ -156,8 +167,10 @@ class Attributes(collections.Mapping): attr_schema.update(resource_class.base_attributes_schema) attribs = Attributes._make_attributes(attr_schema).items() - return dict((n, att.as_output(resource_name, + outp = dict((n, att.as_output(resource_name, template_type)) for n, att in attribs) + outp['OS::stack_id'] = _stack_id_output(resource_name, template_type) + return outp @staticmethod def schema_from_outputs(json_snippet): diff --git a/heat/tests/test_attributes.py b/heat/tests/test_attributes.py index 77b6d1b799..49ce6de1a3 100644 --- a/heat/tests/test_attributes.py +++ b/heat/tests/test_attributes.py @@ -172,6 +172,9 @@ class AttributesTest(common.HeatTestCase): "test3": { "Value": {"Fn::GetAtt": ["test_resource", "test3"]}, "Description": "Test attrib 3" + }, + "OS::stack_id": { + "Value": {"Ref": "test_resource"}, } } MyTestResourceClass = mock.MagicMock() @@ -202,6 +205,9 @@ class AttributesTest(common.HeatTestCase): "test3": { "value": {"get_attr": ["test_resource", "test3"]}, "description": "Test attrib 3" + }, + "OS::stack_id": { + "value": {"get_resource": "test_resource"}, } } MyTestResourceClass = mock.MagicMock() diff --git a/heat/tests/test_resource.py b/heat/tests/test_resource.py index b7c9442abe..7459a51e83 100644 --- a/heat/tests/test_resource.py +++ b/heat/tests/test_resource.py @@ -1442,6 +1442,9 @@ class ResourceTest(common.HeatTestCase): 'show': { 'Description': u'Detailed information about resource.', 'Value': {"Fn::GetAtt": ["TestResource", "show"]} + }, + 'OS::stack_id': { + 'Value': {"Ref": "TestResource"} } } } @@ -1526,6 +1529,9 @@ class ResourceTest(common.HeatTestCase): 'show': { 'description': u'Detailed information about resource.', 'value': {"get_attr": ["TestResource", "show"]} + }, + 'OS::stack_id': { + 'value': {"get_resource": "TestResource"} } } }