~james-page/charms/trusty/ceph/wily

« back to all changes in this revision

Viewing changes to hooks/utils.py

  • Committer: Liam Young
  • Date: 2015-01-13 14:01:45 UTC
  • mfrom: (92.1.2 ceph)
  • Revision ID: liam.young@canonical.com-20150113140145-xclhy82prhk7tn1l
[corey.bryant,r=gnuoy] This is just simplifying the code and using render() from charm-helpers instead of the roll-your-own render_template().

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: