]>
Commit | Line | Data |
---|---|---|
b5b8bbf5 | 1 | from ceph_volume.util import arg_validators |
11fdf7f2 | 2 | from ceph_volume import process, conf |
b32b8144 | 3 | from ceph_volume import terminal |
d2e6a577 FG |
4 | import argparse |
5 | ||
6 | ||
b32b8144 FG |
7 | def rollback_osd(args, osd_id=None): |
8 | """ | |
11fdf7f2 TL |
9 | When the process of creating or preparing fails, the OSD needs to be |
10 | destroyed so that the ID cane be reused. This is prevents leaving the ID | |
11 | around as "used" on the monitor, which can cause confusion if expecting | |
12 | sequential OSD IDs. | |
13 | ||
14 | The usage of `destroy-new` allows this to be done without requiring the | |
15 | admin keyring (otherwise needed for destroy and purge commands) | |
b32b8144 FG |
16 | """ |
17 | if not osd_id: | |
18 | # it means that it wasn't generated, so there is nothing to rollback here | |
19 | return | |
20 | ||
21 | # once here, this is an error condition that needs to be rolled back | |
22 | terminal.error('Was unable to complete a new OSD, will rollback changes') | |
23 | osd_name = 'osd.%s' | |
11fdf7f2 TL |
24 | bootstrap_keyring = '/var/lib/ceph/bootstrap-osd/%s.keyring' % conf.cluster |
25 | cmd = [ | |
26 | 'ceph', | |
27 | '--cluster', conf.cluster, | |
28 | '--name', 'client.bootstrap-osd', | |
29 | '--keyring', bootstrap_keyring, | |
30 | 'osd', 'purge-new', osd_name % osd_id, | |
31 | '--yes-i-really-mean-it', | |
32 | ] | |
33 | ||
34 | process.run(cmd) | |
b32b8144 FG |
35 | |
36 | ||
d2e6a577 FG |
37 | def common_parser(prog, description): |
38 | """ | |
39 | Both prepare and create share the same parser, those are defined here to | |
40 | avoid duplication | |
41 | """ | |
42 | parser = argparse.ArgumentParser( | |
43 | prog=prog, | |
44 | formatter_class=argparse.RawDescriptionHelpFormatter, | |
45 | description=description, | |
46 | ) | |
3a9019d9 FG |
47 | |
48 | required_group = parser.add_argument_group('required arguments') | |
49 | filestore_group = parser.add_argument_group('filestore') | |
50 | bluestore_group = parser.add_argument_group('bluestore') | |
51 | ||
52 | required_group.add_argument( | |
d2e6a577 FG |
53 | '--data', |
54 | required=True, | |
91327a77 | 55 | type=arg_validators.ValidDevice(as_string=True), |
3efd9988 | 56 | help='OSD data path. A physical device or logical volume', |
d2e6a577 | 57 | ) |
3a9019d9 | 58 | |
92f5a8d4 TL |
59 | required_group.add_argument( |
60 | '--data-size', | |
61 | help='Size of data LV in case a device was passed in --data', | |
62 | default=0, | |
63 | ) | |
64 | ||
65 | required_group.add_argument( | |
66 | '--data-slots', | |
67 | help=('Intended number of slots on data device. The new OSD gets one' | |
68 | 'of those slots or 1/nth of the available capacity'), | |
69 | default=1, | |
70 | ) | |
71 | ||
3a9019d9 FG |
72 | filestore_group.add_argument( |
73 | '--filestore', | |
74 | action='store_true', | |
75 | help='Use the filestore objectstore', | |
d2e6a577 | 76 | ) |
3a9019d9 FG |
77 | |
78 | filestore_group.add_argument( | |
79 | '--journal', | |
80 | help='(REQUIRED) A logical volume (vg_name/lv_name), or path to a device', | |
81 | ) | |
82 | ||
92f5a8d4 TL |
83 | filestore_group.add_argument( |
84 | '--journal-size', | |
85 | help='Size of journal LV in case a raw block device was passed in --journal', | |
86 | default=0, | |
87 | ) | |
88 | ||
3a9019d9 | 89 | bluestore_group.add_argument( |
d2e6a577 | 90 | '--bluestore', |
3efd9988 FG |
91 | action='store_true', |
92 | help='Use the bluestore objectstore', | |
d2e6a577 | 93 | ) |
3a9019d9 FG |
94 | |
95 | bluestore_group.add_argument( | |
96 | '--block.db', | |
97 | dest='block_db', | |
98 | help='Path to bluestore block.db logical volume or device', | |
99 | ) | |
100 | ||
92f5a8d4 TL |
101 | bluestore_group.add_argument( |
102 | '--block.db-size', | |
103 | dest='block_db_size', | |
104 | help='Size of block.db LV in case device was passed in --block.db', | |
105 | default=0, | |
106 | ) | |
107 | ||
108 | required_group.add_argument( | |
109 | '--block.db-slots', | |
110 | dest='block_db_slots', | |
111 | help=('Intended number of slots on db device. The new OSD gets one' | |
112 | 'of those slots or 1/nth of the available capacity'), | |
113 | default=1, | |
114 | ) | |
115 | ||
3a9019d9 FG |
116 | bluestore_group.add_argument( |
117 | '--block.wal', | |
118 | dest='block_wal', | |
119 | help='Path to bluestore block.wal logical volume or device', | |
d2e6a577 | 120 | ) |
3a9019d9 | 121 | |
92f5a8d4 TL |
122 | bluestore_group.add_argument( |
123 | '--block.wal-size', | |
124 | dest='block_wal_size', | |
125 | help='Size of block.wal LV in case device was passed in --block.wal', | |
126 | default=0, | |
127 | ) | |
128 | ||
129 | required_group.add_argument( | |
130 | '--block.wal-slots', | |
131 | dest='block_wal_slots', | |
132 | help=('Intended number of slots on wal device. The new OSD gets one' | |
133 | 'of those slots or 1/nth of the available capacity'), | |
134 | default=1, | |
135 | ) | |
136 | ||
d2e6a577 FG |
137 | parser.add_argument( |
138 | '--osd-id', | |
139 | help='Reuse an existing OSD id', | |
140 | ) | |
3a9019d9 | 141 | |
d2e6a577 FG |
142 | parser.add_argument( |
143 | '--osd-fsid', | |
144 | help='Reuse an existing OSD fsid', | |
145 | ) | |
3a9019d9 | 146 | |
91327a77 AA |
147 | parser.add_argument( |
148 | '--cluster-fsid', | |
149 | help='Specify the cluster fsid, useful when no ceph.conf is available', | |
150 | ) | |
151 | ||
b32b8144 FG |
152 | parser.add_argument( |
153 | '--crush-device-class', | |
154 | dest='crush_device_class', | |
155 | help='Crush device class to assign this OSD to', | |
156 | ) | |
3a9019d9 | 157 | |
b32b8144 FG |
158 | parser.add_argument( |
159 | '--dmcrypt', | |
160 | action='store_true', | |
161 | help='Enable device encryption via dm-crypt', | |
162 | ) | |
3a9019d9 | 163 | |
94b18763 FG |
164 | parser.add_argument( |
165 | '--no-systemd', | |
166 | dest='no_systemd', | |
167 | action='store_true', | |
168 | help='Skip creating and enabling systemd units and starting OSD services when activating', | |
169 | ) | |
170 | ||
d2e6a577 FG |
171 | # Do not parse args, so that consumers can do something before the args get |
172 | # parsed triggering argparse behavior | |
173 | return parser | |
174 | ||
175 | ||
176 | create_parser = common_parser # noqa | |
177 | prepare_parser = common_parser # noqa |