]>
git.proxmox.com Git - ceph.git/blob - ceph/src/ceph-volume/ceph_volume/devices/lvm/create.py
1 from __future__
import print_function
2 from textwrap
import dedent
4 from ceph_volume
.util
import system
5 from ceph_volume
.util
.arg_validators
import exclude_group_options
6 from ceph_volume
import decorators
, terminal
7 from .common
import create_parser
, rollback_osd
8 from .prepare
import Prepare
9 from .activate
import Activate
11 logger
= logging
.getLogger(__name__
)
16 help = 'Create a new OSD from an LVM device'
18 def __init__(self
, argv
):
21 @decorators.needs_root
22 def create(self
, args
):
24 args
.osd_fsid
= system
.generate_uuid()
25 prepare_step
= Prepare([])
26 prepare_step
.safe_prepare(args
)
27 osd_id
= prepare_step
.osd_id
29 # we try this for activate only when 'creating' an OSD, because a rollback should not
30 # happen when doing normal activation. For example when starting an OSD, systemd will call
31 # activate, which would never need to be rolled back.
32 Activate([]).activate(args
)
34 logger
.error('lvm activate was unable to complete, while creating the OSD')
35 logger
.info('will rollback OSD ID creation')
36 rollback_osd(args
, osd_id
)
38 terminal
.success("ceph-volume lvm create successful for: %s" % args
.data
)
41 sub_command_help
= dedent("""
42 Create an OSD by assigning an ID and FSID, registering them with the
43 cluster with an ID and FSID, formatting and mounting the volume, adding
44 all the metadata to the logical volumes using LVM tags, and starting
47 Example calls for supported scenarios:
52 Existing logical volume (lv) or device:
54 ceph-volume lvm create --filestore --data {vg name/lv name} --journal /path/to/device
58 ceph-volume lvm create --filestore --data {vg name/lv name} --journal {vg name/lv name}
61 parser
= create_parser(
62 prog
='ceph-volume lvm create',
63 description
=sub_command_help
,
65 if len(self
.argv
) == 0:
66 print(sub_command_help
)
68 exclude_group_options(parser
, groups
=['filestore', 'bluestore'], argv
=self
.argv
)
69 args
= parser
.parse_args(self
.argv
)
70 # Default to bluestore here since defaulting it in add_argument may
71 # cause both to be True
72 if not args
.bluestore
and not args
.filestore
: