~niedbalski/charms/trusty/ceph-osd/sysctl-param

« back to all changes in this revision

Viewing changes to hooks/hooks.py

  • Committer: James Page
  • Date: 2013-11-18 12:17:59 UTC
  • mfrom: (15.1.3 ceph-osd)
  • Revision ID: james.page@canonical.com-20131118121759-son32zoatkaqp030
[james-page] Managed ceph.conf using alternatives

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
    related_units,
22
22
    relation_get,
23
23
    Hooks,
24
 
    UnregisteredHookError
 
24
    UnregisteredHookError,
 
25
    service_name
25
26
)
26
27
from charmhelpers.core.host import (
 
28
    umount,
 
29
    mkdir
 
30
)
 
31
from charmhelpers.fetch import (
 
32
    add_source,
27
33
    apt_install,
28
34
    apt_update,
29
35
    filter_installed_packages,
30
 
    umount
31
36
)
32
 
from charmhelpers.fetch import add_source
33
37
 
34
38
from utils import (
35
39
    render_template,
36
40
    get_host_ip,
37
41
)
38
42
 
 
43
from charmhelpers.contrib.openstack.alternatives import install_alternative
 
44
 
39
45
hooks = Hooks()
40
46
 
41
47
 
66
72
        'fsid': get_fsid(),
67
73
        'version': ceph.get_ceph_version()
68
74
    }
69
 
 
70
 
    with open('/etc/ceph/ceph.conf', 'w') as cephconf:
 
75
    # Install ceph.conf as an alternative to support
 
76
    # co-existence with other charms that write this file
 
77
    charm_ceph_conf = "/var/lib/charm/{}/ceph.conf".format(service_name())
 
78
    mkdir(os.path.dirname(charm_ceph_conf))
 
79
    with open(charm_ceph_conf, 'w') as cephconf:
71
80
        cephconf.write(render_template('ceph.conf', cephcontext))
 
81
    install_alternative('ceph.conf', '/etc/ceph/ceph.conf',
 
82
                        charm_ceph_conf, 90)
72
83
 
73
84
JOURNAL_ZAPPED = '/var/lib/ceph/journal_zapped'
74
85