X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ceph%2Fsrc%2Fpython-common%2Fceph%2Fdeployment%2Ftranslate.py;h=2412e86186734a4d8b84f59edc815449e5f2ea49;hb=1911f103e16ae0d04db10fb41db8217ef4c320d3;hp=a09e7126971849e296c757805a1632676bafe998;hpb=78f773100ed5d2ebc9d99e65a3d7e3a6f541a97e;p=ceph.git diff --git a/ceph/src/python-common/ceph/deployment/translate.py b/ceph/src/python-common/ceph/deployment/translate.py index a09e71269..2412e8618 100644 --- a/ceph/src/python-common/ceph/deployment/translate.py +++ b/ceph/src/python-common/ceph/deployment/translate.py @@ -1,7 +1,7 @@ import logging try: - from typing import Optional + from typing import Optional, List except ImportError: pass @@ -15,11 +15,15 @@ class to_ceph_volume(object): def __init__(self, spec, # type: DriveGroupSpec - selection # type: DriveSelection + selection, # type: DriveSelection + osd_id_claims=None, # type: Optional[List[str]] + preview=False # type: bool ): self.spec = spec self.selection = selection + self.preview = preview + self.osd_id_claims = osd_id_claims def run(self): # type: () -> Optional[str] @@ -32,6 +36,7 @@ class to_ceph_volume(object): if not data_devices: return None + cmd = "" if self.spec.objectstore == 'filestore': cmd = "lvm batch --no-auto" @@ -54,6 +59,14 @@ class to_ceph_volume(object): not db_devices and \ not wal_devices: cmd = "lvm prepare --bluestore --data %s --no-systemd" % (' '.join(data_devices)) + if self.osd_id_claims: + cmd += " --osd-id {}".format(str(self.osd_id_claims[0])) + if self.preview: + # Like every horrible hack, this has sideffects on other features. + # In this case, 'lvm prepare' has neither a '--report' nor a '--format json' option + # which essentially doesn't allow for a proper previews here. + # Fall back to lvm batch in order to get a preview. + return f"lvm batch --no-auto {' '.join(data_devices)} --report --format json" return cmd if self.spec.objectstore == 'bluestore': @@ -78,7 +91,14 @@ class to_ceph_volume(object): if self.spec.osds_per_device: cmd += " --osds-per-device {}".format(self.spec.osds_per_device) + if self.osd_id_claims: + cmd += " --osd-ids {}".format(" ".join(self.osd_id_claims)) + cmd += " --yes" cmd += " --no-systemd" + if self.preview: + cmd += " --report" + cmd += " --format json" + return cmd