mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
update py renderer to use the standard template systems
This commit is contained in:
parent
6eb8134359
commit
c43defd04d
@ -5,9 +5,13 @@ The sls file should contain a function called ``sls`` which returns high state
|
||||
data
|
||||
'''
|
||||
|
||||
# Import python libs
|
||||
import imp
|
||||
import os
|
||||
|
||||
# Import Salt libs
|
||||
from salt.exceptions import SaltRenderError
|
||||
import salt.utils.templates
|
||||
|
||||
def render(template, env='', sls=''):
|
||||
'''
|
||||
@ -16,14 +20,17 @@ def render(template, env='', sls=''):
|
||||
if not os.path.isfile(template):
|
||||
return {}
|
||||
|
||||
mod = imp.load_source(
|
||||
os.path.basename(template).split('.')[0],
|
||||
template
|
||||
)
|
||||
mod.salt = __salt__
|
||||
mod.grains = __grains__
|
||||
mod.pillar = __pillar__
|
||||
mod.env = env
|
||||
mod.sls = sls
|
||||
tmp_data = salt.utils.templates.py(
|
||||
template_file,
|
||||
True,
|
||||
salt=__salt__,
|
||||
grains=__grains__,
|
||||
opts=__opts__,
|
||||
pillar=__pillar__,
|
||||
env=env,
|
||||
sls=sls)
|
||||
if not tmp_data.get('result', False):
|
||||
raise SaltRenderError(tmp_data.get('data',
|
||||
'Unknown render error in yaml_jinja renderer'))
|
||||
|
||||
return mod.run()
|
||||
return tmp_data['data']
|
||||
|
Loading…
Reference in New Issue
Block a user