Ensuring plumgrid services to restart on certain hooks, Updated restart_pg()

This commit is contained in:
Junaid Ali 2016-03-14 20:13:15 +05:00
parent c4868ea751
commit f8987ff8ca
2 changed files with 25 additions and 17 deletions

View File

@ -74,18 +74,22 @@ def config_changed():
This hook is run when a config parameter is changed. This hook is run when a config parameter is changed.
It also runs on node reboot. It also runs on node reboot.
''' '''
charm_config = config()
if charm_config.changed('lcm-ssh-key'):
if add_lcm_key(): if add_lcm_key():
log("PLUMgrid LCM Key added") log("PLUMgrid LCM Key added")
return 1
charm_config = config()
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")
return 1 else:
restart_pg()
if charm_config.changed('os-data-network'): if charm_config.changed('os-data-network'):
if charm_config['fabric-interfaces'] == 'MANAGEMENT': if charm_config['fabric-interfaces'] == 'MANAGEMENT':
log('Fabric running on managment network') log('Fabric running on managment network')
return 1 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() stop_pg()
configure_sources(update=True) configure_sources(update=True)
pkgs = determine_packages() pkgs = determine_packages()
@ -93,11 +97,8 @@ def config_changed():
apt_install(pkg, options=['--force-yes'], fatal=True) apt_install(pkg, options=['--force-yes'], fatal=True)
remove_iovisor() remove_iovisor()
load_iovisor() load_iovisor()
ensure_mtu()
ensure_files()
add_lcm_key()
CONFIGS.write_all()
restart_pg() restart_pg()
CONFIGS.write_all()
@hooks.hook('upgrade-charm') @hooks.hook('upgrade-charm')

View File

@ -141,6 +141,13 @@ def restart_pg():
Stops and Starts PLUMgrid service after flushing iptables. Stops and Starts PLUMgrid service after flushing iptables.
''' '''
stop_pg() stop_pg()
if not service_start('plumgrid'):
if not service_start('libvirt-bin'):
raise ValueError("libvirt-bin 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)
service_start('plumgrid') service_start('plumgrid')
time.sleep(30) time.sleep(30)