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: 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 Pending
Review via email: mp+291148@code.launchpad.net
To post a comment you must log in.
26. By Bilal Baqar

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
=== modified file 'hooks/pg_gw_hooks.py'
--- hooks/pg_gw_hooks.py 2016-03-28 14:19:54 +0000
+++ hooks/pg_gw_hooks.py 2016-04-06 19:05:29 +0000
@@ -6,12 +6,13 @@
6# in this file.6# in this file.
77
8import sys8import sys
99from charmhelpers.core.host import service_running
10from charmhelpers.core.hookenv import (10from charmhelpers.core.hookenv import (
11 Hooks,11 Hooks,
12 UnregisteredHookError,12 UnregisteredHookError,
13 log,13 log,
14 config,14 config,
15 status_set
15)16)
1617
17from charmhelpers.fetch import (18from charmhelpers.fetch import (
@@ -45,8 +46,10 @@
45 '''46 '''
46 Install hook is run when the charm is first deployed on a node.47 Install hook is run when the charm is first deployed on a node.
47 '''48 '''
49 status_set('maintenance', 'Executing pre-install')
48 load_iptables()50 load_iptables()
49 configure_sources(update=True)51 configure_sources(update=True)
52 status_set('maintenance', 'Installing apt packages')
50 pkgs = determine_packages()53 pkgs = determine_packages()
51 for pkg in pkgs:54 for pkg in pkgs:
52 apt_install(pkg, options=['--force-yes'], fatal=True)55 apt_install(pkg, options=['--force-yes'], fatal=True)
@@ -88,6 +91,7 @@
88 charm_config.changed('install_keys') or91 charm_config.changed('install_keys') or
89 charm_config.changed('iovisor-build')):92 charm_config.changed('iovisor-build')):
90 stop_pg()93 stop_pg()
94 status_set('maintenance', 'Upgrading apt packages')
91 configure_sources(update=True)95 configure_sources(update=True)
92 pkgs = determine_packages()96 pkgs = determine_packages()
93 for pkg in pkgs:97 for pkg in pkgs:
@@ -113,6 +117,14 @@
113 stop_pg()117 stop_pg()
114118
115119
120@hooks.hook('update-status')
121def update_status():
122 if service_running('plumgrid'):
123 status_set('active', 'Unit is ready')
124 else:
125 status_set('blocked', 'plumgrid service not running')
126
127
116def main():128def main():
117 try:129 try:
118 hooks.execute(sys.argv)130 hooks.execute(sys.argv)
119131
=== modified file 'hooks/pg_gw_utils.py'
--- hooks/pg_gw_utils.py 2016-03-28 18:35:55 +0000
+++ hooks/pg_gw_utils.py 2016-04-06 19:05:29 +0000
@@ -16,7 +16,8 @@
16from charmhelpers.core.hookenv import (16from charmhelpers.core.hookenv import (
17 log,17 log,
18 config,18 config,
19 unit_get19 unit_get,
20 status_set
20)21)
21from charmhelpers.contrib.network.ip import (22from charmhelpers.contrib.network.ip import (
22 get_iface_from_addr,23 get_iface_from_addr,
@@ -160,6 +161,7 @@
160 raise ValueError("plumgrid service couldn't be started")161 raise ValueError("plumgrid service couldn't be started")
161 else:162 else:
162 raise ValueError("libvirt-bin service couldn't be started")163 raise ValueError("libvirt-bin service couldn't be started")
164 status_set('active', 'Unit is ready')
163165
164166
165def stop_pg():167def stop_pg():
166168
=== added symlink 'hooks/update-status'
=== target is u'pg_gw_hooks.py'
=== modified file 'templates/kilo/00-pg.conf'
--- templates/kilo/00-pg.conf 2016-03-27 15:26:09 +0000
+++ templates/kilo/00-pg.conf 2016-04-06 19:05:29 +0000
@@ -1,1 +1,2 @@
1$template ls_json,"{{'{'}}{{'%'}}timestamp:::date-rfc3339,jsonf:@timestamp%,%source:::jsonf:@source_host%,%msg:::json%}":syslogtag,isequal,"pg:" @{{ opsvm_ip }}:6000;ls_json1$template ls_json,"{{'{'}}{{'%'}}timestamp:::date-rfc3339,jsonf:@timestamp%,%source:::jsonf:@source_host%,%msg:::json%}"
2:syslogtag,isequal,"pg:" @{{ opsvm_ip }}:6000;ls_json

Subscribers

People subscribed via source and target branches