Commit 196da2bb authored by Ad Schellevis's avatar Ad Schellevis

(configd) template generation, return ERR when template not found. see...

(configd) template generation, return ERR when template not found. see https://github.com/opnsense/core/issues/329
parent 4370f811
......@@ -51,14 +51,16 @@ def execute(action, parameters):
tmpl.setConfig(conf.get())
filenames = tmpl.generate(parameters)
# send generated filenames to syslog
for filename in filenames:
syslog.syslog(syslog.LOG_DEBUG, ' %s generated %s' % (parameters, filename))
del conf
del tmpl
return 'OK'
# send generated filenames to syslog
if filenames is not None:
for filename in filenames:
syslog.syslog(syslog.LOG_DEBUG, ' %s generated %s' % (parameters, filename))
return 'OK'
else:
return 'ERR'
elif action.command == 'template.list':
# traverse all installed templates and return list
# the number of registered targets is returned between []
......
......@@ -272,9 +272,9 @@ class Template(object):
"""
:param module_name: module name in dot notation ( company.module ), may use wildcards
:param create_directory: automatically create directories to place template output in ( if not existing )
:return: list of generated output files
:return: list of generated output files or None if template not found
"""
result = []
result = None
for template_name in sorted(self.list_modules().keys()):
wildcard_pos = module_name.find('*')
do_generate = False
......@@ -290,6 +290,8 @@ class Template(object):
do_generate = True
if do_generate:
if result is None:
result = list()
syslog.syslog(syslog.LOG_NOTICE, "generate template container %s" % template_name)
for filename in self._generate(template_name, create_directory):
result.append(filename)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment