From: Guillaume Abrioux Date: Tue, 8 Aug 2023 15:03:02 +0000 (+0000) Subject: ceph-volume: add new parameter '--list-all' to inventory X-Git-Tag: v17.2.7~138^2~4 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=e1020fdd3a3f4d69dddd9052df43a46cd94f7dc4;p=ceph.git ceph-volume: add new parameter '--list-all' to inventory 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 (cherry picked from commit 605da29be9ef2903d4d84a624c4376963d6d8ed8) --- diff --git a/src/ceph-volume/ceph_volume/inventory/main.py b/src/ceph-volume/ceph_volume/inventory/main.py index aa70e92f19d5c..da0ff6c882ee5 100644 --- a/src/ceph-volume/ceph_volume/inventory/main.py +++ b/src/ceph-volume/ceph_volume/inventory/main.py @@ -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': diff --git a/src/ceph-volume/ceph_volume/util/device.py b/src/ceph-volume/ceph_volume/util/device.py index 5d9e2329a2588..349d0bd4de89b 100644 --- a/src/ceph-volume/ceph_volume/util/device.py +++ b/src/ceph-volume/ceph_volume/util/device.py @@ -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 = [