Merged do_hooks changes from pjdc

This commit is contained in:
James Page 2012-10-08 13:19:37 +01:00
commit 3a85f25402
3 changed files with 23 additions and 19 deletions

View File

@ -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)

View File

@ -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):

View File

@ -1 +1 @@
67
69