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