~tribaal/charms/raring/ceph/add-python-ceph-charm

« back to all changes in this revision

Viewing changes to hooks/hooks.py

  • Committer: James Page
  • Date: 2012-12-17 10:22:51 UTC
  • Revision ID: james.page@canonical.com-20121217102251-xps6cjcygkzxnohf
Updates for latest ceph upstream and utils refactor

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
 
21
21
def install_upstart_scripts():
22
 
    for x in glob.glob('files/upstart/*.conf'):
23
 
        shutil.copy(x, '/etc/init/')
 
22
    # Only install upstart configurations for older versions
 
23
    if ceph.version_compare(ceph.get_ceph_version(),
 
24
                            "0.55.1") < 0:
 
25
        for x in glob.glob('files/upstart/*.conf'):
 
26
            shutil.copy(x, '/etc/init/')
24
27
 
25
28
 
26
29
def install():
36
39
        'auth_supported': utils.config_get('auth-supported'),
37
40
        'mon_hosts': ' '.join(get_mon_hosts()),
38
41
        'fsid': utils.config_get('fsid'),
 
42
        'version': ceph.get_ceph_version()
39
43
        }
40
44
 
41
45
    with open('/etc/ceph/ceph.conf', 'w') as cephconf:
53
57
        sys.exit(1)
54
58
 
55
59
    monitor_secret = utils.config_get('monitor-secret')
56
 
    if monitor_secret == '':
 
60
    if not monitor_secret:
57
61
        utils.juju_log('CRITICAL',
58
62
                       'No monitor-secret supplied, cannot proceed.')
59
63
        sys.exit(1)
61
65
    emit_cephconf()
62
66
 
63
67
    e_mountpoint = utils.config_get('ephemeral-unmount')
64
 
    if (e_mountpoint != "" and
 
68
    if (e_mountpoint and
65
69
        filesystem_mounted(e_mountpoint)):
66
70
        subprocess.call(['umount', e_mountpoint])
67
71
 
127
131
 
128
132
 
129
133
def reformat_osd():
130
 
    if utils.config_get('osd-reformat') != "":
 
134
    if utils.config_get('osd-reformat'):
131
135
        return True
132
136
    else:
133
137
        return False
151
155
                       'Looks like {} is in use, skipping.'.format(dev))
152
156
        return
153
157
 
154
 
    subprocess.call(['ceph-disk-prepare', dev])
 
158
    cmd = ['ceph-disk-prepare']
 
159
    # Later versions of ceph support more options
 
160
    if ceph.version_compare(ceph.get_ceph_version(),
 
161
                            "0.55") >= 0:
 
162
        osd_format = utils.config_get('osd-format')
 
163
        if osd_format:
 
164
            cmd.append('--fs-type')
 
165
            cmd.append(osd_format)
 
166
        cmd.append(dev)
 
167
        osd_journal = utils.config_get('osd-journal')
 
168
        if (osd_journal and
 
169
            os.path.exists(osd_journal)):
 
170
            cmd.append(osd_journal)
 
171
    else:
 
172
        # Just provide the device - no other options
 
173
        # for older versions of ceph
 
174
        cmd.append(dev)
 
175
    subprocess.call(cmd)
155
176
 
156
177
 
157
178
def device_mounted(dev):