Permalink
Browse files

update py renderer to use the standard template systems

  • Loading branch information...
1 parent 6eb8134 commit c43defd04d448989c11f720b4e8223ca9b0f52ec @thatch45 thatch45 committed Apr 3, 2012
Showing with 17 additions and 10 deletions.
  1. +17 −10 salt/renderers/py.py
View
@@ -5,9 +5,13 @@
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']

0 comments on commit c43defd

Please sign in to comment.