/usr/lib/python2.7/dist-packages/charmtools/templates/python/files/hooks/config-changed is in charm-tools 2.1.2-0ubuntu4.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | #!/usr/bin/python
import os
import sys
sys.path.insert(0, os.path.join(os.environ['CHARM_DIR'], 'lib'))
from charmhelpers.core import (
hookenv,
host,
)
from start import start
hooks = hookenv.Hooks()
log = hookenv.log
SERVICE = '$metadata.package'
@hooks.hook('config-changed')
def config_changed():
config = hookenv.config()
for key in config:
if config.changed(key):
log("config['{}'] changed from {} to {}".format(
key, config.previous(key), config[key]))
config.save()
start()
if __name__ == "__main__":
# execute a hook based on the name the program is called by
hooks.execute(sys.argv)
|