Adding status messages in charms - Ticket:[SOL-949]
This commit is contained in:
commit
1cb0e47ca7
@ -16,7 +16,8 @@ from charmhelpers.core.hookenv import (
|
|||||||
log,
|
log,
|
||||||
config,
|
config,
|
||||||
relation_set,
|
relation_set,
|
||||||
relation_ids
|
relation_ids,
|
||||||
|
status_set
|
||||||
)
|
)
|
||||||
|
|
||||||
from charmhelpers.fetch import (
|
from charmhelpers.fetch import (
|
||||||
@ -50,8 +51,10 @@ def install():
|
|||||||
'''
|
'''
|
||||||
Install hook is run when the charm is first deployed on a node.
|
Install hook is run when the charm is first deployed on a node.
|
||||||
'''
|
'''
|
||||||
|
status_set('maintenance', 'Executing pre-install')
|
||||||
load_iptables()
|
load_iptables()
|
||||||
configure_sources(update=True)
|
configure_sources(update=True)
|
||||||
|
status_set('maintenance', 'Installing apt packages')
|
||||||
pkgs = determine_packages()
|
pkgs = determine_packages()
|
||||||
for pkg in pkgs:
|
for pkg in pkgs:
|
||||||
apt_install(pkg, options=['--force-yes'], fatal=True)
|
apt_install(pkg, options=['--force-yes'], fatal=True)
|
||||||
@ -108,6 +111,7 @@ def config_changed():
|
|||||||
charm_config.changed('plumgrid-build') or
|
charm_config.changed('plumgrid-build') or
|
||||||
charm_config.changed('install_keys') or
|
charm_config.changed('install_keys') or
|
||||||
charm_config.changed('iovisor-build')):
|
charm_config.changed('iovisor-build')):
|
||||||
|
status_set('maintenance', 'Upgrading apt packages')
|
||||||
stop_pg()
|
stop_pg()
|
||||||
configure_sources(update=True)
|
configure_sources(update=True)
|
||||||
pkgs = determine_packages()
|
pkgs = determine_packages()
|
||||||
@ -157,6 +161,14 @@ def stop():
|
|||||||
stop_pg()
|
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():
|
def main():
|
||||||
try:
|
try:
|
||||||
hooks.execute(sys.argv)
|
hooks.execute(sys.argv)
|
||||||
|
@ -17,6 +17,7 @@ from charmhelpers.core.hookenv import (
|
|||||||
log,
|
log,
|
||||||
config,
|
config,
|
||||||
unit_get,
|
unit_get,
|
||||||
|
status_set
|
||||||
)
|
)
|
||||||
from charmhelpers.contrib.network.ip import (
|
from charmhelpers.contrib.network.ip import (
|
||||||
get_iface_from_addr,
|
get_iface_from_addr,
|
||||||
@ -160,6 +161,7 @@ def restart_pg():
|
|||||||
raise ValueError("plumgrid service couldn't be started")
|
raise ValueError("plumgrid service couldn't be started")
|
||||||
else:
|
else:
|
||||||
raise ValueError("libvirt-bin service couldn't be started")
|
raise ValueError("libvirt-bin service couldn't be started")
|
||||||
|
status_set('active', 'Unit is ready')
|
||||||
|
|
||||||
|
|
||||||
def stop_pg():
|
def stop_pg():
|
||||||
|
1
hooks/update-status
Symbolic link
1
hooks/update-status
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
pg_dir_hooks.py
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user