Merge "Add support for Storage hooks"
This commit is contained in:
commit
7733790748
@ -10,7 +10,8 @@ options:
|
||||
The devices to format and set up as osd volumes.
|
||||
|
||||
These devices are the range of devices that will be checked for and
|
||||
used across all service units.
|
||||
used across all service units, in addition to any volumes attached
|
||||
via the --storage flag during deployment.
|
||||
|
||||
For ceph >= 0.56.6 these can also be directories instead of devices - the
|
||||
charm assumes anything not starting with /dev is a directory instead.
|
||||
|
7
hooks/add-storage
Executable file
7
hooks/add-storage
Executable file
@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
# Wrapper to deal with newer Ubuntu versions that don't have py2 installed
|
||||
# by default.
|
||||
|
||||
dpkg -l|grep 'python-apt ' || exit 0
|
||||
|
||||
exec ./hooks/storage.real
|
@ -31,6 +31,8 @@ from charmhelpers.core.hookenv import (
|
||||
UnregisteredHookError,
|
||||
service_name,
|
||||
status_set,
|
||||
storage_get,
|
||||
storage_list,
|
||||
)
|
||||
from charmhelpers.core.host import (
|
||||
umount,
|
||||
@ -413,6 +415,7 @@ def config_changed():
|
||||
prepare_disks_and_activate()
|
||||
|
||||
|
||||
@hooks.hook('storage.real')
|
||||
def prepare_disks_and_activate():
|
||||
osd_journal = get_journal_devices()
|
||||
check_overlap(osd_journal, set(get_devices()))
|
||||
@ -481,20 +484,31 @@ def reformat_osd():
|
||||
|
||||
def get_devices():
|
||||
if config('osd-devices'):
|
||||
return [
|
||||
devices = [
|
||||
os.path.realpath(path)
|
||||
for path in config('osd-devices').split(' ')]
|
||||
else:
|
||||
return []
|
||||
devices = []
|
||||
|
||||
# List storage instances for the 'osd-devices'
|
||||
# store declared for this charm too, and add
|
||||
# their block device paths to the list.
|
||||
storage_ids = storage_list('osd-devices')
|
||||
devices.extend((storage_get('location', s) for s in storage_ids))
|
||||
return devices
|
||||
|
||||
|
||||
def get_journal_devices():
|
||||
osd_journal = config('osd-journal')
|
||||
if not osd_journal:
|
||||
return set()
|
||||
osd_journal = [l.strip() for l in config('osd-journal').split(' ')]
|
||||
osd_journal = set(filter(os.path.exists, osd_journal))
|
||||
return osd_journal
|
||||
if config('osd-journal'):
|
||||
devices = config('osd-journal')
|
||||
devices = [l.strip() for l in config('osd-journal').split(' ')]
|
||||
else:
|
||||
devices = []
|
||||
storage_ids = storage_list('osd-journals')
|
||||
devices.extend((storage_get('location', s) for s in storage_ids))
|
||||
devices = filter(os.path.exists, devices)
|
||||
|
||||
return set(devices)
|
||||
|
||||
|
||||
@hooks.hook('mon-relation-changed',
|
||||
|
1
hooks/osd-devices-storage-attached
Symbolic link
1
hooks/osd-devices-storage-attached
Symbolic link
@ -0,0 +1 @@
|
||||
add-storage
|
1
hooks/osd-devices-storage-detaching
Symbolic link
1
hooks/osd-devices-storage-detaching
Symbolic link
@ -0,0 +1 @@
|
||||
add-storage
|
1
hooks/storage.real
Symbolic link
1
hooks/storage.real
Symbolic link
@ -0,0 +1 @@
|
||||
ceph_hooks.py
|
@ -22,3 +22,12 @@ extra-bindings:
|
||||
requires:
|
||||
mon:
|
||||
interface: ceph-osd
|
||||
storage:
|
||||
osd-devices:
|
||||
type: block
|
||||
multiple:
|
||||
range: 0-
|
||||
osd-journals:
|
||||
type: block
|
||||
multiple:
|
||||
range: 0-
|
Loading…
Reference in New Issue
Block a user