diff --git a/heat/engine/manager.py b/heat/engine/manager.py index b6872c3273..a39d4223e9 100644 --- a/heat/engine/manager.py +++ b/heat/engine/manager.py @@ -131,7 +131,6 @@ class EngineManager(manager.Manager): arg3 -> Template of stack you want to create. arg4 -> Params passed from API. """ - auth.authenticate(context) logger.info('validate_template') @@ -139,20 +138,29 @@ class EngineManager(manager.Manager): msg = _("No Template provided.") return webob.exc.HTTPBadRequest(explanation=msg) - stack_name = 'validate' - try: - tmpl = parser.Template(template) - user_params = parser.Parameters(stack_name, tmpl, params) - s = parser.Stack(context, stack_name, tmpl, user_params) - except KeyError as ex: - res = ('A Fn::FindInMap operation referenced ' - 'a non-existent map [%s]' % str(ex)) + tmpl = parser.Template(template) + resources = template.get('Resources', []) - result = {'Description': 'Malformed Query Response [%s]' % (res), - 'Parameters': []} - else: - result = s.validate() + if not resources: + return {'Error': 'At least one Resources member must be defined.'} + for res in resources.values(): + if not res.get('Type'): + return {'Error': + 'Every Resources object must contain a Type member.'} + + parameters = [] + for param_key, param in template.get('Parameters', {}).items(): + parameters.append({ + 'NoEcho': param.get('NoEcho', 'false'), + 'ParameterKey': param_key, + 'Description': param.get('Description', '') + }) + + result = { + 'Description': template.get('Description', ''), + 'Parameters': parameters, + } return {'ValidateTemplateResult': result} def get_template(self, context, stack_name, params): diff --git a/heat/tests/test_validate.py b/heat/tests/test_validate.py index 7dea58218f..975e508244 100644 --- a/heat/tests/test_validate.py +++ b/heat/tests/test_validate.py @@ -269,7 +269,7 @@ class validateTest(unittest.TestCase): res = dict(manager. validate_template(None, t, params)['ValidateTemplateResult']) print 'res %s' % res - self.assertEqual(res['Description'], 'Successfully validated') + self.assertEqual(res['Description'], 'test.') def test_validate_ref_invalid(self): t = json.loads(test_template_ref % 'WikiDatabasez') @@ -301,7 +301,7 @@ class validateTest(unittest.TestCase): manager = managers.EngineManager() res = dict(manager. validate_template(None, t, params)['ValidateTemplateResult']) - self.assertEqual(res['Description'], 'Successfully validated') + self.assertEqual(res['Description'], 'test.') def test_validate_findinmap_invalid(self): t = json.loads(test_template_findinmap_invalid)