Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / ceph-volume / ceph_volume / devices / lvm / create.py
1 from __future__ import print_function
2 from textwrap import dedent
3 from ceph_volume.util import system
4 from ceph_volume import decorators
5 from .common import create_parser
6 from .prepare import Prepare
7 from .activate import Activate
8
9
10 class Create(object):
11
12     help = 'Create a new OSD from  an LVM device'
13
14     def __init__(self, argv):
15         self.argv = argv
16
17     @decorators.needs_root
18     def create(self, args):
19         if not args.osd_fsid:
20             args.osd_fsid = system.generate_uuid()
21         Prepare([]).prepare(args)
22         Activate([]).activate(args)
23
24     def main(self):
25         sub_command_help = dedent("""
26         Create an OSD by assigning an ID and FSID, registering them with the
27         cluster with an ID and FSID, formatting and mounting the volume, adding
28         all the metadata to the logical volumes using LVM tags, and starting
29         the OSD daemon.
30
31         Example calls for supported scenarios:
32
33         Filestore
34         ---------
35
36           Existing logical volume (lv) or device:
37
38               ceph-volume lvm create --filestore --data {vg name/lv name} --journal /path/to/device
39
40           Or:
41
42               ceph-volume lvm create --filestore --data {vg name/lv name} --journal {vg name/lv name}
43
44         """)
45         parser = create_parser(
46             prog='ceph-volume lvm create',
47             description=sub_command_help,
48         )
49         if len(self.argv) == 0:
50             print(sub_command_help)
51             return
52         args = parser.parse_args(self.argv)
53         # Default to bluestore here since defaulting it in add_argument may
54         # cause both to be True
55         if args.bluestore is None and args.filestore is None:
56             args.bluestore = True
57         self.create(args)