restart_on_stop Ticket: [SOL-950]
- Added restart_on_stop decorator function which starts plumgrid service is it has been stopped in the function - Added restart_on_change to config-changed hook so that any config changes result in plugrid restart - ifc_list_gateway only removed when change in ifcs.conf
This commit is contained in:
commit
769e214bdf
|
@ -14,8 +14,6 @@ from charmhelpers.core.hookenv import (
|
||||||
config,
|
config,
|
||||||
)
|
)
|
||||||
|
|
||||||
from charmhelpers.core.host import service_running
|
|
||||||
|
|
||||||
from charmhelpers.fetch import (
|
from charmhelpers.fetch import (
|
||||||
apt_install,
|
apt_install,
|
||||||
configure_sources,
|
configure_sources,
|
||||||
|
@ -24,7 +22,6 @@ from charmhelpers.fetch import (
|
||||||
from pg_gw_utils import (
|
from pg_gw_utils import (
|
||||||
register_configs,
|
register_configs,
|
||||||
ensure_files,
|
ensure_files,
|
||||||
restart_pg,
|
|
||||||
restart_map,
|
restart_map,
|
||||||
stop_pg,
|
stop_pg,
|
||||||
determine_packages,
|
determine_packages,
|
||||||
|
@ -35,6 +32,7 @@ from pg_gw_utils import (
|
||||||
fabric_interface_changed,
|
fabric_interface_changed,
|
||||||
load_iptables,
|
load_iptables,
|
||||||
restart_on_change,
|
restart_on_change,
|
||||||
|
restart_on_stop,
|
||||||
director_cluster_ready
|
director_cluster_ready
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -71,6 +69,8 @@ def plumgrid_changed():
|
||||||
|
|
||||||
|
|
||||||
@hooks.hook('config-changed')
|
@hooks.hook('config-changed')
|
||||||
|
@restart_on_stop()
|
||||||
|
@restart_on_change(restart_map())
|
||||||
def config_changed():
|
def config_changed():
|
||||||
'''
|
'''
|
||||||
This hook is run when a config parameter is changed.
|
This hook is run when a config parameter is changed.
|
||||||
|
@ -83,10 +83,6 @@ def config_changed():
|
||||||
if charm_config.changed('fabric-interfaces'):
|
if charm_config.changed('fabric-interfaces'):
|
||||||
if not fabric_interface_changed():
|
if not fabric_interface_changed():
|
||||||
log("Fabric interface already set")
|
log("Fabric interface already set")
|
||||||
else:
|
|
||||||
stop_pg()
|
|
||||||
if charm_config.changed('external-interfaces'):
|
|
||||||
stop_pg()
|
|
||||||
if (charm_config.changed('install_sources') or
|
if (charm_config.changed('install_sources') or
|
||||||
charm_config.changed('plumgrid-build') or
|
charm_config.changed('plumgrid-build') or
|
||||||
charm_config.changed('install_keys') or
|
charm_config.changed('install_keys') or
|
||||||
|
@ -100,8 +96,6 @@ def config_changed():
|
||||||
load_iovisor()
|
load_iovisor()
|
||||||
ensure_mtu()
|
ensure_mtu()
|
||||||
CONFIGS.write_all()
|
CONFIGS.write_all()
|
||||||
if not service_running('plumgrid'):
|
|
||||||
restart_pg()
|
|
||||||
|
|
||||||
|
|
||||||
@hooks.hook('upgrade-charm')
|
@hooks.hook('upgrade-charm')
|
||||||
|
|
|
@ -393,6 +393,19 @@ def director_cluster_ready():
|
||||||
return True if dirs_count == 1 or dirs_count == 3 else False
|
return True if dirs_count == 1 or dirs_count == 3 else False
|
||||||
|
|
||||||
|
|
||||||
|
def restart_on_stop():
|
||||||
|
"""
|
||||||
|
Starts plumgrid service if it is stopped
|
||||||
|
"""
|
||||||
|
def wrap(f):
|
||||||
|
def wrapped_f(*args, **kwargs):
|
||||||
|
f(*args, **kwargs)
|
||||||
|
if not service_running('plumgrid'):
|
||||||
|
restart_pg()
|
||||||
|
return wrapped_f
|
||||||
|
return wrap
|
||||||
|
|
||||||
|
|
||||||
def restart_on_change(restart_map):
|
def restart_on_change(restart_map):
|
||||||
"""
|
"""
|
||||||
Restart services based on configuration files changing
|
Restart services based on configuration files changing
|
||||||
|
@ -403,6 +416,8 @@ def restart_on_change(restart_map):
|
||||||
f(*args, **kwargs)
|
f(*args, **kwargs)
|
||||||
for path in restart_map:
|
for path in restart_map:
|
||||||
if path_hash(path) != checksums[path]:
|
if path_hash(path) != checksums[path]:
|
||||||
|
if path == PG_IFCS_CONF:
|
||||||
|
ensure_files()
|
||||||
restart_pg()
|
restart_pg()
|
||||||
break
|
break
|
||||||
return wrapped_f
|
return wrapped_f
|
||||||
|
|
|
@ -24,7 +24,6 @@ TO_PATCH = [
|
||||||
'configure_sources',
|
'configure_sources',
|
||||||
'ensure_files',
|
'ensure_files',
|
||||||
'stop_pg',
|
'stop_pg',
|
||||||
'restart_pg',
|
|
||||||
'load_iovisor',
|
'load_iovisor',
|
||||||
'ensure_mtu',
|
'ensure_mtu',
|
||||||
'add_lcm_key',
|
'add_lcm_key',
|
||||||
|
|
Loading…
Reference in New Issue