]>
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_group
import DriveGroupSpec
9 from ceph
.deployment
.drive_selection
.selector
import DriveSelection
11 logger
= logging
.getLogger(__name__
)
14 class to_ceph_volume(object):
17 spec
, # type: DriveGroupSpec
18 selection
, # type: DriveSelection
19 osd_id_claims
=None, # type: Optional[List[str]]
20 preview
=False # type: bool
24 self
.selection
= selection
25 self
.preview
= preview
26 self
.osd_id_claims
= osd_id_claims
29 # type: () -> Optional[str]
30 """ Generate ceph-volume commands based on the DriveGroup filters """
31 data_devices
= [x
.path
for x
in self
.selection
.data_devices()]
32 db_devices
= [x
.path
for x
in self
.selection
.db_devices()]
33 wal_devices
= [x
.path
for x
in self
.selection
.wal_devices()]
34 journal_devices
= [x
.path
for x
in self
.selection
.journal_devices()]
40 if self
.spec
.objectstore
== 'filestore':
41 cmd
= "lvm batch --no-auto"
43 cmd
+= " {}".format(" ".join(data_devices
))
45 if self
.spec
.journal_size
:
46 cmd
+= " --journal-size {}".format(self
.spec
.journal_size
)
49 cmd
+= " --journal-devices {}".format(
50 ' '.join(journal_devices
))
55 if self
.spec
.objectstore
== 'bluestore' and \
56 not self
.spec
.encrypted
and \
57 not self
.spec
.osds_per_device
and \
58 len(data_devices
) == 1 and \
61 cmd
= "lvm prepare --bluestore --data %s --no-systemd" % (' '.join(data_devices
))
62 if self
.osd_id_claims
:
63 cmd
+= " --osd-id {}".format(str(self
.osd_id_claims
[0]))
65 # Like every horrible hack, this has sideffects on other features.
66 # In this case, 'lvm prepare' has neither a '--report' nor a '--format json' option
67 # which essentially doesn't allow for a proper previews here.
68 # Fall back to lvm batch in order to get a preview.
69 return f
"lvm batch --no-auto {' '.join(data_devices)} --report --format json"
72 if self
.spec
.objectstore
== 'bluestore':
74 cmd
= "lvm batch --no-auto {}".format(" ".join(data_devices
))
77 cmd
+= " --db-devices {}".format(" ".join(db_devices
))
80 cmd
+= " --wal-devices {}".format(" ".join(wal_devices
))
82 if self
.spec
.block_wal_size
:
83 cmd
+= " --block-wal-size {}".format(self
.spec
.block_wal_size
)
85 if self
.spec
.block_db_size
:
86 cmd
+= " --block-db-size {}".format(self
.spec
.block_db_size
)
88 if self
.spec
.encrypted
:
91 if self
.spec
.osds_per_device
:
92 cmd
+= " --osds-per-device {}".format(self
.spec
.osds_per_device
)
94 if self
.osd_id_claims
:
95 cmd
+= " --osd-ids {}".format(" ".join(self
.osd_id_claims
))
98 cmd
+= " --no-systemd"
102 cmd
+= " --format json"