22import argparse
33import logging
44from textwrap import dedent
5- from ceph_volume import objectstore
5+ from ceph_volume import objectstore , terminal
6+ from typing import List , Optional
67
78
89logger = logging .getLogger (__name__ )
9-
10+ mlogger = terminal . MultiLogger ( __name__ )
1011
1112class 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
0 commit comments