Merge "Pass on outputs errors to parent stacks"
This commit is contained in:
commit
518d651ee9
|
@ -158,6 +158,10 @@ class InvalidTemplateReference(HeatException):
|
||||||
' is incorrect.')
|
' is incorrect.')
|
||||||
|
|
||||||
|
|
||||||
|
class TemplateOutputError(HeatException):
|
||||||
|
msg_fmt = _('Error in %(resource)s output %(attribute)s: %(message)s')
|
||||||
|
|
||||||
|
|
||||||
class InvalidExternalResourceDependency(HeatException):
|
class InvalidExternalResourceDependency(HeatException):
|
||||||
msg_fmt = _("Invalid dependency with external %(resource_type)s "
|
msg_fmt = _("Invalid dependency with external %(resource_type)s "
|
||||||
"resource: %(external_id)s")
|
"resource: %(external_id)s")
|
||||||
|
|
|
@ -585,8 +585,10 @@ class StackResource(resource.Resource):
|
||||||
particular exception, not KeyError, being raised if the key does not
|
particular exception, not KeyError, being raised if the key does not
|
||||||
exist.)
|
exist.)
|
||||||
"""
|
"""
|
||||||
if self._outputs is None or self._outputs.get(op,
|
if (self._outputs is None or
|
||||||
NotImplemented) is None:
|
(op in self._outputs and
|
||||||
|
rpc_api.OUTPUT_ERROR not in self._outputs[op] and
|
||||||
|
self._outputs[op].get(rpc_api.OUTPUT_VALUE) is None)):
|
||||||
stack_identity = self.nested_identifier()
|
stack_identity = self.nested_identifier()
|
||||||
if stack_identity is None:
|
if stack_identity is None:
|
||||||
return
|
return
|
||||||
|
@ -595,14 +597,20 @@ class StackResource(resource.Resource):
|
||||||
if not stack:
|
if not stack:
|
||||||
return
|
return
|
||||||
outputs = stack[0].get(rpc_api.STACK_OUTPUTS) or {}
|
outputs = stack[0].get(rpc_api.STACK_OUTPUTS) or {}
|
||||||
self._outputs = {o[rpc_api.OUTPUT_KEY]: o[rpc_api.OUTPUT_VALUE]
|
self._outputs = {o[rpc_api.OUTPUT_KEY]: o for o in outputs}
|
||||||
for o in outputs if rpc_api.OUTPUT_ERROR not in o}
|
|
||||||
|
|
||||||
try:
|
if op not in self._outputs:
|
||||||
return self._outputs[op]
|
|
||||||
except KeyError:
|
|
||||||
raise exception.InvalidTemplateAttribute(resource=self.name,
|
raise exception.InvalidTemplateAttribute(resource=self.name,
|
||||||
key=op)
|
key=op)
|
||||||
|
|
||||||
|
output_data = self._outputs[op]
|
||||||
|
if rpc_api.OUTPUT_ERROR in output_data:
|
||||||
|
raise exception.TemplateOutputError(
|
||||||
|
resource=self.name,
|
||||||
|
attribute=op,
|
||||||
|
message=output_data[rpc_api.OUTPUT_ERROR])
|
||||||
|
|
||||||
|
return output_data[rpc_api.OUTPUT_VALUE]
|
||||||
|
|
||||||
def _resolve_attribute(self, name):
|
def _resolve_attribute(self, name):
|
||||||
return self.get_output(name)
|
return self.get_output(name)
|
||||||
|
|
|
@ -319,7 +319,7 @@ class ProviderTemplateTest(common.HeatTestCase):
|
||||||
output = {'outputs': [{'output_key': 'Foo', 'output_value': None,
|
output = {'outputs': [{'output_key': 'Foo', 'output_value': None,
|
||||||
'output_error': 'it is all bad'}]}
|
'output_error': 'it is all bad'}]}
|
||||||
temp_res._rpc_client.show_stack.return_value = [output]
|
temp_res._rpc_client.show_stack.return_value = [output]
|
||||||
self.assertRaises(exception.InvalidTemplateAttribute,
|
self.assertRaises(exception.TemplateOutputError,
|
||||||
temp_res.FnGetAtt, 'Foo')
|
temp_res.FnGetAtt, 'Foo')
|
||||||
|
|
||||||
def test_properties_normal(self):
|
def test_properties_normal(self):
|
||||||
|
|
Loading…
Reference in New Issue