Include an OS::stack_id output when generating a template
When generating a template to act as a facade for an existing resource type, include an OS::stack_id output so that doing get_resource on the facade resource will return the physical ID of the inner resource. Change-Id: I257e9cc2eefd2cb8153e94cd05b21fed4b03c6c7
This commit is contained in:
parent
5553a6f29c
commit
e1124b2605
@ -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
|
@repr_wrapper
|
||||||
class Attributes(collections.Mapping):
|
class Attributes(collections.Mapping):
|
||||||
"""Models a collection of Resource Attributes."""
|
"""Models a collection of Resource Attributes."""
|
||||||
@ -156,8 +167,10 @@ class Attributes(collections.Mapping):
|
|||||||
attr_schema.update(resource_class.base_attributes_schema)
|
attr_schema.update(resource_class.base_attributes_schema)
|
||||||
attribs = Attributes._make_attributes(attr_schema).items()
|
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)
|
template_type)) for n, att in attribs)
|
||||||
|
outp['OS::stack_id'] = _stack_id_output(resource_name, template_type)
|
||||||
|
return outp
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def schema_from_outputs(json_snippet):
|
def schema_from_outputs(json_snippet):
|
||||||
|
@ -172,6 +172,9 @@ class AttributesTest(common.HeatTestCase):
|
|||||||
"test3": {
|
"test3": {
|
||||||
"Value": {"Fn::GetAtt": ["test_resource", "test3"]},
|
"Value": {"Fn::GetAtt": ["test_resource", "test3"]},
|
||||||
"Description": "Test attrib 3"
|
"Description": "Test attrib 3"
|
||||||
|
},
|
||||||
|
"OS::stack_id": {
|
||||||
|
"Value": {"Ref": "test_resource"},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MyTestResourceClass = mock.MagicMock()
|
MyTestResourceClass = mock.MagicMock()
|
||||||
@ -202,6 +205,9 @@ class AttributesTest(common.HeatTestCase):
|
|||||||
"test3": {
|
"test3": {
|
||||||
"value": {"get_attr": ["test_resource", "test3"]},
|
"value": {"get_attr": ["test_resource", "test3"]},
|
||||||
"description": "Test attrib 3"
|
"description": "Test attrib 3"
|
||||||
|
},
|
||||||
|
"OS::stack_id": {
|
||||||
|
"value": {"get_resource": "test_resource"},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MyTestResourceClass = mock.MagicMock()
|
MyTestResourceClass = mock.MagicMock()
|
||||||
|
@ -1442,6 +1442,9 @@ class ResourceTest(common.HeatTestCase):
|
|||||||
'show': {
|
'show': {
|
||||||
'Description': u'Detailed information about resource.',
|
'Description': u'Detailed information about resource.',
|
||||||
'Value': {"Fn::GetAtt": ["TestResource", "show"]}
|
'Value': {"Fn::GetAtt": ["TestResource", "show"]}
|
||||||
|
},
|
||||||
|
'OS::stack_id': {
|
||||||
|
'Value': {"Ref": "TestResource"}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1526,6 +1529,9 @@ class ResourceTest(common.HeatTestCase):
|
|||||||
'show': {
|
'show': {
|
||||||
'description': u'Detailed information about resource.',
|
'description': u'Detailed information about resource.',
|
||||||
'value': {"get_attr": ["TestResource", "show"]}
|
'value': {"get_attr": ["TestResource", "show"]}
|
||||||
|
},
|
||||||
|
'OS::stack_id': {
|
||||||
|
'value': {"get_resource": "TestResource"}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user