From: Guillaume Abrioux Date: Wed, 8 Jan 2025 13:58:26 +0000 (+0000) Subject: ceph-volume: add type annotations to devices.lvm.activate X-Git-Tag: v20.0.0~336^2~11 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=74a6293278857f9fd7bae5410a8e40c986683107;p=ceph.git ceph-volume: add type annotations to devices.lvm.activate This commit adds the Python type annotations to `devices.lvm.activate`. Signed-off-by: Guillaume Abrioux --- diff --git a/src/ceph-volume/ceph_volume/devices/lvm/activate.py b/src/ceph-volume/ceph_volume/devices/lvm/activate.py index 7b4d57c950914..60ef423ad9b6e 100644 --- a/src/ceph-volume/ceph_volume/devices/lvm/activate.py +++ b/src/ceph-volume/ceph_volume/devices/lvm/activate.py @@ -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 diff --git a/src/ceph-volume/ceph_volume/objectstore/baseobjectstore.py b/src/ceph-volume/ceph_volume/objectstore/baseobjectstore.py index cb55aae7d8149..7afc571d0a044 100644 --- a/src/ceph-volume/ceph_volume/objectstore/baseobjectstore.py +++ b/src/ceph-volume/ceph_volume/objectstore/baseobjectstore.py @@ -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.