1 from ceph_volume
.util
import arg_validators
2 from ceph_volume
import process
, conf
3 from ceph_volume
import terminal
7 def rollback_osd(args
, osd_id
=None):
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
14 The usage of `destroy-new` allows this to be done without requiring the
15 admin keyring (otherwise needed for destroy and purge commands)
18 # it means that it wasn't generated, so there is nothing to rollback here
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')
24 bootstrap_keyring
= '/var/lib/ceph/bootstrap-osd/%s.keyring' % conf
.cluster
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',
37 def common_parser(prog
, description
):
39 Both prepare and create share the same parser, those are defined here to
42 parser
= argparse
.ArgumentParser(
44 formatter_class
=argparse
.RawDescriptionHelpFormatter
,
45 description
=description
,
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')
52 required_group
.add_argument(
55 type=arg_validators
.ValidDevice(as_string
=True),
56 help='OSD data path. A physical device or logical volume',
59 filestore_group
.add_argument(
62 help='Use the filestore objectstore',
65 filestore_group
.add_argument(
67 help='(REQUIRED) A logical volume (vg_name/lv_name), or path to a device',
70 bluestore_group
.add_argument(
73 help='Use the bluestore objectstore',
76 bluestore_group
.add_argument(
79 help='Path to bluestore block.db logical volume or device',
82 bluestore_group
.add_argument(
85 help='Path to bluestore block.wal logical volume or device',
90 help='Reuse an existing OSD id',
95 help='Reuse an existing OSD fsid',
100 help='Specify the cluster fsid, useful when no ceph.conf is available',
104 '--crush-device-class',
105 dest
='crush_device_class',
106 help='Crush device class to assign this OSD to',
112 help='Enable device encryption via dm-crypt',
119 help='Skip creating and enabling systemd units and starting OSD services when activating',
122 # Do not parse args, so that consumers can do something before the args get
123 # parsed triggering argparse behavior
127 create_parser
= common_parser
# noqa
128 prepare_parser
= common_parser
# noqa