]>
git.proxmox.com Git - ceph.git/blob - ceph/src/python-common/ceph/deployment/translate.py
4 from typing
import Optional
, List
8 from ceph
.deployment
.drive_selection
.selector
import DriveSelection
10 logger
= logging
.getLogger(__name__
)
13 # TODO refactor this to a DriveSelection method
14 class to_ceph_volume(object):
17 selection
, # type: DriveSelection
18 osd_id_claims
=None, # type: Optional[List[str]]
19 preview
=False # type: bool
22 self
.selection
= selection
23 self
.spec
= selection
.spec
24 self
.preview
= preview
25 self
.osd_id_claims
= osd_id_claims
28 # type: () -> Optional[str]
29 """ Generate ceph-volume commands based on the DriveGroup filters """
30 data_devices
= [x
.path
for x
in self
.selection
.data_devices()]
31 db_devices
= [x
.path
for x
in self
.selection
.db_devices()]
32 wal_devices
= [x
.path
for x
in self
.selection
.wal_devices()]
33 journal_devices
= [x
.path
for x
in self
.selection
.journal_devices()]
39 if self
.spec
.method
== 'raw':
40 assert self
.spec
.objectstore
== 'bluestore'
41 cmd
= "raw prepare --bluestore"
42 cmd
+= " --data {}".format(" ".join(data_devices
))
44 cmd
+= " --block.db {}".format(" ".join(db_devices
))
46 cmd
+= " --block.wal {}".format(" ".join(wal_devices
))
48 elif self
.spec
.objectstore
== 'filestore':
49 cmd
= "lvm batch --no-auto"
51 cmd
+= " {}".format(" ".join(data_devices
))
53 if self
.spec
.journal_size
:
54 cmd
+= " --journal-size {}".format(self
.spec
.journal_size
)
57 cmd
+= " --journal-devices {}".format(
58 ' '.join(journal_devices
))
62 elif self
.spec
.objectstore
== 'bluestore':
64 cmd
= "lvm batch --no-auto {}".format(" ".join(data_devices
))
67 cmd
+= " --db-devices {}".format(" ".join(db_devices
))
70 cmd
+= " --wal-devices {}".format(" ".join(wal_devices
))
72 if self
.spec
.block_wal_size
:
73 cmd
+= " --block-wal-size {}".format(self
.spec
.block_wal_size
)
75 if self
.spec
.block_db_size
:
76 cmd
+= " --block-db-size {}".format(self
.spec
.block_db_size
)
78 if self
.spec
.encrypted
:
81 if self
.spec
.osds_per_device
:
82 cmd
+= " --osds-per-device {}".format(self
.spec
.osds_per_device
)
84 if self
.spec
.data_allocate_fraction
:
85 cmd
+= " --data-allocate-fraction {}".format(self
.spec
.data_allocate_fraction
)
87 if self
.osd_id_claims
:
88 cmd
+= " --osd-ids {}".format(" ".join(self
.osd_id_claims
))
90 if self
.spec
.method
!= 'raw':
92 cmd
+= " --no-systemd"
96 cmd
+= " --format json"