Add an InvalidTemplateVersion exception
Change-Id: I9dcc9a2d1ee611d0b8d6554c238784ea98a77930
This commit is contained in:
parent
4f20c532e3
commit
445e0b9e2f
|
@ -276,6 +276,7 @@ def map_remote_error(ex):
|
||||||
'WatchRuleNotFound',
|
'WatchRuleNotFound',
|
||||||
'StackValidationFailed',
|
'StackValidationFailed',
|
||||||
'InvalidTemplateReference',
|
'InvalidTemplateReference',
|
||||||
|
'InvalidTemplateVersion',
|
||||||
'UnknownUserParameter',
|
'UnknownUserParameter',
|
||||||
'UserParameterMissing',
|
'UserParameterMissing',
|
||||||
'InvalidTemplateParameter',
|
'InvalidTemplateParameter',
|
||||||
|
|
|
@ -71,6 +71,7 @@ class FaultWrapper(wsgi.Middleware):
|
||||||
'StackExists': webob.exc.HTTPConflict,
|
'StackExists': webob.exc.HTTPConflict,
|
||||||
'StackValidationFailed': webob.exc.HTTPBadRequest,
|
'StackValidationFailed': webob.exc.HTTPBadRequest,
|
||||||
'InvalidTemplateReference': webob.exc.HTTPBadRequest,
|
'InvalidTemplateReference': webob.exc.HTTPBadRequest,
|
||||||
|
'InvalidTemplateVersion': webob.exc.HTTPBadRequest,
|
||||||
'UnknownUserParameter': webob.exc.HTTPBadRequest,
|
'UnknownUserParameter': webob.exc.HTTPBadRequest,
|
||||||
'RevertFailed': webob.exc.HTTPInternalServerError,
|
'RevertFailed': webob.exc.HTTPInternalServerError,
|
||||||
'StopActionFailed': webob.exc.HTTPInternalServerError,
|
'StopActionFailed': webob.exc.HTTPInternalServerError,
|
||||||
|
|
|
@ -192,6 +192,10 @@ class UnknownUserParameter(HeatException):
|
||||||
msg_fmt = _("The Parameter (%(key)s) was not defined in template.")
|
msg_fmt = _("The Parameter (%(key)s) was not defined in template.")
|
||||||
|
|
||||||
|
|
||||||
|
class InvalidTemplateVersion(HeatException):
|
||||||
|
msg_fmt = _("The template version is invalid: %(explanation)s")
|
||||||
|
|
||||||
|
|
||||||
class InvalidTemplateParameter(HeatException):
|
class InvalidTemplateParameter(HeatException):
|
||||||
msg_fmt = _("The Parameter (%(key)s) has no attributes.")
|
msg_fmt = _("The Parameter (%(key)s) has no attributes.")
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from heat.common import exception
|
||||||
from heat.engine import template
|
from heat.engine import template
|
||||||
from heat.engine.cfn import template as cfn_template
|
from heat.engine.cfn import template as cfn_template
|
||||||
from heat.engine.hot import parameters
|
from heat.engine.hot import parameters
|
||||||
|
@ -47,11 +48,8 @@ class HOTemplate(template.Template):
|
||||||
version = template.get(self.VERSION, '2013-05-23')
|
version = template.get(self.VERSION, '2013-05-23')
|
||||||
|
|
||||||
if version not in self.VERSIONS:
|
if version not in self.VERSIONS:
|
||||||
msg = _('"%(version)s" is not a valid '
|
msg = _('Should be one of: %s') % str(self.VERSIONS)
|
||||||
'heat_template_version. Should be one of: '
|
raise exception.InvalidTemplateVersion(explanation=msg)
|
||||||
'%(valid)s')
|
|
||||||
raise ValueError(msg % {'version': version,
|
|
||||||
'valid': str(self.VERSIONS)})
|
|
||||||
|
|
||||||
super(HOTemplate, self).__init__(template, *args, **kwargs)
|
super(HOTemplate, self).__init__(template, *args, **kwargs)
|
||||||
self.version = self.VERSION, version
|
self.version = self.VERSION, version
|
||||||
|
|
|
@ -310,9 +310,8 @@ class HOTemplateTest(HeatTestCase):
|
||||||
|
|
||||||
tmpl_str = "heat_template_version: this-ain't-valid"
|
tmpl_str = "heat_template_version: this-ain't-valid"
|
||||||
hot_tmpl = template_format.parse(tmpl_str)
|
hot_tmpl = template_format.parse(tmpl_str)
|
||||||
exc = self.assertRaises(ValueError, template.Template, hot_tmpl)
|
self.assertRaises(exception.InvalidTemplateVersion,
|
||||||
self.assertIn('"this-ain\'t-valid" is not a valid '
|
template.Template, hot_tmpl)
|
||||||
'heat_template_version', str(exc))
|
|
||||||
|
|
||||||
def test_valid_hot_version(self):
|
def test_valid_hot_version(self):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue