From 4871bd3509fa3dfb2cf86c9c89ec4b0cd5e2a2ee Mon Sep 17 00:00:00 2001 From: Marc Gariepy Date: Tue, 22 Sep 2020 09:01:33 -0400 Subject: [PATCH] ceph-volume: remove unneeded call to get_devices() there is no need to probe the device to generate the argparse help message. also removing the test on the function as it's not there anymore. Signed-off-by: Marc Gariepy Fixes: https://tracker.ceph.com/issues/47502 (cherry picked from commit 5c6f66166a7afad87627032cafdc5c4f11f94eac) --- .../ceph_volume/devices/lvm/batch.py | 19 +------- .../tests/devices/lvm/test_batch.py | 48 ------------------- 2 files changed, 2 insertions(+), 65 deletions(-) diff --git a/src/ceph-volume/ceph_volume/devices/lvm/batch.py b/src/ceph-volume/ceph_volume/devices/lvm/batch.py index a83c8680bf336..4657b0deca7a2 100644 --- a/src/ceph-volume/ceph_volume/devices/lvm/batch.py +++ b/src/ceph-volume/ceph_volume/devices/lvm/batch.py @@ -3,7 +3,7 @@ import logging import json from textwrap import dedent from ceph_volume import terminal, decorators -from ceph_volume.util import disk, prompt_bool +from ceph_volume.util import prompt_bool from ceph_volume.util import arg_validators from . import strategies @@ -127,9 +127,6 @@ class Batch(object): _help = dedent(""" Automatically size devices ready for OSD provisioning based on default strategies. - Detected devices: - {detected_devices} - Usage: ceph-volume lvm batch [DEVICE...] @@ -143,7 +140,7 @@ class Batch(object): parser = argparse.ArgumentParser( prog='ceph-volume lvm batch', formatter_class=argparse.RawDescriptionHelpFormatter, - description=self.print_help(), + description=self._help, ) parser.add_argument( @@ -260,18 +257,6 @@ class Batch(object): for dev_list in ['', 'db_', 'wal_', 'journal_']: setattr(self, '{}usable'.format(dev_list), []) - def get_devices(self): - # remove devices with partitions - devices = [(device, details) for device, details in - disk.get_devices().items() if details.get('partitions') == {}] - size_sort = lambda x: (x[0], x[1]['size']) - return device_formatter(sorted(devices, key=size_sort)) - - def print_help(self): - return self._help.format( - detected_devices=self.get_devices(), - ) - def report(self): if self.args.format == 'pretty': self.strategy.report_pretty(self.filtered_devices) diff --git a/src/ceph-volume/ceph_volume/tests/devices/lvm/test_batch.py b/src/ceph-volume/ceph_volume/tests/devices/lvm/test_batch.py index 06a37c4906c25..a7fd52c47925e 100644 --- a/src/ceph-volume/ceph_volume/tests/devices/lvm/test_batch.py +++ b/src/ceph-volume/ceph_volume/tests/devices/lvm/test_batch.py @@ -9,54 +9,6 @@ class TestBatch(object): b = batch.Batch([]) b.main() - def test_get_devices(self, monkeypatch): - return_value = { - '/dev/vdd': { - 'removable': '0', - 'vendor': '0x1af4', - 'model': '', - 'sas_address': '', - 'sas_device_handle': '', - 'sectors': 0, - 'size': 21474836480.0, - 'support_discard': '', - 'partitions': { - 'vdd1': { - 'start': '2048', - 'sectors': '41940959', - 'sectorsize': 512, - 'size': '20.00 GB' - } - }, - 'rotational': '1', - 'scheduler_mode': 'mq-deadline', - 'sectorsize': '512', - 'human_readable_size': '20.00 GB', - 'path': '/dev/vdd' - }, - '/dev/vdf': { - 'removable': '0', - 'vendor': '0x1af4', - 'model': '', - 'sas_address': '', - 'sas_device_handle': '', - 'sectors': 0, - 'size': 21474836480.0, - 'support_discard': '', - 'partitions': {}, - 'rotational': '1', - 'scheduler_mode': 'mq-deadline', - 'sectorsize': '512', - 'human_readable_size': '20.00 GB', - 'path': '/dev/vdf' - } - } - monkeypatch.setattr('ceph_volume.devices.lvm.batch.disk.get_devices', - lambda: return_value) - b = batch.Batch([]) - result = b.get_devices().strip() - assert result == '* /dev/vdf 20.00 GB rotational' - def test_disjoint_device_lists(self, factory): device1 = factory(used_by_ceph=False, available=True, abspath="/dev/sda") device2 = factory(used_by_ceph=False, available=True, abspath="/dev/sdb") -- 2.39.5