]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/python-common/ceph/deployment/translate.py
import 15.2.2 octopus source
[ceph.git] / ceph / src / python-common / ceph / deployment / translate.py
index a09e7126971849e296c757805a1632676bafe998..2412e86186734a4d8b84f59edc815449e5f2ea49 100644 (file)
@@ -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