~hopem/charms/trusty/ceph-mon/lp1548478

« back to all changes in this revision

Viewing changes to hooks/utils.py

  • Committer: Corey Bryant
  • Date: 2014-12-15 21:13:11 UTC
  • mto: (92.3.1 ceph)
  • mto: This revision was merged to the branch mainline in revision 94.
  • Revision ID: corey.bryant@canonical.com-20141215211311-ancbixpja98wwz86
Drop render_template() and use charm-helpers render() instead.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
    get_ipv6_addr
29
29
)
30
30
 
31
 
TEMPLATES_DIR = 'templates'
32
 
 
33
 
try:
34
 
    import jinja2
35
 
except ImportError:
36
 
    apt_install(filter_installed_packages(['python-jinja2']),
37
 
                fatal=True)
38
 
    import jinja2
39
 
 
40
31
try:
41
32
    import dns.resolver
42
33
except ImportError:
45
36
    import dns.resolver
46
37
 
47
38
 
48
 
def render_template(template_name, context, template_dir=TEMPLATES_DIR):
49
 
    templates = jinja2.Environment(
50
 
        loader=jinja2.FileSystemLoader(template_dir))
51
 
    template = templates.get_template(template_name)
52
 
    return template.render(context)
53
 
 
54
 
 
55
39
def enable_pocket(pocket):
56
40
    apt_sources = "/etc/apt/sources.list"
57
41
    with open(apt_sources, "r") as sources: