diff --git a/config.yaml b/config.yaml index fccc44eb..b658bb40 100644 --- a/config.yaml +++ b/config.yaml @@ -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. diff --git a/hooks/add-storage b/hooks/add-storage new file mode 100755 index 00000000..5b02c170 --- /dev/null +++ b/hooks/add-storage @@ -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 \ No newline at end of file diff --git a/hooks/ceph_hooks.py b/hooks/ceph_hooks.py index b5799632..f38108ec 100755 --- a/hooks/ceph_hooks.py +++ b/hooks/ceph_hooks.py @@ -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', diff --git a/hooks/osd-devices-storage-attached b/hooks/osd-devices-storage-attached new file mode 120000 index 00000000..68134a91 --- /dev/null +++ b/hooks/osd-devices-storage-attached @@ -0,0 +1 @@ +add-storage \ No newline at end of file diff --git a/hooks/osd-devices-storage-detaching b/hooks/osd-devices-storage-detaching new file mode 120000 index 00000000..68134a91 --- /dev/null +++ b/hooks/osd-devices-storage-detaching @@ -0,0 +1 @@ +add-storage \ No newline at end of file diff --git a/hooks/storage.real b/hooks/storage.real new file mode 120000 index 00000000..52d96630 --- /dev/null +++ b/hooks/storage.real @@ -0,0 +1 @@ +ceph_hooks.py \ No newline at end of file diff --git a/metadata.yaml b/metadata.yaml index a48b5d31..01815ea0 100644 --- a/metadata.yaml +++ b/metadata.yaml @@ -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- \ No newline at end of file