Merge "Raise InvalidTemplateReference for missing resources"
This commit is contained in:
commit
44f91f0186
@ -85,8 +85,9 @@ class ParamRef(function.Function):
|
||||
|
||||
try:
|
||||
return self.parameters[param_name]
|
||||
except (KeyError, ValueError):
|
||||
raise exception.UserParameterMissing(key=param_name)
|
||||
except KeyError:
|
||||
raise exception.InvalidTemplateReference(resource=param_name,
|
||||
key='unknown')
|
||||
|
||||
|
||||
class ResourceRef(function.Function):
|
||||
@ -98,10 +99,14 @@ class ResourceRef(function.Function):
|
||||
{ "Ref" : "<resource_name>" }
|
||||
'''
|
||||
|
||||
def _resource(self):
|
||||
def _resource(self, path='unknown'):
|
||||
resource_name = function.resolve(self.args)
|
||||
|
||||
return self.stack[resource_name]
|
||||
try:
|
||||
return self.stack[resource_name]
|
||||
except KeyError:
|
||||
raise exception.InvalidTemplateReference(resource=resource_name,
|
||||
key=path)
|
||||
|
||||
def result(self):
|
||||
return self._resource().FnGetRefId()
|
||||
@ -150,15 +155,14 @@ class GetAtt(function.Function):
|
||||
|
||||
return resource_name, attribute
|
||||
|
||||
def _resource(self):
|
||||
def _resource(self, path='unknown'):
|
||||
resource_name = function.resolve(self._resource_name)
|
||||
|
||||
try:
|
||||
return self.stack[resource_name]
|
||||
except KeyError:
|
||||
raise exception.InvalidTemplateAttribute(
|
||||
resource=resource_name,
|
||||
key=function.resolve(self._attribute))
|
||||
raise exception.InvalidTemplateReference(resource=resource_name,
|
||||
key=path)
|
||||
|
||||
def result(self):
|
||||
attribute = function.resolve(self._attribute)
|
||||
|
@ -220,7 +220,7 @@ class Parameter(object):
|
||||
if self.has_default():
|
||||
return self.default()
|
||||
|
||||
raise KeyError(_('Missing parameter %s') % self.name)
|
||||
raise exception.UserParameterMissing(key=self.name)
|
||||
|
||||
def hidden(self):
|
||||
'''
|
||||
|
@ -649,7 +649,7 @@ class StackTest(test_parser.StackTest):
|
||||
self.stack.state)
|
||||
|
||||
snippet = {'Value': {'get_attr': ['resource2', 'who_cares']}}
|
||||
self.assertRaises(exception.InvalidTemplateAttribute,
|
||||
self.assertRaises(exception.InvalidTemplateReference,
|
||||
self.resolve, snippet)
|
||||
|
||||
@utils.stack_delete_after
|
||||
|
Loading…
Reference in New Issue
Block a user