Merge "Include an OS::stack_id output when generating a template"
This commit is contained in:
commit
8cf1724f85
@ -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):
|
||||
|
@ -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()
|
||||
|
@ -1478,6 +1478,9 @@ class ResourceTest(common.HeatTestCase):
|
||||
'show': {
|
||||
'Description': u'Detailed information about resource.',
|
||||
'Value': {"Fn::GetAtt": ["TestResource", "show"]}
|
||||
},
|
||||
'OS::stack_id': {
|
||||
'Value': {"Ref": "TestResource"}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1562,6 +1565,9 @@ class ResourceTest(common.HeatTestCase):
|
||||
'show': {
|
||||
'description': u'Detailed information about resource.',
|
||||
'value': {"get_attr": ["TestResource", "show"]}
|
||||
},
|
||||
'OS::stack_id': {
|
||||
'value': {"get_resource": "TestResource"}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user