From 2e99af93876bcc669b15ee1f20a3118a3948705f Mon Sep 17 00:00:00 2001 From: Junaid Ali Date: Wed, 16 Mar 2016 07:13:44 +0500 Subject: [PATCH] Updated config-changed hook and restart_pg() --- hooks/pg_gw_hooks.py | 10 +++++++--- hooks/pg_gw_utils.py | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/hooks/pg_gw_hooks.py b/hooks/pg_gw_hooks.py index 7df9ba1..5e3b1cc 100755 --- a/hooks/pg_gw_hooks.py +++ b/hooks/pg_gw_hooks.py @@ -14,6 +14,8 @@ from charmhelpers.core.hookenv import ( config, ) +from charmhelpers.core.host import service_running + from charmhelpers.fetch import ( apt_install, apt_purge, @@ -82,13 +84,12 @@ def config_changed(): if not fabric_interface_changed(): log("Fabric interface already set") else: - restart_pg() + stop_pg() if charm_config.changed('os-data-network'): if charm_config['fabric-interfaces'] == 'MANAGEMENT': log('Fabric running on managment network') if (charm_config.changed('install_sources') or charm_config.changed('plumgrid-build') or - charm_config.changed('plumgrid-virtual-ip') or charm_config.changed('iovisor-build')): stop_pg() configure_sources(update=True) @@ -97,8 +98,11 @@ def config_changed(): apt_install(pkg, options=['--force-yes'], fatal=True) remove_iovisor() load_iovisor() - restart_pg() CONFIGS.write_all() + # Restarting the plumgrid service only if it is + # already stopped by any config-parameters or node reboot + if not service_running('plumgrid'): + restart_pg() @hooks.hook('upgrade-charm') diff --git a/hooks/pg_gw_utils.py b/hooks/pg_gw_utils.py index 3786485..9ca5bdb 100644 --- a/hooks/pg_gw_utils.py +++ b/hooks/pg_gw_utils.py @@ -148,7 +148,8 @@ def restart_pg(): # wait for 3 secs so that libvirt-bin can be completely up and # start the plumgrid service time.sleep(3) - service_start('plumgrid') + if not service_start('plumgrid'): + raise ValueError("plumgrid service couldn't be started") time.sleep(30)