~tribaal/charms/trusty/ceph/trunk

« back to all changes in this revision

Viewing changes to hooks/ceph.py

  • Committer: Liam Young
  • Date: 2014-09-26 08:54:03 UTC
  • Revision ID: liam.young@canonical.com-20140926085403-ifrmo61a0u3neupn
Cherry pick the fix to use pkgrevno comparisons from charmhelpers, from next

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
import subprocess
12
12
import time
13
13
import os
14
 
import apt_pkg as apt
15
14
from charmhelpers.core.host import (
16
15
    mkdir,
17
16
    service_restart,
 
17
    cmp_pkgrevno,
18
18
)
19
19
from charmhelpers.core.hookenv import (
20
20
    log,
126
126
def start_osds(devices):
127
127
    # Scan for ceph block devices
128
128
    rescan_osd_devices()
129
 
    if get_ceph_version() >= "0.56.6":
 
129
    if cmp_pkgrevno('ceph', "0.56.6") >= 0:
130
130
        # Use ceph-disk-activate for directory based OSD's
131
131
        for dev_or_path in devices:
132
132
            if os.path.exists(dev_or_path) and os.path.isdir(dev_or_path):
309
309
            os.unlink(keyring)
310
310
 
311
311
 
312
 
def get_ceph_version():
313
 
    apt.init()
314
 
    cache = apt.Cache()
315
 
    pkg = cache['ceph']
316
 
    if pkg.current_ver:
317
 
        return apt.upstream_version(pkg.current_ver.ver_str)
318
 
    else:
319
 
        return None
320
 
 
321
 
 
322
 
def version_compare(a, b):
323
 
    return apt.version_compare(a, b)
324
 
 
325
 
 
326
312
def update_monfs():
327
313
    hostname = get_unit_hostname()
328
314
    monfs = '/var/lib/ceph/mon/ceph-{}'.format(hostname)
360
346
 
361
347
    cmd = ['ceph-disk-prepare']
362
348
    # Later versions of ceph support more options
363
 
    if get_ceph_version() >= "0.48.3":
 
349
    if cmp_pkgrevno('ceph', "0.48.3") >= 0:
364
350
        if osd_format:
365
351
            cmd.append('--fs-type')
366
352
            cmd.append(osd_format)
383
369
        log('Path {} is already configured as an OSD - bailing'.format(path))
384
370
        return
385
371
 
386
 
    if get_ceph_version() < "0.56.6":
 
372
    if cmp_pkgrevno('ceph', "0.56.6") < 0:
387
373
        log('Unable to use directories for OSDs with ceph < 0.56.6',
388
374
            level=ERROR)
389
375
        raise