diff --git a/hooks/pg_gw_hooks.py b/hooks/pg_gw_hooks.py index 5e3b1cc..4ff5abc 100755 --- a/hooks/pg_gw_hooks.py +++ b/hooks/pg_gw_hooks.py @@ -85,11 +85,9 @@ def config_changed(): log("Fabric interface already set") else: 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('install_keys') or charm_config.changed('iovisor-build')): stop_pg() configure_sources(update=True) @@ -99,8 +97,6 @@ def config_changed(): remove_iovisor() load_iovisor() 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() diff --git a/hooks/pg_gw_utils.py b/hooks/pg_gw_utils.py index 9ca5bdb..1830f12 100644 --- a/hooks/pg_gw_utils.py +++ b/hooks/pg_gw_utils.py @@ -30,6 +30,7 @@ from charmhelpers.core.host import ( write_file, service_start, service_stop, + service_running ) from charmhelpers.fetch import ( apt_cache, @@ -141,16 +142,18 @@ def restart_pg(): Stops and Starts PLUMgrid service after flushing iptables. ''' stop_pg() - if not service_start('plumgrid'): - if not service_start('libvirt-bin'): - raise ValueError("libvirt-bin service couldn't be started") + service_start('plumgrid') + time.sleep(3) + if not service_running('plumgrid'): + if service_running('libvirt-bin'): + raise ValueError("plumgrid service couldn't be started") else: - # wait for 3 secs so that libvirt-bin can be completely up and - # start the plumgrid service - time.sleep(3) - if not service_start('plumgrid'): - raise ValueError("plumgrid service couldn't be started") - time.sleep(30) + if service_start('libvirt-bin'): + time.sleep(3) + if not service_running('plumgrid'): + raise ValueError("plumgrid service couldn't be started") + else: + raise ValueError("libvirt-bin service couldn't be started") def stop_pg():