~brad-marshall/charms/trusty/ntp/remove-ntp-status-check

« back to all changes in this revision

Viewing changes to hooks/utils.py

[r=cory_fu,a=lazypower]  Christopher Glass 2014-08-05 Removed ntp-specific teplating code and replaced it with the charmhelpers version instead

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
from charmhelpers.fetch import (
2
 
    apt_install,
3
 
    filter_installed_packages
4
 
)
5
 
 
6
 
 
7
 
TEMPLATES_DIR = 'templates'
8
 
 
9
 
try:
10
 
    import jinja2
11
 
except ImportError:
12
 
    apt_install(filter_installed_packages(['python-jinja2']),
13
 
                fatal=True)
14
 
    import jinja2
15
 
 
16
 
 
17
 
def render_template(template_name, context, template_dir=TEMPLATES_DIR):
18
 
    templates = jinja2.Environment(
19
 
        loader=jinja2.FileSystemLoader(template_dir))
20
 
    template = templates.get_template(template_name)
21
 
    return template.render(context)