From 62b618e8e18a5b0d26960c657d18879948633247 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Ole=C5=9B?= Date: Thu, 25 Jun 2015 14:00:22 +0000 Subject: [PATCH] Validate created resources --- solar/solar/core/virtual_resource.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/solar/solar/core/virtual_resource.py b/solar/solar/core/virtual_resource.py index 697c3378..ce3fcbf7 100644 --- a/solar/solar/core/virtual_resource.py +++ b/solar/solar/core/virtual_resource.py @@ -7,6 +7,7 @@ import yaml from jinja2 import Template, Environment, meta from solar import utils +from solar.core import validation from solar.core import resource as resource_module from solar.core import signals @@ -58,8 +59,17 @@ def create_virtual_resource(vr_name, template): emitter = db[emitter] reciver = db[reciver] signals.connect(emitter, reciver, mapping) - return created_resources + for r in db.values(): + if not isinstance(r, resource_module.Resource): + continue + + print 'Validating {}'.format(r.name) + errors = validation.validate_resource(r) + if errors: + print 'ERROR: %s: %s' % (r.name, errors) + #import sys;sys.exit() + return created_resources def create(name, path, kwargs, virtual_resource=None): if not os.path.exists(path):