Drop render_template() and use charm-helpers render() instead.
This commit is contained in:
parent
d0ae009d2f
commit
1589199922
|
@ -46,9 +46,9 @@ from charmhelpers.contrib.network.ip import (
|
||||||
format_ipv6_addr
|
format_ipv6_addr
|
||||||
)
|
)
|
||||||
from charmhelpers.core.sysctl import create as create_sysctl
|
from charmhelpers.core.sysctl import create as create_sysctl
|
||||||
|
from charmhelpers.core.templating import render
|
||||||
|
|
||||||
from utils import (
|
from utils import (
|
||||||
render_template,
|
|
||||||
get_public_addr,
|
get_public_addr,
|
||||||
assert_charm_supports_ipv6
|
assert_charm_supports_ipv6
|
||||||
)
|
)
|
||||||
|
@ -98,8 +98,7 @@ def emit_cephconf():
|
||||||
# co-existence with other charms that write this file
|
# co-existence with other charms that write this file
|
||||||
charm_ceph_conf = "/var/lib/charm/{}/ceph.conf".format(service_name())
|
charm_ceph_conf = "/var/lib/charm/{}/ceph.conf".format(service_name())
|
||||||
mkdir(os.path.dirname(charm_ceph_conf))
|
mkdir(os.path.dirname(charm_ceph_conf))
|
||||||
with open(charm_ceph_conf, 'w') as cephconf:
|
render('ceph.conf', charm_ceph_conf, cephcontext, perms=0o644)
|
||||||
cephconf.write(render_template('ceph.conf', cephcontext))
|
|
||||||
install_alternative('ceph.conf', '/etc/ceph/ceph.conf',
|
install_alternative('ceph.conf', '/etc/ceph/ceph.conf',
|
||||||
charm_ceph_conf, 100)
|
charm_ceph_conf, 100)
|
||||||
|
|
||||||
|
|
|
@ -28,15 +28,6 @@ from charmhelpers.contrib.network.ip import (
|
||||||
get_ipv6_addr
|
get_ipv6_addr
|
||||||
)
|
)
|
||||||
|
|
||||||
TEMPLATES_DIR = 'templates'
|
|
||||||
|
|
||||||
try:
|
|
||||||
import jinja2
|
|
||||||
except ImportError:
|
|
||||||
apt_install(filter_installed_packages(['python-jinja2']),
|
|
||||||
fatal=True)
|
|
||||||
import jinja2
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import dns.resolver
|
import dns.resolver
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -45,13 +36,6 @@ except ImportError:
|
||||||
import dns.resolver
|
import dns.resolver
|
||||||
|
|
||||||
|
|
||||||
def render_template(template_name, context, template_dir=TEMPLATES_DIR):
|
|
||||||
templates = jinja2.Environment(
|
|
||||||
loader=jinja2.FileSystemLoader(template_dir))
|
|
||||||
template = templates.get_template(template_name)
|
|
||||||
return template.render(context)
|
|
||||||
|
|
||||||
|
|
||||||
def enable_pocket(pocket):
|
def enable_pocket(pocket):
|
||||||
apt_sources = "/etc/apt/sources.list"
|
apt_sources = "/etc/apt/sources.list"
|
||||||
with open(apt_sources, "r") as sources:
|
with open(apt_sources, "r") as sources:
|
||||||
|
|
Loading…
Reference in New Issue