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 @@ # in this file. import sys - +from charmhelpers.core.host import service_running from charmhelpers.core.hookenv import ( Hooks, UnregisteredHookError, log, config, + status_set ) from charmhelpers.fetch import ( @@ -45,8 +46,10 @@ def install(): ''' Install hook is run when the charm is first deployed on a node. ''' + status_set('maintenance', 'Executing pre-install') load_iptables() configure_sources(update=True) + status_set('maintenance', 'Installing apt packages') pkgs = determine_packages() for pkg in pkgs: apt_install(pkg, options=['--force-yes'], fatal=True) @@ -88,6 +91,7 @@ def config_changed(): charm_config.changed('install_keys') or charm_config.changed('iovisor-build')): stop_pg() + status_set('maintenance', 'Upgrading apt packages') configure_sources(update=True) pkgs = determine_packages() for pkg in pkgs: @@ -113,6 +117,14 @@ def stop(): stop_pg() +@hooks.hook('update-status') +def update_status(): + if service_running('plumgrid'): + status_set('active', 'Unit is ready') + else: + status_set('blocked', 'plumgrid service not running') + + def main(): try: 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 from charmhelpers.core.hookenv import ( log, config, - unit_get + unit_get, + status_set ) from charmhelpers.contrib.network.ip import ( get_iface_from_addr, @@ -160,6 +161,7 @@ def restart_pg(): raise ValueError("plumgrid service couldn't be started") else: raise ValueError("libvirt-bin service couldn't be started") + status_set('active', 'Unit is ready') def stop_pg(): 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 @@ -$template ls_json,"{{'{'}}{{'%'}}timestamp:::date-rfc3339,jsonf:@timestamp%,%source:::jsonf:@source_host%,%msg:::json%}":syslogtag,isequal,"pg:" @{{ opsvm_ip }}:6000;ls_json +$template ls_json,"{{'{'}}{{'%'}}timestamp:::date-rfc3339,jsonf:@timestamp%,%source:::jsonf:@source_host%,%msg:::json%}" +:syslogtag,isequal,"pg:" @{{ opsvm_ip }}:6000;ls_json