4
# Copyright 2015 Canonical Ltd.
7
# Liang Chen <liang.chen@ubuntu.com>
13
from charmhelpers.core.hookenv import (
15
Hooks, UnregisteredHookError,
19
from utils import render_template
24
def emit_lxc_br_conf():
26
if config('new-lxc-network'):
27
lxc_context['new_network'] = True
29
lxc_bridge_conf = "/etc/network/interfaces.d/lxcbr0.cfg"
30
with open(lxc_bridge_conf, 'w') as lxc_br_conf:
31
lxc_br_conf.write(render_template('lxc-bridge.conf', lxc_context))
34
@hooks.hook('config-changed')
37
cmd = ['ifup', 'lxcbr0']
38
subprocess.check_call(cmd)
41
if __name__ == '__main__':
43
hooks.execute(sys.argv)
44
except UnregisteredHookError as e:
45
log('Unknown hook {} - skipping.'.format(e))