]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: top-level 'activate' command
authorSage Weil <sage@newdream.net>
Thu, 5 Aug 2021 17:29:17 +0000 (13:29 -0400)
committerAdam King <adking@redhat.com>
Tue, 17 May 2022 14:25:59 +0000 (10:25 -0400)
First try raw, then lvm.

Signed-off-by: Sage Weil <sage@newdream.net>
(cherry picked from commit 3d7ceec684b0ac5b83fae4c397b134236fac485e)

src/ceph-volume/ceph_volume/activate/__init__.py [new file with mode: 0644]
src/ceph-volume/ceph_volume/activate/main.py [new file with mode: 0644]
src/ceph-volume/ceph_volume/main.py

diff --git a/src/ceph-volume/ceph_volume/activate/__init__.py b/src/ceph-volume/ceph_volume/activate/__init__.py
new file mode 100644 (file)
index 0000000..542bf32
--- /dev/null
@@ -0,0 +1 @@
+from .main import Activate # noqa
diff --git a/src/ceph-volume/ceph_volume/activate/main.py b/src/ceph-volume/ceph_volume/activate/main.py
new file mode 100644 (file)
index 0000000..40690c5
--- /dev/null
@@ -0,0 +1,73 @@
+# -*- coding: utf-8 -*-
+
+import argparse
+
+from ceph_volume import terminal
+from ceph_volume.devices.lvm.activate import Activate as LVMActivate
+from ceph_volume.devices.raw.activate import Activate as RAWActivate
+
+
+class Activate(object):
+
+    help = "Activate an OSD"
+
+    def __init__(self, argv):
+        self.argv = argv
+
+    def main(self):
+        parser = argparse.ArgumentParser(
+            prog='ceph-volume activate',
+            formatter_class=argparse.RawDescriptionHelpFormatter,
+            description=self.help,
+        )
+        parser.add_argument(
+            '--osd-id',
+            help='OSD ID to activate'
+        )
+        parser.add_argument(
+            '--osd-uuid',
+            help='OSD UUID to active'
+        )
+        parser.add_argument(
+            '--no-systemd',
+            dest='no_systemd',
+            action='store_true',
+            help='Skip creating and enabling systemd units and starting OSD services'
+        )
+        parser.add_argument(
+            '--no-tmpfs',
+            action='store_true',
+            help='Do not use a tmpfs mount for OSD data dir'
+        )
+        self.args = parser.parse_args(self.argv)
+
+        # first try raw
+        try:
+            RAWActivate([]).activate(
+                device=None,
+                start_osd_id=self.args.osd_id,
+                start_osd_uuid=self.args.osd_uuid,
+                tmpfs=not self.args.no_tmpfs,
+                systemd=not self.args.no_systemd,
+                block_wal=None,
+                block_db=None,
+            )
+            return
+        except Exception as e:
+            terminal.info(f'Failed to activate via raw: {e}')
+
+        # then try lvm
+        try:
+            LVMActivate([]).activate(
+                argparse.Namespace(
+                    osd_id=self.args.osd_id,
+                    osd_fsid=self.args.osd_uuid,
+                    no_tmpfs=self.args.no_tmpfs,
+                    no_systemd=self.args.no_systemd,
+                )
+            )
+            return
+        except Exception as e:
+            terminal.info(f'Failed to activate via lvm: {e}')
+
+        terminal.error('Failed to activate any OSD(s)')
index a66b7bb7df96164f9803d43ccf29de840eed4dec..652b0f9c87d13ed5a13506214c370609993303f9 100644 (file)
@@ -6,7 +6,7 @@ import sys
 import logging
 
 from ceph_volume.decorators import catches
-from ceph_volume import log, devices, configuration, conf, exceptions, terminal, inventory, drive_group
+from ceph_volume import log, devices, configuration, conf, exceptions, terminal, inventory, drive_group, activate
 
 
 class Volume(object):
@@ -29,6 +29,7 @@ Ceph Conf: {ceph_path}
             'simple': devices.simple.Simple,
             'raw': devices.raw.Raw,
             'inventory': inventory.Inventory,
+            'activate': activate.Activate,
             'drive-group': drive_group.Deploy,
         }
         self.plugin_help = "No plugins found/loaded"