]>
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
import decorators
, terminal
6 from .common
import create_parser
, rollback_osd
7 from .prepare
import Prepare
8 from .activate
import Activate
10 logger
= logging
.getLogger(__name__
)
15 help = 'Create a new OSD from an LVM device'
17 def __init__(self
, argv
):
20 @decorators.needs_root
21 def create(self
, args
):
23 args
.osd_fsid
= system
.generate_uuid()
24 prepare_step
= Prepare([])
25 prepare_step
.safe_prepare(args
)
26 osd_id
= prepare_step
.osd_id
28 # we try this for activate only when 'creating' an OSD, because a rollback should not
29 # happen when doing normal activation. For example when starting an OSD, systemd will call
30 # activate, which would never need to be rolled back.
31 Activate([]).activate(args
)
33 logger
.error('lvm activate was unable to complete, while creating the OSD')
34 logger
.info('will rollback OSD ID creation')
35 rollback_osd(args
, osd_id
)
37 terminal
.success("ceph-volume lvm create successful for: %s" % args
.data
)
40 sub_command_help
= dedent("""
41 Create an OSD by assigning an ID and FSID, registering them with the
42 cluster with an ID and FSID, formatting and mounting the volume, adding
43 all the metadata to the logical volumes using LVM tags, and starting
46 Example calls for supported scenarios:
51 Existing logical volume (lv) or device:
53 ceph-volume lvm create --filestore --data {vg name/lv name} --journal /path/to/device
57 ceph-volume lvm create --filestore --data {vg name/lv name} --journal {vg name/lv name}
60 parser
= create_parser(
61 prog
='ceph-volume lvm create',
62 description
=sub_command_help
,
64 if len(self
.argv
) == 0:
65 print(sub_command_help
)
67 args
= parser
.parse_args(self
.argv
)
68 # Default to bluestore here since defaulting it in add_argument may
69 # cause both to be True
70 if not args
.bluestore
and not args
.filestore
: