]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume inventory: make libstoragemgmt data retrieval optional 38149/head
authorJan Fajerski <jfajerski@suse.com>
Wed, 18 Nov 2020 08:37:48 +0000 (09:37 +0100)
committerJan Fajerski <jfajerski@suse.com>
Wed, 25 Nov 2020 21:19:00 +0000 (22:19 +0100)
Default to not retrieving libstoragemgmt data since it seems this can
cause serious issues on older hardware. Safest way is to only retrieve
lsm data when the user opts in..

Fixes: https://tracker.ceph.com/issues/48270
Signed-off-by: Jan Fajerski <jfajerski@suse.com>
src/ceph-volume/ceph_volume/inventory/main.py
src/ceph-volume/ceph_volume/util/device.py

index 7053a3ebf8f83e83ad5373e7f99791af7c4c1305..aa70e92f19d5c949af903952aacfefb8690bcee0 100644 (file)
@@ -38,17 +38,25 @@ class Inventory(object):
                   'no effect when <path> is passed'),
             default=False,
         )
+        parser.add_argument(
+            '--with-lsm',
+            action='store_true',
+            help=('Attempt to retrieve additional health and metadata through '
+                  'libstoragemgmt'),
+            default=False,
+        )
         self.args = parser.parse_args(self.argv)
         if self.args.path:
-            self.format_report(Device(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))
+            self.format_report(Devices(filter_for_batch=self.args.filter_for_batch,
+                                       with_lsm=self.args.with_lsm))
 
     def get_report(self):
         if self.args.path:
-            return Device(self.args.path).json_report()
+            return Device(self.args.path, with_lsm=self.args.with_lsm).json_report()
         else:
-            return Devices(filter_for_batch=self.args.filter_for_batch).json_report()
+            return Devices(filter_for_batch=self.args.filter_for_batch, with_lsm=self.args.with_lsm).json_report()
 
     def format_report(self, inventory):
         if self.args.format == 'json':
index 708227e831413581fef6e10ddd587100e96926f3..193a72f3d008cfeda1aeacef63cc2d816d8327a2 100644 (file)
@@ -27,10 +27,10 @@ class Devices(object):
     A container for Device instances with reporting
     """
 
-    def __init__(self, filter_for_batch=False):
+    def __init__(self, filter_for_batch=False, with_lsm=False):
         if not sys_info.devices:
             sys_info.devices = disk.get_devices()
-        self.devices = [Device(k) for k in
+        self.devices = [Device(k, with_lsm) for k in
                             sys_info.devices.keys()]
         if filter_for_batch:
             self.devices = [d for d in self.devices if d.available_lvm_batch]
@@ -83,7 +83,7 @@ class Device(object):
     # unittests
     lvs = []
 
-    def __init__(self, path):
+    def __init__(self, path, with_lsm=False):
         self.path = path
         # LVs can have a vg/lv path, while disks will have /dev/sda
         self.abspath = path
@@ -98,7 +98,7 @@ class Device(object):
         self._exists = None
         self._is_lvm_member = None
         self._parse()
-        self.lsm_data = self.fetch_lsm()
+        self.lsm_data = self.fetch_lsm(with_lsm)
 
         self.available_lvm, self.rejected_reasons_lvm = self._check_lvm_reject_reasons()
         self.available_raw, self.rejected_reasons_raw = self._check_raw_reject_reasons()
@@ -108,7 +108,7 @@ class Device(object):
 
         self.device_id = self._get_device_id()
 
-    def fetch_lsm(self):
+    def fetch_lsm(self, with_lsm):
         '''
         Attempt to fetch libstoragemgmt (LSM) metadata, and return to the caller
         as a dict. An empty dict is passed back to the caller if the target path
@@ -116,11 +116,11 @@ class Device(object):
         json returned will provide LSM attributes, and any associated errors that
         lsm encountered when probing the device.
         '''
-        if not self.exists or not self.is_device:
+        if not with_lsm or not self.exists or not self.is_device:
             return {}
 
         lsm_disk = LSMDisk(self.path)
-        
+
         return  lsm_disk.json_report()
 
     def __lt__(self, other):