]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: lvm create the functional activate module
authorAlfredo Deza <adeza@redhat.com>
Thu, 29 Jun 2017 13:49:50 +0000 (09:49 -0400)
committerAlfredo Deza <adeza@redhat.com>
Fri, 4 Aug 2017 14:25:57 +0000 (10:25 -0400)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
src/ceph-volume/ceph_volume/devices/lvm/activate.py [new file with mode: 0644]

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 (file)
index 0000000..c4a51ff
--- /dev/null
@@ -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)