Merged do_hooks changes from pjdc
This commit is contained in:
commit
3a85f25402
@ -170,21 +170,13 @@ def start():
|
||||
'--subsystem-match=block', '--action=add'])
|
||||
|
||||
|
||||
hooks = {
|
||||
'config-changed': config_changed,
|
||||
'install': install,
|
||||
'mon-relation-departed': mon_relation,
|
||||
'mon-relation-joined': mon_relation,
|
||||
'start': start,
|
||||
'upgrade-charm': upgrade_charm,
|
||||
}
|
||||
|
||||
hook = os.path.basename(sys.argv[0])
|
||||
|
||||
try:
|
||||
hooks[hook]()
|
||||
except KeyError:
|
||||
utils.juju_log('INFO',
|
||||
"This charm doesn't know how to handle '{}'.".format(hook))
|
||||
utils.do_hooks({
|
||||
'config-changed': config_changed,
|
||||
'install': install,
|
||||
'mon-relation-departed': mon_relation,
|
||||
'mon-relation-joined': mon_relation,
|
||||
'start': start,
|
||||
'upgrade-charm': upgrade_charm,
|
||||
})
|
||||
|
||||
sys.exit(0)
|
||||
|
@ -3,12 +3,24 @@
|
||||
# Copyright 2012 Canonical Ltd.
|
||||
#
|
||||
# Authors:
|
||||
# James Page <james.page@canonical.com>
|
||||
#
|
||||
# James Page <james.page@ubuntu.com>
|
||||
# Paul Collins <paul.collins@canonical.com>
|
||||
#
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import socket
|
||||
import sys
|
||||
|
||||
|
||||
def do_hooks(hooks):
|
||||
hook = os.path.basename(sys.argv[0])
|
||||
|
||||
try:
|
||||
hooks[hook]()
|
||||
except KeyError:
|
||||
utils.juju_log('INFO',
|
||||
"This charm doesn't know how to handle '{}'.".format(hook))
|
||||
|
||||
|
||||
def install(*pkgs):
|
||||
|
Loading…
Reference in New Issue
Block a user