]> git.proxmox.com Git - ceph.git/blame - ceph/src/ceph-volume/ceph_volume/activate/main.py
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / ceph-volume / ceph_volume / activate / main.py
CommitLineData
20effc67
TL
1# -*- coding: utf-8 -*-
2
3import argparse
4
5from ceph_volume import terminal
6from ceph_volume.devices.lvm.activate import Activate as LVMActivate
7from ceph_volume.devices.raw.activate import Activate as RAWActivate
8from ceph_volume.devices.simple.activate import Activate as SimpleActivate
9
10
11class Activate(object):
12
13 help = "Activate an OSD"
14
15 def __init__(self, argv):
16 self.argv = argv
17
18 def main(self):
19 parser = argparse.ArgumentParser(
20 prog='ceph-volume activate',
21 formatter_class=argparse.RawDescriptionHelpFormatter,
22 description=self.help,
23 )
24 parser.add_argument(
25 '--osd-id',
26 help='OSD ID to activate'
27 )
28 parser.add_argument(
29 '--osd-uuid',
1e59de90 30 help='OSD UUID to activate'
20effc67
TL
31 )
32 parser.add_argument(
33 '--no-systemd',
34 dest='no_systemd',
35 action='store_true',
36 help='Skip creating and enabling systemd units and starting OSD services'
37 )
38 parser.add_argument(
39 '--no-tmpfs',
40 action='store_true',
41 help='Do not use a tmpfs mount for OSD data dir'
42 )
43 self.args = parser.parse_args(self.argv)
44
45 # first try raw
46 try:
47 RAWActivate([]).activate(
48 devs=None,
49 start_osd_id=self.args.osd_id,
50 start_osd_uuid=self.args.osd_uuid,
51 tmpfs=not self.args.no_tmpfs,
52 systemd=not self.args.no_systemd,
20effc67
TL
53 )
54 return
55 except Exception as e:
56 terminal.info(f'Failed to activate via raw: {e}')
57
58 # then try lvm
59 try:
60 LVMActivate([]).activate(
61 argparse.Namespace(
62 osd_id=self.args.osd_id,
63 osd_fsid=self.args.osd_uuid,
64 no_tmpfs=self.args.no_tmpfs,
65 no_systemd=self.args.no_systemd,
66 )
67 )
68 return
69 except Exception as e:
1e59de90 70 terminal.info(f'Failed to activate via LVM: {e}')
20effc67
TL
71
72 # then try simple
73 try:
74 SimpleActivate([]).activate(
75 argparse.Namespace(
76 osd_id=self.args.osd_id,
77 osd_fsid=self.args.osd_uuid,
78 no_systemd=self.args.no_systemd,
79 )
80 )
81 return
82 except Exception as e:
83 terminal.info(f'Failed to activate via simple: {e}')
84
85 terminal.error('Failed to activate any OSD(s)')