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

Proposed by Junaid Ali on 2016-04-06
Status: Merged
Merged at revision: 26
Proposed branch: lp:~junaidali/charms/trusty/plumgrid-gateway/trunk
Merge into: lp:~plumgrid-team/charms/trusty/plumgrid-gateway/trunk
Diff against target: 84 lines (+18/-3)
3 files modified
hooks/pg_gw_hooks.py (+13/-1)
hooks/pg_gw_utils.py (+3/-1)
templates/kilo/00-pg.conf (+2/-1)
To merge this branch: bzr merge lp:~junaidali/charms/trusty/plumgrid-gateway/trunk
Reviewer Review Type Date Requested Status
Bilal Baqar 2016-04-06 Pending
Review via email: mp+291148@code.launchpad.net
To post a comment you must log in.
26. By Bilal Baqar on 2016-04-08

Adding status messages in charms - Ticket:[SOL-949]

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-28 14:19:54 +0000
3+++ hooks/pg_gw_hooks.py 2016-04-06 19:05:29 +0000
4@@ -6,12 +6,13 @@
5 # in this file.
6
7 import sys
8-
9+from charmhelpers.core.host import service_running
10 from charmhelpers.core.hookenv import (
11 Hooks,
12 UnregisteredHookError,
13 log,
14 config,
15+ status_set
16 )
17
18 from charmhelpers.fetch import (
19@@ -45,8 +46,10 @@
20 '''
21 Install hook is run when the charm is first deployed on a node.
22 '''
23+ status_set('maintenance', 'Executing pre-install')
24 load_iptables()
25 configure_sources(update=True)
26+ status_set('maintenance', 'Installing apt packages')
27 pkgs = determine_packages()
28 for pkg in pkgs:
29 apt_install(pkg, options=['--force-yes'], fatal=True)
30@@ -88,6 +91,7 @@
31 charm_config.changed('install_keys') or
32 charm_config.changed('iovisor-build')):
33 stop_pg()
34+ status_set('maintenance', 'Upgrading apt packages')
35 configure_sources(update=True)
36 pkgs = determine_packages()
37 for pkg in pkgs:
38@@ -113,6 +117,14 @@
39 stop_pg()
40
41
42+@hooks.hook('update-status')
43+def update_status():
44+ if service_running('plumgrid'):
45+ status_set('active', 'Unit is ready')
46+ else:
47+ status_set('blocked', 'plumgrid service not running')
48+
49+
50 def main():
51 try:
52 hooks.execute(sys.argv)
53
54=== modified file 'hooks/pg_gw_utils.py'
55--- hooks/pg_gw_utils.py 2016-03-28 18:35:55 +0000
56+++ hooks/pg_gw_utils.py 2016-04-06 19:05:29 +0000
57@@ -16,7 +16,8 @@
58 from charmhelpers.core.hookenv import (
59 log,
60 config,
61- unit_get
62+ unit_get,
63+ status_set
64 )
65 from charmhelpers.contrib.network.ip import (
66 get_iface_from_addr,
67@@ -160,6 +161,7 @@
68 raise ValueError("plumgrid service couldn't be started")
69 else:
70 raise ValueError("libvirt-bin service couldn't be started")
71+ status_set('active', 'Unit is ready')
72
73
74 def stop_pg():
75
76=== added symlink 'hooks/update-status'
77=== target is u'pg_gw_hooks.py'
78=== modified file 'templates/kilo/00-pg.conf'
79--- templates/kilo/00-pg.conf 2016-03-27 15:26:09 +0000
80+++ templates/kilo/00-pg.conf 2016-04-06 19:05:29 +0000
81@@ -1,1 +1,2 @@
82-$template ls_json,"{{'{'}}{{'%'}}timestamp:::date-rfc3339,jsonf:@timestamp%,%source:::jsonf:@source_host%,%msg:::json%}":syslogtag,isequal,"pg:" @{{ opsvm_ip }}:6000;ls_json
83+$template ls_json,"{{'{'}}{{'%'}}timestamp:::date-rfc3339,jsonf:@timestamp%,%source:::jsonf:@source_host%,%msg:::json%}"
84+:syslogtag,isequal,"pg:" @{{ opsvm_ip }}:6000;ls_json

Subscribers

People subscribed via source and target branches