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

Proposed by Junaid Ali on 2016-03-28
Status: Merged
Merged at revision: 25
Proposed branch: lp:~junaidali/charms/trusty/plumgrid-gateway/opsvm
Merge into: lp:~plumgrid-team/charms/trusty/plumgrid-gateway/trunk
Diff against target: 102 lines (+18/-10)
3 files modified
hooks/pg_gw_hooks.py (+3/-9)
hooks/pg_gw_utils.py (+15/-0)
unit_tests/test_pg_gw_hooks.py (+0/-1)
To merge this branch: bzr merge lp:~junaidali/charms/trusty/plumgrid-gateway/opsvm
Reviewer Review Type Date Requested Status
Bilal Baqar 2016-03-28 Approve on 2016-03-28
Review via email: mp+290238@code.launchpad.net
To post a comment you must log in.
Bilal Baqar (bbaqar) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/pg_gw_hooks.py'
2--- hooks/pg_gw_hooks.py 2016-03-27 15:24:34 +0000
3+++ hooks/pg_gw_hooks.py 2016-03-28 18:36:55 +0000
4@@ -14,8 +14,6 @@
5 config,
6 )
7
8-from charmhelpers.core.host import service_running
9-
10 from charmhelpers.fetch import (
11 apt_install,
12 configure_sources,
13@@ -24,7 +22,6 @@
14 from pg_gw_utils import (
15 register_configs,
16 ensure_files,
17- restart_pg,
18 restart_map,
19 stop_pg,
20 determine_packages,
21@@ -35,6 +32,7 @@
22 fabric_interface_changed,
23 load_iptables,
24 restart_on_change,
25+ restart_on_stop,
26 director_cluster_ready
27 )
28
29@@ -71,6 +69,8 @@
30
31
32 @hooks.hook('config-changed')
33+@restart_on_stop()
34+@restart_on_change(restart_map())
35 def config_changed():
36 '''
37 This hook is run when a config parameter is changed.
38@@ -83,10 +83,6 @@
39 if charm_config.changed('fabric-interfaces'):
40 if not fabric_interface_changed():
41 log("Fabric interface already set")
42- else:
43- stop_pg()
44- if charm_config.changed('external-interfaces'):
45- stop_pg()
46 if (charm_config.changed('install_sources') or
47 charm_config.changed('plumgrid-build') or
48 charm_config.changed('install_keys') or
49@@ -100,8 +96,6 @@
50 load_iovisor()
51 ensure_mtu()
52 CONFIGS.write_all()
53- if not service_running('plumgrid'):
54- restart_pg()
55
56
57 @hooks.hook('upgrade-charm')
58
59=== modified file 'hooks/pg_gw_utils.py'
60--- hooks/pg_gw_utils.py 2016-03-27 15:24:34 +0000
61+++ hooks/pg_gw_utils.py 2016-03-28 18:36:55 +0000
62@@ -393,6 +393,19 @@
63 return True if dirs_count == 1 or dirs_count == 3 else False
64
65
66+def restart_on_stop():
67+ """
68+ Starts plumgrid service if it is stopped
69+ """
70+ def wrap(f):
71+ def wrapped_f(*args, **kwargs):
72+ f(*args, **kwargs)
73+ if not service_running('plumgrid'):
74+ restart_pg()
75+ return wrapped_f
76+ return wrap
77+
78+
79 def restart_on_change(restart_map):
80 """
81 Restart services based on configuration files changing
82@@ -403,6 +416,8 @@
83 f(*args, **kwargs)
84 for path in restart_map:
85 if path_hash(path) != checksums[path]:
86+ if path == PG_IFCS_CONF:
87+ ensure_files()
88 restart_pg()
89 break
90 return wrapped_f
91
92=== modified file 'unit_tests/test_pg_gw_hooks.py'
93--- unit_tests/test_pg_gw_hooks.py 2016-03-28 18:18:41 +0000
94+++ unit_tests/test_pg_gw_hooks.py 2016-03-28 18:36:55 +0000
95@@ -24,7 +24,6 @@
96 'configure_sources',
97 'ensure_files',
98 'stop_pg',
99- 'restart_pg',
100 'load_iovisor',
101 'ensure_mtu',
102 'add_lcm_key',

Subscribers

People subscribed via source and target branches