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

Proposed by Junaid Ali
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 Approve
Review via email: mp+290238@code.launchpad.net
To post a comment you must log in.
Revision history for this message
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
=== modified file 'hooks/pg_gw_hooks.py'
--- hooks/pg_gw_hooks.py 2016-03-27 15:24:34 +0000
+++ hooks/pg_gw_hooks.py 2016-03-28 18:36:55 +0000
@@ -14,8 +14,6 @@
14 config,14 config,
15)15)
1616
17from charmhelpers.core.host import service_running
18
19from charmhelpers.fetch import (17from charmhelpers.fetch import (
20 apt_install,18 apt_install,
21 configure_sources,19 configure_sources,
@@ -24,7 +22,6 @@
24from pg_gw_utils import (22from pg_gw_utils import (
25 register_configs,23 register_configs,
26 ensure_files,24 ensure_files,
27 restart_pg,
28 restart_map,25 restart_map,
29 stop_pg,26 stop_pg,
30 determine_packages,27 determine_packages,
@@ -35,6 +32,7 @@
35 fabric_interface_changed,32 fabric_interface_changed,
36 load_iptables,33 load_iptables,
37 restart_on_change,34 restart_on_change,
35 restart_on_stop,
38 director_cluster_ready36 director_cluster_ready
39)37)
4038
@@ -71,6 +69,8 @@
7169
7270
73@hooks.hook('config-changed')71@hooks.hook('config-changed')
72@restart_on_stop()
73@restart_on_change(restart_map())
74def config_changed():74def config_changed():
75 '''75 '''
76 This hook is run when a config parameter is changed.76 This hook is run when a config parameter is changed.
@@ -83,10 +83,6 @@
83 if charm_config.changed('fabric-interfaces'):83 if charm_config.changed('fabric-interfaces'):
84 if not fabric_interface_changed():84 if not fabric_interface_changed():
85 log("Fabric interface already set")85 log("Fabric interface already set")
86 else:
87 stop_pg()
88 if charm_config.changed('external-interfaces'):
89 stop_pg()
90 if (charm_config.changed('install_sources') or86 if (charm_config.changed('install_sources') or
91 charm_config.changed('plumgrid-build') or87 charm_config.changed('plumgrid-build') or
92 charm_config.changed('install_keys') or88 charm_config.changed('install_keys') or
@@ -100,8 +96,6 @@
100 load_iovisor()96 load_iovisor()
101 ensure_mtu()97 ensure_mtu()
102 CONFIGS.write_all()98 CONFIGS.write_all()
103 if not service_running('plumgrid'):
104 restart_pg()
10599
106100
107@hooks.hook('upgrade-charm')101@hooks.hook('upgrade-charm')
108102
=== modified file 'hooks/pg_gw_utils.py'
--- hooks/pg_gw_utils.py 2016-03-27 15:24:34 +0000
+++ hooks/pg_gw_utils.py 2016-03-28 18:36:55 +0000
@@ -393,6 +393,19 @@
393 return True if dirs_count == 1 or dirs_count == 3 else False393 return True if dirs_count == 1 or dirs_count == 3 else False
394394
395395
396def restart_on_stop():
397 """
398 Starts plumgrid service if it is stopped
399 """
400 def wrap(f):
401 def wrapped_f(*args, **kwargs):
402 f(*args, **kwargs)
403 if not service_running('plumgrid'):
404 restart_pg()
405 return wrapped_f
406 return wrap
407
408
396def restart_on_change(restart_map):409def restart_on_change(restart_map):
397 """410 """
398 Restart services based on configuration files changing411 Restart services based on configuration files changing
@@ -403,6 +416,8 @@
403 f(*args, **kwargs)416 f(*args, **kwargs)
404 for path in restart_map:417 for path in restart_map:
405 if path_hash(path) != checksums[path]:418 if path_hash(path) != checksums[path]:
419 if path == PG_IFCS_CONF:
420 ensure_files()
406 restart_pg()421 restart_pg()
407 break422 break
408 return wrapped_f423 return wrapped_f
409424
=== modified file 'unit_tests/test_pg_gw_hooks.py'
--- unit_tests/test_pg_gw_hooks.py 2016-03-28 18:18:41 +0000
+++ unit_tests/test_pg_gw_hooks.py 2016-03-28 18:36:55 +0000
@@ -24,7 +24,6 @@
24 'configure_sources',24 'configure_sources',
25 'ensure_files',25 'ensure_files',
26 'stop_pg',26 'stop_pg',
27 'restart_pg',
28 'load_iovisor',27 'load_iovisor',
29 'ensure_mtu',28 'ensure_mtu',
30 'add_lcm_key',29 'add_lcm_key',

Subscribers

People subscribed via source and target branches