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:
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
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