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

Proposed by Junaid Ali
Status: Needs review
Proposed branch: lp:~junaidali/charms/trusty/plumgrid-gateway/opsvm
Merge into: lp:~bbaqar/charms/trusty/plumgrid-gateway/opsvm
Diff against target: 108 lines (+18/-11)
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/-2)
To merge this branch: bzr merge lp:~junaidali/charms/trusty/plumgrid-gateway/opsvm
Reviewer Review Type Date Requested Status
Bilal Baqar Needs Fixing
Hassaan Pasha Pending
Review via email: mp+290201@code.launchpad.net
To post a comment you must log in.
27. By Junaid Ali

fixing unit_test

Revision history for this message
Bilal Baqar (bbaqar) :
review: Needs Fixing
28. By Junaid Ali

Updated function description

29. By Junaid Ali

Updated function description

Unmerged revisions

29. By Junaid Ali

Updated function description

28. By Junaid Ali

Updated function description

27. By Junaid Ali

fixing unit_test

26. By Junaid Ali

Improved plumgrid service restarts

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:13 +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:13 +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-27 15:24:34 +0000
94+++ unit_tests/test_pg_gw_hooks.py 2016-03-28 18:36:13 +0000
95@@ -19,13 +19,11 @@
96 TO_PATCH = [
97 'remove_iovisor',
98 'apt_install',
99- 'apt_purge',
100 'CONFIGS',
101 'log',
102 'configure_sources',
103 'ensure_files',
104 'stop_pg',
105- 'restart_pg',
106 'load_iovisor',
107 'ensure_mtu',
108 'add_lcm_key',

Subscribers

People subscribed via source and target branches

to all changes: