Trigger restarts on config updates

This commit is contained in:
Liam Young 2014-06-10 17:56:10 +00:00
parent 9b48491b62
commit 2440166014

View File

@ -8,6 +8,7 @@ from charmhelpers.core.hookenv import (
UnregisteredHookError,
log,
relation_set,
relation_ids,
)
from charmhelpers.core.host import (
@ -34,10 +35,11 @@ def install():
apt_update()
apt_install(determine_packages(), fatal=True)
@restart_on_change(restart_map())
@hooks.hook('config-changed')
@restart_on_change(restart_map())
def config_changed():
CONFIGS.write_all()
[neutron_plugin_relation_joined(rid) for rid in relation_ids('neutron-plugin')]
@hooks.hook('neutron-plugin-relation-joined')
def neutron_plugin_relation_joined(remote_restart=True):
@ -49,10 +51,17 @@ def neutron_plugin_relation_joined(remote_restart=True):
NEUTRON_SETTINGS['neutron'][conf]['sections']['COMMENT'].append(comment)
relation_set(subordinate_configuration=json.dumps(NEUTRON_SETTINGS))
@restart_on_change(restart_map())
@hooks.hook('neutron-plugin-relation-changed')
def neutron_plugin_relation_changed():
@restart_on_change(restart_map())
def neutron_plugin_relation_changed(remote_restart=True):
CONFIGS.write_all()
if remote_restart:
comment = ('restart', 'Restart Trigger: ' + str(uuid.uuid4()))
for conf in NEUTRON_SETTINGS['neutron']:
if 'sections' in NEUTRON_SETTINGS['neutron'][conf] and \
'COMMENT' in NEUTRON_SETTINGS['neutron'][conf]['sections']:
NEUTRON_SETTINGS['neutron'][conf]['sections']['COMMENT'].append(comment)
relation_set(subordinate_configuration=json.dumps(NEUTRON_SETTINGS))
def main():
try: