sync changes from charms.ceph
Change-Id: I8a83e15a77306cca4baa665c31cb9363f7cbde83 Depends-On: I483ee9dae4ce69c71ae06359d0fb96aaa1c56cbc
This commit is contained in:
parent
d5a584bc82
commit
7a5be1a23c
|
@ -51,6 +51,8 @@ from charmhelpers.core.hookenv import (
|
||||||
DEBUG,
|
DEBUG,
|
||||||
ERROR,
|
ERROR,
|
||||||
WARNING,
|
WARNING,
|
||||||
|
storage_get,
|
||||||
|
storage_list,
|
||||||
)
|
)
|
||||||
from charmhelpers.fetch import (
|
from charmhelpers.fetch import (
|
||||||
apt_cache,
|
apt_cache,
|
||||||
|
@ -1353,12 +1355,38 @@ def get_partitions(dev):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
||||||
def find_least_used_journal(journal_devices):
|
def find_least_used_utility_device(utility_devices):
|
||||||
usages = map(lambda a: (len(get_partitions(a)), a), journal_devices)
|
"""
|
||||||
|
Find a utility device which has the smallest number of partitions
|
||||||
|
among other devices in the supplied list.
|
||||||
|
|
||||||
|
:utility_devices: A list of devices to be used for filestore journal
|
||||||
|
or bluestore wal or db.
|
||||||
|
:return: string device name
|
||||||
|
"""
|
||||||
|
|
||||||
|
usages = map(lambda a: (len(get_partitions(a)), a), utility_devices)
|
||||||
least = min(usages, key=lambda t: t[0])
|
least = min(usages, key=lambda t: t[0])
|
||||||
return least[1]
|
return least[1]
|
||||||
|
|
||||||
|
|
||||||
|
def get_devices(name):
|
||||||
|
""" Merge config and juju storage based devices
|
||||||
|
|
||||||
|
:name: THe name of the device type, eg: wal, osd, journal
|
||||||
|
:returns: Set(device names), which are strings
|
||||||
|
"""
|
||||||
|
if config(name):
|
||||||
|
devices = [l.strip() for l in config(name).split(' ')]
|
||||||
|
else:
|
||||||
|
devices = []
|
||||||
|
storage_ids = storage_list(name)
|
||||||
|
devices.extend((storage_get('location', s) for s in storage_ids))
|
||||||
|
devices = filter(os.path.exists, devices)
|
||||||
|
|
||||||
|
return set(devices)
|
||||||
|
|
||||||
|
|
||||||
def osdize(dev, osd_format, osd_journal, reformat_osd=False,
|
def osdize(dev, osd_format, osd_journal, reformat_osd=False,
|
||||||
ignore_errors=False, encrypt=False, bluestore=False):
|
ignore_errors=False, encrypt=False, bluestore=False):
|
||||||
if dev.startswith('/dev'):
|
if dev.startswith('/dev'):
|
||||||
|
@ -1405,13 +1433,23 @@ def osdize_dev(dev, osd_format, osd_journal, reformat_osd=False,
|
||||||
# NOTE(jamespage): enable experimental bluestore support
|
# NOTE(jamespage): enable experimental bluestore support
|
||||||
if cmp_pkgrevno('ceph', '10.2.0') >= 0 and bluestore:
|
if cmp_pkgrevno('ceph', '10.2.0') >= 0 and bluestore:
|
||||||
cmd.append('--bluestore')
|
cmd.append('--bluestore')
|
||||||
|
wal = get_devices('bluestore-wal')
|
||||||
|
if wal:
|
||||||
|
cmd.append('--block.wal')
|
||||||
|
least_used_wal = find_least_used_utility_device(wal)
|
||||||
|
cmd.append(least_used_wal)
|
||||||
|
db = get_devices('bluestore-db')
|
||||||
|
if db:
|
||||||
|
cmd.append('--block.db')
|
||||||
|
least_used_db = find_least_used_utility_device(db)
|
||||||
|
cmd.append(least_used_db)
|
||||||
elif cmp_pkgrevno('ceph', '12.1.0') >= 0 and not bluestore:
|
elif cmp_pkgrevno('ceph', '12.1.0') >= 0 and not bluestore:
|
||||||
cmd.append('--filestore')
|
cmd.append('--filestore')
|
||||||
|
|
||||||
cmd.append(dev)
|
cmd.append(dev)
|
||||||
|
|
||||||
if osd_journal:
|
if osd_journal:
|
||||||
least_used = find_least_used_journal(osd_journal)
|
least_used = find_least_used_utility_device(osd_journal)
|
||||||
cmd.append(least_used)
|
cmd.append(least_used)
|
||||||
else:
|
else:
|
||||||
# Just provide the device - no other options
|
# Just provide the device - no other options
|
||||||
|
|
Loading…
Reference in New Issue