From 05d8fe14eef74b516697f9a02bcc3e79f212e049 Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Thu, 29 Jun 2017 09:49:50 -0400 Subject: [PATCH] ceph-volume: lvm create the functional activate module Signed-off-by: Alfredo Deza --- .../ceph_volume/devices/lvm/activate.py | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 src/ceph-volume/ceph_volume/devices/lvm/activate.py diff --git a/src/ceph-volume/ceph_volume/devices/lvm/activate.py b/src/ceph-volume/ceph_volume/devices/lvm/activate.py new file mode 100644 index 00000000000..c4a51ff0f91 --- /dev/null +++ b/src/ceph-volume/ceph_volume/devices/lvm/activate.py @@ -0,0 +1,66 @@ +import argparse +from textwrap import dedent +from ceph_volume import process +from ceph_volume.systemd import systemctl +import api + + +def activate_filestore(lvs): + # find the osd + osd_lv = lvs.get(lv_tags={'ceph.type': 'osd'}) + osd_id = osd_lv.tags['ceph.osd_id'] + osd_journal = lvs.get(lv_tags={'ceph.type': 'journal'}) + + # mount the osd + source = osd_lv.lv_path + destination = '/var/lib/ceph/osd/ceph-%s' % osd_id + process.call(['sudo', 'mount', '-v', source, destination]) + + # ensure that the symlink for the journal is there + source = osd_journal.lv_path + destination = '/var/lib/ceph/osd/ceph-%s/journal' % osd_id + process.call(['sudo', 'ln', '-s', source, destination]) + + # start the OSD + systemctl.start_osd(osd_id) + + +def activate_bluestore(lvs): + # TODO + pass + + +class Activate(object): + + help = 'Discover and mount the LVM device associated with an OSD ID and start the Ceph OSD' + + def __init__(self, argv): + self.argv = argv + + def activate(self, args): + lvs = api.Volumes() + # filter them down for the OSD ID and FSID we need to activate + lvs.filter(lv_tags={'ceph.osd_id': args.id, 'ceph.osd_fsid': args.fsid}) + activate_filestore(lvs) + + def main(self): + sub_command_help = dedent(""" + Activate OSDs by discovering them with LVM and mounting them in their + appropriate destination: + + ceph-volume lvm activate {ID} {UUID} + + The lvs associated with the OSD need to have been prepared previously, + so that all needed tags and metadata exist. + + """) + parser = argparse.ArgumentParser( + prog='ceph-volume lvm activate', + formatter_class=argparse.RawDescriptionHelpFormatter, + description=sub_command_help, + ) + + parser.add_argument('id', nargs='?', help='The ID of the OSD, usually an integer, like 0') + parser.add_argument('fsid', nargs='?', help='The FSID of the OSD, similar to a SHA1') + args = parser.parse_args(self.argv[1:]) + self.activate(args) -- 2.39.5