This commit is contained in:
James Page 2014-07-25 09:01:29 +01:00
commit 0f944474df
4 changed files with 16 additions and 45 deletions

View File

@ -11,10 +11,10 @@ import json
import subprocess
import time
import os
import apt_pkg as apt
from charmhelpers.core.host import (
mkdir,
service_restart,
cmp_pkgrevno,
)
from charmhelpers.core.hookenv import (
log,
@ -126,7 +126,7 @@ def is_osd_disk(dev):
def start_osds(devices):
# Scan for ceph block devices
rescan_osd_devices()
if get_ceph_version() >= "0.56.6":
if cmp_pkgrevno('ceph', "0.56.6") >= 0:
# Use ceph-disk-activate for directory based OSD's
for dev_or_path in devices:
if os.path.exists(dev_or_path) and os.path.isdir(dev_or_path):
@ -309,20 +309,6 @@ def bootstrap_monitor_cluster(secret):
os.unlink(keyring)
def get_ceph_version():
apt.init()
cache = apt.Cache()
pkg = cache['ceph']
if pkg.current_ver:
return apt.upstream_version(pkg.current_ver.ver_str)
else:
return None
def version_compare(a, b):
return apt.version_compare(a, b)
def update_monfs():
hostname = get_unit_hostname()
monfs = '/var/lib/ceph/mon/ceph-{}'.format(hostname)
@ -360,7 +346,7 @@ def osdize_dev(dev, osd_format, osd_journal, reformat_osd=False):
cmd = ['ceph-disk-prepare']
# Later versions of ceph support more options
if get_ceph_version() >= "0.48.3":
if cmp_pkgrevno('ceph', "0.48.3") >= 0:
if osd_format:
cmd.append('--fs-type')
cmd.append(osd_format)
@ -385,7 +371,7 @@ def osdize_dir(path):
log('Path {} is already configured as an OSD - bailing'.format(path))
return
if get_ceph_version() < "0.56.6":
if cmp_pkgrevno('ceph', "0.56.6") < 0:
log('Unable to use directories for OSDs with ceph < 0.56.6',
level=ERROR)
raise

View File

@ -1,5 +1,7 @@
import sys
from functools import partial
from charmhelpers.fetch import apt_install
from charmhelpers.core.hookenv import (
ERROR, log,
@ -62,10 +64,9 @@ def get_address_in_network(network, fallback=None, fatal=False):
return str(cidr.ip)
if network.version == 6 and netifaces.AF_INET6 in addresses:
for addr in addresses[netifaces.AF_INET6]:
if 'fe80' not in addr['addr']:
netmask = addr['netmask']
if not addr['addr'].startswith('fe80'):
cidr = netaddr.IPNetwork("%s/%s" % (addr['addr'],
netmask))
addr['netmask']))
if cidr in network:
return str(cidr.ip)
@ -139,7 +140,7 @@ def _get_for_address(address, key):
return addresses[netifaces.AF_INET][0][key]
if address.version == 6 and netifaces.AF_INET6 in addresses:
for addr in addresses[netifaces.AF_INET6]:
if 'fe80' not in addr['addr']:
if not addr['addr'].startswith('fe80'):
cidr = netaddr.IPNetwork("%s/%s" % (addr['addr'],
addr['netmask']))
if address in cidr:
@ -150,23 +151,6 @@ def _get_for_address(address, key):
return None
def get_iface_for_address(address):
"""Determine the physical interface to which an IP address could be bound
get_iface_for_address = partial(_get_for_address, key='iface')
:param address (str): An individual IPv4 or IPv6 address without a net
mask or subnet prefix. For example, '192.168.1.1'.
:returns str: Interface name or None if address is not bindable.
"""
return _get_for_address(address, 'iface')
def get_netmask_for_address(address):
"""Determine the netmask of the physical interface to which and IP address
could be bound
:param address (str): An individual IPv4 or IPv6 address without a net
mask or subnet prefix. For example, '192.168.1.1'.
:returns str: Netmask of configured interface or None if address is
not bindable.
"""
return _get_for_address(address, 'netmask')
get_netmask_for_address = partial(_get_for_address, key='netmask')

View File

@ -29,7 +29,8 @@ from charmhelpers.core.hookenv import (
from charmhelpers.core.host import (
service_restart,
umount,
mkdir
mkdir,
cmp_pkgrevno
)
from charmhelpers.fetch import (
apt_install,
@ -51,7 +52,7 @@ hooks = Hooks()
def install_upstart_scripts():
# Only install upstart configurations for older versions
if ceph.get_ceph_version() < "0.55.1":
if cmp_pkgrevno('ceph', "0.55.1") < 0:
for x in glob.glob('files/upstart/*.conf'):
shutil.copy(x, '/etc/init/')
@ -70,7 +71,7 @@ def emit_cephconf():
'auth_supported': config('auth-supported'),
'mon_hosts': ' '.join(get_mon_hosts()),
'fsid': config('fsid'),
'version': ceph.get_ceph_version(),
'old_auth': cmp_pkgrevno('ceph', "0.51") < 0,
'osd_journal_size': config('osd-journal-size'),
'use_syslog': str(config('use-syslog')).lower(),
'ceph_public_network': config('ceph-public-network'),

View File

@ -1,5 +1,5 @@
[global]
{% if version < "0.51" %}
{% if old_auth %}
auth supported = {{ auth_supported }}
{% else %}
auth cluster required = {{ auth_supported }}