+import enum
import yaml
from ceph.deployment.inventory import Device
pass
+class OSDMethod(str, enum.Enum):
+ raw = 'raw'
+ lvm = 'lvm'
+
+
class DeviceSelection(object):
"""
Used within :class:`ceph.deployment.drive_group.DriveGroupSpec` to specify the devices
"data_devices", "db_devices", "wal_devices", "journal_devices",
"data_directories", "osds_per_device", "objectstore", "osd_id_claims",
"journal_size", "unmanaged", "filter_logic", "preview_only",
- "data_allocate_fraction"
+ "data_allocate_fraction", "method"
]
def __init__(self,
filter_logic='AND', # type: str
preview_only=False, # type: bool
data_allocate_fraction=None, # type: Optional[float]
+ method=None, # type: Optional[OSDMethod]
):
assert service_type is None or service_type == 'osd'
super(DriveGroupSpec, self).__init__('osd', service_id=service_id,
#: Allocate a fraction of the data device (0,1.0]
self.data_allocate_fraction = data_allocate_fraction
+ self.method = method
+
@classmethod
def _from_json_impl(cls, json_drive_group):
# type: (dict) -> DriveGroupSpec
if self.filter_logic not in ['AND', 'OR']:
raise DriveGroupValidationError('filter_logic must be either <AND> or <OR>')
+ if self.method not in [None, 'lvm', 'raw']:
+ raise DriveGroupValidationError('method must be one of None, lvm, raw')
+ if self.method == 'raw' and self.objectstore == 'filestore':
+ raise DriveGroupValidationError('method raw only supports bluestore')
+
def __repr__(self) -> str:
keys = [
key for key in self._supported_features if getattr(self, key) is not None
return None
cmd = ""
- if self.spec.objectstore == 'filestore':
+ if self.spec.method == 'raw':
+ assert self.spec.objectstore == 'bluestore'
+ cmd = "raw prepare --bluestore"
+ cmd += " --data {}".format(" ".join(data_devices))
+ if db_devices:
+ cmd += " --block.db {}".format(" ".join(db_devices))
+ if wal_devices:
+ cmd += " --block.wal {}".format(" ".join(wal_devices))
+
+ elif self.spec.objectstore == 'filestore':
cmd = "lvm batch --no-auto"
cmd += " {}".format(" ".join(data_devices))
cmd += " --filestore"
- if self.spec.objectstore == 'bluestore':
+ elif self.spec.objectstore == 'bluestore':
cmd = "lvm batch --no-auto {}".format(" ".join(data_devices))
if self.osd_id_claims:
cmd += " --osd-ids {}".format(" ".join(self.osd_id_claims))
- cmd += " --yes"
- cmd += " --no-systemd"
+ if self.spec.method != 'raw':
+ cmd += " --yes"
+ cmd += " --no-systemd"
if self.preview:
cmd += " --report"