]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: add type annotations to devices.lvm.activate
authorGuillaume Abrioux <gabrioux@ibm.com>
Wed, 8 Jan 2025 13:58:26 +0000 (13:58 +0000)
committerGuillaume Abrioux <gabrioux@ibm.com>
Mon, 20 Jan 2025 07:48:03 +0000 (07:48 +0000)
This commit adds the Python type annotations to `devices.lvm.activate`.

Signed-off-by: Guillaume Abrioux <gabrioux@ibm.com>
src/ceph-volume/ceph_volume/devices/lvm/activate.py
src/ceph-volume/ceph_volume/objectstore/baseobjectstore.py

index 7b4d57c9509144da5aa03fa8bb6ab8963c117cf5..60ef423ad9b6e79fff331eab39699475508e106d 100644 (file)
@@ -2,21 +2,24 @@ from __future__ import print_function
 import argparse
 import logging
 from textwrap import dedent
-from ceph_volume import objectstore
+from ceph_volume import objectstore, terminal
+from typing import List, Optional
 
 
 logger = logging.getLogger(__name__)
-
+mlogger = terminal.MultiLogger(__name__)
 
 class Activate(object):
     help = 'Discover and mount the LVM device associated with an OSD ID and start the Ceph OSD'
 
-    def __init__(self, argv, args=None):
-        self.objectstore = None
+    def __init__(self,
+                 argv: Optional[List[str]] = None,
+                 args: Optional[argparse.Namespace] = None) -> None:
+        self.objectstore: Optional[objectstore.baseobjectstore.BaseObjectStore] = None
         self.argv = argv
         self.args = args
 
-    def main(self):
+    def main(self) -> None:
         sub_command_help = dedent("""
         Activate OSDs by discovering them with LVM and mounting them in their
         appropriate destination:
@@ -85,6 +88,8 @@ class Activate(object):
             action='store_true',
             help='Do not use a tmpfs mount for OSD data dir'
         )
+        if self.argv is None:
+            self.argv = []
         if len(self.argv) == 0 and self.args is None:
             print(sub_command_help)
             return
@@ -93,7 +98,11 @@ class Activate(object):
         if self.args.bluestore:
             self.args.objectstore = 'bluestore'
         self.objectstore = objectstore.mapping['LVM'][self.args.objectstore](args=self.args)
-        if self.args.activate_all:
-            self.objectstore.activate_all()
+        if self.objectstore is not None:
+            if self.args.activate_all:
+                self.objectstore.activate_all()
+            else:
+                self.objectstore.activate()
         else:
-            self.objectstore.activate()
+            mlogger.error('Unexpected error while setting objectstore backend.')
+            return
\ No newline at end of file
index cb55aae7d81491b3291aec7934f7124da483dc98..7afc571d0a044d40c0381bc5ba501086f1e5f16d 100644 (file)
@@ -157,6 +157,9 @@ class BaseObjectStore:
     def activate(self) -> None:
         raise NotImplementedError()
 
+    def activate_all(self) -> None:
+        raise NotImplementedError()
+
     def enroll_tpm2(self, device: str) -> None:
         """
         Enrolls a device with TPM2 (Trusted Platform Module 2.0) using systemd-cryptenroll.