~jshieh/charms/trusty/xcat/1428813

« back to all changes in this revision

Viewing changes to charms/trusty/gpfs/hooks/config-changed

  • Committer: Michael Chase-Salerno
  • Date: 2015-01-16 16:16:45 UTC
  • Revision ID: bratac@linux.vnet.ibm.com-20150116161645-wvh0sllwqgyilelw
Initial GPFS charm

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
 
 
3
import os
 
4
import sys
 
5
 
 
6
sys.path.insert(0, os.path.join(os.environ['CHARM_DIR'], 'lib'))
 
7
 
 
8
from charmhelpers.core import (
 
9
    hookenv,
 
10
    host,
 
11
)
 
12
 
 
13
from start import start
 
14
 
 
15
hooks = hookenv.Hooks()
 
16
log = hookenv.log
 
17
 
 
18
SERVICE = 'gpfs'
 
19
 
 
20
 
 
21
@hooks.hook('config-changed')
 
22
def config_changed():
 
23
    config = hookenv.config()
 
24
 
 
25
    for key in config:
 
26
        if config.changed(key):
 
27
            log("config['{}'] changed from {} to {}".format(
 
28
                key, config.previous(key), config[key]))
 
29
 
 
30
    config.save()
 
31
    start()
 
32
 
 
33
 
 
34
if __name__ == "__main__":
 
35
    # execute a hook based on the name the program is called by
 
36
    hooks.execute(sys.argv)