charm-ceph-osd/actions/add_disk.py
James Page 6c27240761 add-disk: Ensure key-manager config is passed to osdize
Recent changes to support vault for key management require that
the 'osd-encrypt-keymanager' is passed to all osdize calls so
that the correct key management approach is taken.

Ensure that the add-disk action does the same, otherwise keys
will always be stored in the ceph mon KV store, rather than
in Vault.

Closes-Bug: 1780920

Change-Id: I8c722d38d68f13dc00c7444a50d67ce37fbd6a29
2018-07-10 09:29:17 +01:00

69 lines
2.1 KiB
Python
Executable File

#!/usr/bin/env python3
#
# Copyright 2016 Canonical Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import psutil
import sys
sys.path.append('lib')
sys.path.append('hooks')
import charmhelpers.contrib.storage.linux.ceph as ch_ceph
import charmhelpers.core.hookenv as hookenv
import ceph_hooks
import ceph.utils
def add_device(request, device_path, bucket=None):
ceph.utils.osdize(dev, hookenv.config('osd-format'),
ceph_hooks.get_journal_devices(),
hookenv.config('ignore-device-errors'),
hookenv.config('osd-encrypt'),
hookenv.config('bluestore'),
hookenv.config('osd-encrypt-keymanager'))
# Make it fast!
if hookenv.config('autotune'):
ceph.utils.tune_dev(dev)
mounts = filter(lambda disk: device_path
in disk.device, psutil.disk_partitions())
for osd in mounts:
osd_id = osd.mountpoint.split('/')[-1].split('-')[-1]
request.ops.append({
'op': 'move-osd-to-bucket',
'osd': "osd.{}".format(osd_id),
'bucket': bucket})
return request
def get_devices():
devices = []
for path in hookenv.action_get('osd-devices').split(' '):
path = path.strip()
if os.path.isabs(path):
devices.append(path)
return devices
if __name__ == "__main__":
request = ch_ceph.CephBrokerRq()
for dev in get_devices():
request = add_device(request=request,
device_path=dev,
bucket=hookenv.action_get("bucket"))
ch_ceph.send_request_if_needed(request, relation='mon')