import logging
try:
- from typing import Optional
+ from typing import Optional, List
except ImportError:
pass
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]
if not data_devices:
return None
+ cmd = ""
if self.spec.objectstore == 'filestore':
cmd = "lvm batch --no-auto"
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':
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