]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
python-common: drivegroup: add 'method' property
authorSage Weil <sage@newdream.net>
Tue, 3 Aug 2021 18:35:27 +0000 (14:35 -0400)
committerAdam King <adking@redhat.com>
Tue, 17 May 2022 14:25:59 +0000 (10:25 -0400)
The DriveGroup method can be none, 'raw', or 'lvm'.

Signed-off-by: Sage Weil <sage@newdream.net>
(cherry picked from commit 81e46bc64472a88c493b26f5948ae29f71ebfbed)

 Conflicts:
src/python-common/ceph/deployment/drive_group.py

src/python-common/ceph/deployment/drive_group.py
src/python-common/ceph/deployment/translate.py

index 0f9788fe525ed81b6fb52422f897ba558bcae369..fac97e6efe49bb9d10f1c75b4485e292e0057e9d 100644 (file)
@@ -1,3 +1,4 @@
+import enum
 import yaml
 
 from ceph.deployment.inventory import Device
@@ -10,6 +11,11 @@ except ImportError:
     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
@@ -144,6 +150,7 @@ class DriveGroupSpec(ServiceSpec):
         "data_devices", "db_devices", "wal_devices", "journal_devices",
         "data_directories", "osds_per_device", "objectstore", "osd_id_claims",
         "journal_size", "unmanaged", "filter_logic", "preview_only", "extra_container_args",
+        "data_allocate_fraction", "method",
     ]
 
     def __init__(self,
@@ -168,6 +175,8 @@ class DriveGroupSpec(ServiceSpec):
                  filter_logic='AND',  # type: str
                  preview_only=False,  # type: bool
                  extra_container_args=None,  # type: Optional[List[str]]
+                 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,
@@ -227,6 +236,11 @@ class DriveGroupSpec(ServiceSpec):
         #: If this should be treated as a 'preview' spec
         self.preview_only = preview_only
 
+        #: 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
@@ -321,5 +335,10 @@ class DriveGroupSpec(ServiceSpec):
                 self.service_id,
                 'filter_logic must be either <AND> or <OR>')
 
+        if self.method not in [None, 'lvm', 'raw']:
+            raise DriveGroupValidationError(self.service_id, 'method must be one of None, lvm, raw')
+        if self.method == 'raw' and self.objectstore == 'filestore':
+            raise DriveGroupValidationError(self.service_id, 'method raw only supports bluestore')
+
 
 yaml.add_representer(DriveGroupSpec, DriveGroupSpec.yaml_representer)
index e5d59816626477877c132bbfce7ffb4a605bf4b2..4293a93a1c6ee85e7e82350f6249fc8466f917be 100644 (file)
@@ -36,7 +36,16 @@ class to_ceph_volume(object):
             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))
@@ -50,7 +59,7 @@ class to_ceph_volume(object):
 
             cmd += " --filestore"
 
-        if self.spec.objectstore == 'bluestore':
+        elif self.spec.objectstore == 'bluestore':
 
             cmd = "lvm batch --no-auto {}".format(" ".join(data_devices))
 
@@ -75,8 +84,9 @@ class to_ceph_volume(object):
         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"