Merge "Enable service validate-template for hot template"

This commit is contained in:
Jenkins 2013-07-26 01:18:47 +00:00 committed by Gerrit Code Review
commit bb1302e340
2 changed files with 19 additions and 2 deletions

View File

@ -306,7 +306,7 @@ class EngineService(service.Service):
return webob.exc.HTTPBadRequest(explanation=msg)
tmpl = parser.Template(template)
tmpl_resources = template.get('Resources', [])
tmpl_resources = tmpl.get('Resources', [])
if not tmpl_resources:
return {'Error': 'At least one Resources member must be defined.'}
@ -330,7 +330,7 @@ class EngineService(service.Service):
params = tmpl_params.map(format_validate_parameter, is_real_param)
result = {
'Description': template.get('Description', ''),
'Description': tmpl.get('Description', ''),
'Parameters': params,
}
return result

View File

@ -531,6 +531,23 @@ class validateTest(HeatTestCase):
res = dict(engine.validate_template(None, t))
self.assertEqual(res['Description'], 'test.')
def test_validate_hot_valid(self):
t = template_format.parse(
"""
heat_template_version: 2013-05-23
description: test.
resources:
my_instance:
type: AWS::EC2::Instance
""")
self.m.StubOutWithMock(instances.Instance, 'nova')
instances.Instance.nova().AndReturn(self.fc)
self.m.ReplayAll()
engine = service.EngineService('a', 't')
res = dict(engine.validate_template(None, t))
self.assertEqual(res['Description'], 'test.')
def test_validate_ref_invalid(self):
t = template_format.parse(test_template_ref % 'WikiDatabasez')