summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunaid Ali <junaidali@plumgrid.com>2016-03-16 07:13:44 +0500
committerJunaid Ali <junaidali@plumgrid.com>2016-03-16 07:13:44 +0500
commit2e99af93876bcc669b15ee1f20a3118a3948705f (patch)
tree6d40a7b4b7a0d30eb1ea5d5d6729c5151ec11e87
parentf8987ff8ca1cea34b386bdf01ebddf3bd73ddb7c (diff)
Updated config-changed hook and restart_pg()
-rwxr-xr-xhooks/pg_gw_hooks.py10
-rw-r--r--hooks/pg_gw_utils.py3
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 (
14 config, 14 config,
15) 15)
16 16
17from charmhelpers.core.host import service_running
18
17from charmhelpers.fetch import ( 19from charmhelpers.fetch import (
18 apt_install, 20 apt_install,
19 apt_purge, 21 apt_purge,
@@ -82,13 +84,12 @@ def config_changed():
82 if not fabric_interface_changed(): 84 if not fabric_interface_changed():
83 log("Fabric interface already set") 85 log("Fabric interface already set")
84 else: 86 else:
85 restart_pg() 87 stop_pg()
86 if charm_config.changed('os-data-network'): 88 if charm_config.changed('os-data-network'):
87 if charm_config['fabric-interfaces'] == 'MANAGEMENT': 89 if charm_config['fabric-interfaces'] == 'MANAGEMENT':
88 log('Fabric running on managment network') 90 log('Fabric running on managment network')
89 if (charm_config.changed('install_sources') or 91 if (charm_config.changed('install_sources') or
90 charm_config.changed('plumgrid-build') or 92 charm_config.changed('plumgrid-build') or
91 charm_config.changed('plumgrid-virtual-ip') or
92 charm_config.changed('iovisor-build')): 93 charm_config.changed('iovisor-build')):
93 stop_pg() 94 stop_pg()
94 configure_sources(update=True) 95 configure_sources(update=True)
@@ -97,8 +98,11 @@ def config_changed():
97 apt_install(pkg, options=['--force-yes'], fatal=True) 98 apt_install(pkg, options=['--force-yes'], fatal=True)
98 remove_iovisor() 99 remove_iovisor()
99 load_iovisor() 100 load_iovisor()
100 restart_pg()
101 CONFIGS.write_all() 101 CONFIGS.write_all()
102 # Restarting the plumgrid service only if it is
103 # already stopped by any config-parameters or node reboot
104 if not service_running('plumgrid'):
105 restart_pg()
102 106
103 107
104@hooks.hook('upgrade-charm') 108@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():
148 # wait for 3 secs so that libvirt-bin can be completely up and 148 # wait for 3 secs so that libvirt-bin can be completely up and
149 # start the plumgrid service 149 # start the plumgrid service
150 time.sleep(3) 150 time.sleep(3)
151 service_start('plumgrid') 151 if not service_start('plumgrid'):
152 raise ValueError("plumgrid service couldn't be started")
152 time.sleep(30) 153 time.sleep(30)
153 154
154 155