summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunaid Ali <junaidali@plumgrid.com>2016-03-14 20:13:15 +0500
committerJunaid Ali <junaidali@plumgrid.com>2016-03-14 20:13:15 +0500
commitf8987ff8ca1cea34b386bdf01ebddf3bd73ddb7c (patch)
tree4a1a1d118b43df184d2cf53e3c86851f0aeed488
parentc4868ea75125efa2fd65fe4e840fe8a902d19a6d (diff)
Ensuring plumgrid services to restart on certain hooks, Updated restart_pg()
-rwxr-xr-xhooks/pg_gw_hooks.py33
-rw-r--r--hooks/pg_gw_utils.py9
2 files changed, 25 insertions, 17 deletions
diff --git a/hooks/pg_gw_hooks.py b/hooks/pg_gw_hooks.py
index 97ea9c6..7df9ba1 100755
--- a/hooks/pg_gw_hooks.py
+++ b/hooks/pg_gw_hooks.py
@@ -74,30 +74,31 @@ def config_changed():
74 This hook is run when a config parameter is changed. 74 This hook is run when a config parameter is changed.
75 It also runs on node reboot. 75 It also runs on node reboot.
76 ''' 76 '''
77 if add_lcm_key():
78 log("PLUMgrid LCM Key added")
79 return 1
80 charm_config = config() 77 charm_config = config()
78 if charm_config.changed('lcm-ssh-key'):
79 if add_lcm_key():
80 log("PLUMgrid LCM Key added")
81 if charm_config.changed('fabric-interfaces'): 81 if charm_config.changed('fabric-interfaces'):
82 if not fabric_interface_changed(): 82 if not fabric_interface_changed():
83 log("Fabric interface already set") 83 log("Fabric interface already set")
84 return 1 84 else:
85 restart_pg()
85 if charm_config.changed('os-data-network'): 86 if charm_config.changed('os-data-network'):
86 if charm_config['fabric-interfaces'] == 'MANAGEMENT': 87 if charm_config['fabric-interfaces'] == 'MANAGEMENT':
87 log('Fabric running on managment network') 88 log('Fabric running on managment network')
88 return 1 89 if (charm_config.changed('install_sources') or
89 stop_pg() 90 charm_config.changed('plumgrid-build') or
90 configure_sources(update=True) 91 charm_config.changed('plumgrid-virtual-ip') or
91 pkgs = determine_packages() 92 charm_config.changed('iovisor-build')):
92 for pkg in pkgs: 93 stop_pg()
93 apt_install(pkg, options=['--force-yes'], fatal=True) 94 configure_sources(update=True)
94 remove_iovisor() 95 pkgs = determine_packages()
95 load_iovisor() 96 for pkg in pkgs:
96 ensure_mtu() 97 apt_install(pkg, options=['--force-yes'], fatal=True)
97 ensure_files() 98 remove_iovisor()
98 add_lcm_key() 99 load_iovisor()
100 restart_pg()
99 CONFIGS.write_all() 101 CONFIGS.write_all()
100 restart_pg()
101 102
102 103
103@hooks.hook('upgrade-charm') 104@hooks.hook('upgrade-charm')
diff --git a/hooks/pg_gw_utils.py b/hooks/pg_gw_utils.py
index 186870f..3786485 100644
--- a/hooks/pg_gw_utils.py
+++ b/hooks/pg_gw_utils.py
@@ -141,7 +141,14 @@ def restart_pg():
141 Stops and Starts PLUMgrid service after flushing iptables. 141 Stops and Starts PLUMgrid service after flushing iptables.
142 ''' 142 '''
143 stop_pg() 143 stop_pg()
144 service_start('plumgrid') 144 if not service_start('plumgrid'):
145 if not service_start('libvirt-bin'):
146 raise ValueError("libvirt-bin service couldn't be started")
147 else:
148 # wait for 3 secs so that libvirt-bin can be completely up and
149 # start the plumgrid service
150 time.sleep(3)
151 service_start('plumgrid')
145 time.sleep(30) 152 time.sleep(30)
146 153
147 154