]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: add new parameter '--list-all' to inventory
authorGuillaume Abrioux <gabrioux@ibm.com>
Tue, 8 Aug 2023 15:03:02 +0000 (15:03 +0000)
committerGuillaume Abrioux <gabrioux@ibm.com>
Tue, 5 Sep 2023 13:23:25 +0000 (15:23 +0200)
The inventory should report LV devices as they are valid devices that
can be used to be prepared as OSDs.

Fixes: https://tracker.ceph.com/issues/62362
Signed-off-by: Guillaume Abrioux <gabrioux@ibm.com>
(cherry picked from commit 605da29be9ef2903d4d84a624c4376963d6d8ed8)

src/ceph-volume/ceph_volume/inventory/main.py
src/ceph-volume/ceph_volume/util/device.py

index aa70e92f19d5c949af903952aacfefb8690bcee0..da0ff6c882ee5c639444fbc72636939134784cbc 100644 (file)
@@ -45,18 +45,27 @@ class Inventory(object):
                   'libstoragemgmt'),
             default=False,
         )
+        parser.add_argument(
+            '--list-all',
+            action='store_true',
+            help=('Whether ceph-volume should list lvm devices'),
+            default=False
+        )
         self.args = parser.parse_args(self.argv)
         if self.args.path:
             self.format_report(Device(self.args.path, with_lsm=self.args.with_lsm))
         else:
             self.format_report(Devices(filter_for_batch=self.args.filter_for_batch,
-                                       with_lsm=self.args.with_lsm))
+                                       with_lsm=self.args.with_lsm,
+                                       list_all=self.args.list_all))
 
     def get_report(self):
         if self.args.path:
             return Device(self.args.path, with_lsm=self.args.with_lsm).json_report()
         else:
-            return Devices(filter_for_batch=self.args.filter_for_batch, with_lsm=self.args.with_lsm).json_report()
+            return Devices(filter_for_batch=self.args.filter_for_batch,
+                           with_lsm=self.args.with_lsm,
+                           list_all=self.args.list_all).json_report()
 
     def format_report(self, inventory):
         if self.args.format == 'json':
index 5d9e2329a2588b9cbff8174452328de32d22aecc..349d0bd4de89b2ca82078e6980caf14cf8dc4f2e 100644 (file)
@@ -33,20 +33,28 @@ class Devices(object):
     A container for Device instances with reporting
     """
 
-    def __init__(self, filter_for_batch=False, with_lsm=False):
+    def __init__(self,
+                 filter_for_batch=False,
+                 with_lsm=False,
+                 list_all=False):
         lvs = lvm.get_lvs()
         lsblk_all = disk.lsblk_all()
         all_devices_vgs = lvm.get_all_devices_vgs()
         if not sys_info.devices:
             sys_info.devices = disk.get_devices()
-        self.devices = [Device(k,
-                               with_lsm,
-                               lvs=lvs,
-                               lsblk_all=lsblk_all,
-                               all_devices_vgs=all_devices_vgs) for k in
-                        sys_info.devices.keys()]
-        if filter_for_batch:
-            self.devices = [d for d in self.devices if d.available_lvm_batch]
+        self._devices = [Device(k,
+                                with_lsm,
+                                lvs=lvs,
+                                lsblk_all=lsblk_all,
+                                all_devices_vgs=all_devices_vgs) for k in
+                         sys_info.devices.keys()]
+        self.devices = []
+        for device in self._devices:
+            if filter_for_batch and not device.available_lvm_batch:
+                continue
+            if device.is_lv and not list_all:
+                continue
+            self.devices.append(device)
 
     def pretty_report(self):
         output = [