summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBilal Baqar <bbaqar@plumgrid.com>2016-04-08 01:35:38 -0700
committerBilal Baqar <bbaqar@plumgrid.com>2016-04-08 01:35:38 -0700
commitc9cefc745c79c975f205712cc9752a98d532615e (patch)
tree0b3ff04fc056119f2e08e1349c8fca497405da4a
parent769e214bdf5cfe0efc93dc4e29c54037661e1f1d (diff)
parent95868fa97bfd31f00c0815d8684a7c8546cf4435 (diff)
Adding status messages in charms - Ticket:[SOL-949]
-rwxr-xr-xhooks/pg_gw_hooks.py14
-rw-r--r--hooks/pg_gw_utils.py4
l---------hooks/update-status1
-rw-r--r--templates/kilo/00-pg.conf3
4 files changed, 19 insertions, 3 deletions
diff --git a/hooks/pg_gw_hooks.py b/hooks/pg_gw_hooks.py
index 1d3f87d..4ccb4b6 100755
--- a/hooks/pg_gw_hooks.py
+++ b/hooks/pg_gw_hooks.py
@@ -6,12 +6,13 @@
6# in this file. 6# in this file.
7 7
8import sys 8import sys
9 9from 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)
16 17
17from charmhelpers.fetch import ( 18from charmhelpers.fetch import (
@@ -45,8 +46,10 @@ def install():
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 @@ def config_changed():
88 charm_config.changed('install_keys') or 91 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 @@ def stop():
113 stop_pg() 117 stop_pg()
114 118
115 119
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)
diff --git a/hooks/pg_gw_utils.py b/hooks/pg_gw_utils.py
index b4e2f98..57a9632 100644
--- a/hooks/pg_gw_utils.py
+++ b/hooks/pg_gw_utils.py
@@ -16,7 +16,8 @@ from charmhelpers.contrib.openstack import templating
16from charmhelpers.core.hookenv import ( 16from charmhelpers.core.hookenv import (
17 log, 17 log,
18 config, 18 config,
19 unit_get 19 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 @@ def restart_pg():
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')
163 165
164 166
165def stop_pg(): 167def stop_pg():
diff --git a/hooks/update-status b/hooks/update-status
new file mode 120000
index 0000000..3aec9ba
--- /dev/null
+++ b/hooks/update-status
@@ -0,0 +1 @@
pg_gw_hooks.py \ No newline at end of file
diff --git a/templates/kilo/00-pg.conf b/templates/kilo/00-pg.conf
index c5a6016..e744a27 100644
--- a/templates/kilo/00-pg.conf
+++ b/templates/kilo/00-pg.conf
@@ -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_json 1$template ls_json,"{{'{'}}{{'%'}}timestamp:::date-rfc3339,jsonf:@timestamp%,%source:::jsonf:@source_host%,%msg:::json%}"
2:syslogtag,isequal,"pg:" @{{ opsvm_ip }}:6000;ls_json