Merge lp:~junaidali/charms/trusty/plumgrid-gateway/trunk into lp:~plumgrid-team/charms/trusty/plumgrid-gateway/trunk

Proposed by Junaid Ali
Status: Merged
Merged at revision: 23
Proposed branch: lp:~junaidali/charms/trusty/plumgrid-gateway/trunk
Merge into: lp:~plumgrid-team/charms/trusty/plumgrid-gateway/trunk
Diff against target: 109 lines (+34/-24)
3 files modified
hooks/pg_gw_hooks.py (+22/-19)
hooks/pg_gw_utils.py (+12/-1)
unit_tests/test_pg_gw_hooks.py (+0/-4)
To merge this branch: bzr merge lp:~junaidali/charms/trusty/plumgrid-gateway/trunk
Reviewer Review Type Date Requested Status
Bilal Baqar Approve
Hassaan Pasha Pending
Review via email: mp+288939@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Bilal Baqar (bbaqar) :
review: Approve
23. By Bilal Baqar

Improved config-changed hook to perform steps according to the config changed

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'hooks/pg_gw_hooks.py'
--- hooks/pg_gw_hooks.py 2016-03-14 04:18:03 +0000
+++ hooks/pg_gw_hooks.py 2016-03-25 16:51:08 +0000
@@ -14,6 +14,8 @@
14 config,14 config,
15)15)
1616
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,
@@ -74,30 +76,31 @@
74 This hook is run when a config parameter is changed.76 This hook is run when a config parameter is changed.
75 It also runs on node reboot.77 It also runs on node reboot.
76 '''78 '''
77 if add_lcm_key():
78 log("PLUMgrid LCM Key added")
79 return 1
80 charm_config = config()79 charm_config = config()
80 if charm_config.changed('lcm-ssh-key'):
81 if add_lcm_key():
82 log("PLUMgrid LCM Key added")
81 if charm_config.changed('fabric-interfaces'):83 if charm_config.changed('fabric-interfaces'):
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 return 186 else:
85 if charm_config.changed('os-data-network'):87 stop_pg()
86 if charm_config['fabric-interfaces'] == 'MANAGEMENT':88 if charm_config.changed('external-interfaces'):
87 log('Fabric running on managment network')89 stop_pg()
88 return 190 if (charm_config.changed('install_sources') or
89 stop_pg()91 charm_config.changed('plumgrid-build') or
90 configure_sources(update=True)92 charm_config.changed('install_keys') or
91 pkgs = determine_packages()93 charm_config.changed('iovisor-build')):
92 for pkg in pkgs:94 stop_pg()
93 apt_install(pkg, options=['--force-yes'], fatal=True)95 configure_sources(update=True)
94 remove_iovisor()96 pkgs = determine_packages()
95 load_iovisor()97 for pkg in pkgs:
96 ensure_mtu()98 apt_install(pkg, options=['--force-yes'], fatal=True)
97 ensure_files()99 remove_iovisor()
98 add_lcm_key()100 load_iovisor()
99 CONFIGS.write_all()101 CONFIGS.write_all()
100 restart_pg()102 if not service_running('plumgrid'):
103 restart_pg()
101104
102105
103@hooks.hook('upgrade-charm')106@hooks.hook('upgrade-charm')
104107
=== modified file 'hooks/pg_gw_utils.py'
--- hooks/pg_gw_utils.py 2016-03-13 02:08:48 +0000
+++ hooks/pg_gw_utils.py 2016-03-25 16:51:08 +0000
@@ -30,6 +30,7 @@
30 write_file,30 write_file,
31 service_start,31 service_start,
32 service_stop,32 service_stop,
33 service_running
33)34)
34from charmhelpers.fetch import (35from charmhelpers.fetch import (
35 apt_cache,36 apt_cache,
@@ -142,7 +143,17 @@
142 '''143 '''
143 stop_pg()144 stop_pg()
144 service_start('plumgrid')145 service_start('plumgrid')
145 time.sleep(30)146 time.sleep(3)
147 if not service_running('plumgrid'):
148 if service_running('libvirt-bin'):
149 raise ValueError("plumgrid service couldn't be started")
150 else:
151 if service_start('libvirt-bin'):
152 time.sleep(3)
153 if not service_running('plumgrid'):
154 raise ValueError("plumgrid service couldn't be started")
155 else:
156 raise ValueError("libvirt-bin service couldn't be started")
146157
147158
148def stop_pg():159def stop_pg():
149160
=== modified file 'unit_tests/test_pg_gw_hooks.py'
--- unit_tests/test_pg_gw_hooks.py 2016-03-10 22:39:19 +0000
+++ unit_tests/test_pg_gw_hooks.py 2016-03-25 16:51:08 +0000
@@ -70,10 +70,6 @@
70 self.CONFIGS.write_all.assert_called_with()70 self.CONFIGS.write_all.assert_called_with()
71 self.restart_pg.assert_called_with()71 self.restart_pg.assert_called_with()
7272
73 def test_config_changed_hook(self):
74 self.add_lcm_key.return_value = 1
75 self._call_hook('config-changed')
76
77 def test_stop(self):73 def test_stop(self):
78 _pkgs = ['plumgrid-lxc', 'iovisor-dkms']74 _pkgs = ['plumgrid-lxc', 'iovisor-dkms']
79 self._call_hook('stop')75 self._call_hook('stop')

Subscribers

People subscribed via source and target branches