]> git.proxmox.com Git - ceph.git/blob - ceph/src/ceph-volume/ceph_volume/devices/lvm/common.py
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / ceph-volume / ceph_volume / devices / lvm / common.py
1 from ceph_volume.util import arg_validators
2 from ceph_volume import process, conf
3 from ceph_volume import terminal
4 import argparse
5
6
7 def rollback_osd(args, osd_id=None):
8 """
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)
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'
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)
35
36
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 )
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(
53 '--data',
54 required=True,
55 type=arg_validators.ValidDevice(as_string=True),
56 help='OSD data path. A physical device or logical volume',
57 )
58
59 filestore_group.add_argument(
60 '--filestore',
61 action='store_true',
62 help='Use the filestore objectstore',
63 )
64
65 filestore_group.add_argument(
66 '--journal',
67 help='(REQUIRED) A logical volume (vg_name/lv_name), or path to a device',
68 )
69
70 bluestore_group.add_argument(
71 '--bluestore',
72 action='store_true',
73 help='Use the bluestore objectstore',
74 )
75
76 bluestore_group.add_argument(
77 '--block.db',
78 dest='block_db',
79 help='Path to bluestore block.db logical volume or device',
80 )
81
82 bluestore_group.add_argument(
83 '--block.wal',
84 dest='block_wal',
85 help='Path to bluestore block.wal logical volume or device',
86 )
87
88 parser.add_argument(
89 '--osd-id',
90 help='Reuse an existing OSD id',
91 )
92
93 parser.add_argument(
94 '--osd-fsid',
95 help='Reuse an existing OSD fsid',
96 )
97
98 parser.add_argument(
99 '--cluster-fsid',
100 help='Specify the cluster fsid, useful when no ceph.conf is available',
101 )
102
103 parser.add_argument(
104 '--crush-device-class',
105 dest='crush_device_class',
106 help='Crush device class to assign this OSD to',
107 )
108
109 parser.add_argument(
110 '--dmcrypt',
111 action='store_true',
112 help='Enable device encryption via dm-crypt',
113 )
114
115 parser.add_argument(
116 '--no-systemd',
117 dest='no_systemd',
118 action='store_true',
119 help='Skip creating and enabling systemd units and starting OSD services when activating',
120 )
121
122 # Do not parse args, so that consumers can do something before the args get
123 # parsed triggering argparse behavior
124 return parser
125
126
127 create_parser = common_parser # noqa
128 prepare_parser = common_parser # noqa