Skip to content

Commit 74a6293

Browse files
committed
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 <[email protected]>
1 parent 79acee1 commit 74a6293

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

src/ceph-volume/ceph_volume/devices/lvm/activate.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,24 @@
22
import argparse
33
import logging
44
from textwrap import dedent
5-
from ceph_volume import objectstore
5+
from ceph_volume import objectstore, terminal
6+
from typing import List, Optional
67

78

89
logger = logging.getLogger(__name__)
9-
10+
mlogger = terminal.MultiLogger(__name__)
1011

1112
class Activate(object):
1213
help = 'Discover and mount the LVM device associated with an OSD ID and start the Ceph OSD'
1314

14-
def __init__(self, argv, args=None):
15-
self.objectstore = None
15+
def __init__(self,
16+
argv: Optional[List[str]] = None,
17+
args: Optional[argparse.Namespace] = None) -> None:
18+
self.objectstore: Optional[objectstore.baseobjectstore.BaseObjectStore] = None
1619
self.argv = argv
1720
self.args = args
1821

19-
def main(self):
22+
def main(self) -> None:
2023
sub_command_help = dedent("""
2124
Activate OSDs by discovering them with LVM and mounting them in their
2225
appropriate destination:
@@ -85,6 +88,8 @@ def main(self):
8588
action='store_true',
8689
help='Do not use a tmpfs mount for OSD data dir'
8790
)
91+
if self.argv is None:
92+
self.argv = []
8893
if len(self.argv) == 0 and self.args is None:
8994
print(sub_command_help)
9095
return
@@ -93,7 +98,11 @@ def main(self):
9398
if self.args.bluestore:
9499
self.args.objectstore = 'bluestore'
95100
self.objectstore = objectstore.mapping['LVM'][self.args.objectstore](args=self.args)
96-
if self.args.activate_all:
97-
self.objectstore.activate_all()
101+
if self.objectstore is not None:
102+
if self.args.activate_all:
103+
self.objectstore.activate_all()
104+
else:
105+
self.objectstore.activate()
98106
else:
99-
self.objectstore.activate()
107+
mlogger.error('Unexpected error while setting objectstore backend.')
108+
return

src/ceph-volume/ceph_volume/objectstore/baseobjectstore.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ def osd_mkfs(self) -> None:
157157
def activate(self) -> None:
158158
raise NotImplementedError()
159159

160+
def activate_all(self) -> None:
161+
raise NotImplementedError()
162+
160163
def enroll_tpm2(self, device: str) -> None:
161164
"""
162165
Enrolls a device with TPM2 (Trusted Platform Module 2.0) using systemd-cryptenroll.

0 commit comments

Comments
 (0)