Merge "Raise InvalidTemplateReference for missing resources"

This commit is contained in:
Jenkins 2014-04-30 16:51:25 +00:00 committed by Gerrit Code Review
commit 44f91f0186
3 changed files with 14 additions and 10 deletions

View File

@ -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)
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)

View File

@ -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):
'''

View File

@ -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