From b98bc678b9dec6cc630f0d5573e8246464567129 Mon Sep 17 00:00:00 2001 From: Julia Kreger Date: Mon, 19 Aug 2019 15:17:53 -0400 Subject: [PATCH] Handle floppy disk controllers Cleaning presently fails on floopy disk controllers. While they may be uncommon in server hardware, they can exist in virtual machines, and even as virtual devices on some hardware chassises. Change-Id: I8ba07bfd5ca1e503f46c1bac4fffb5f509186939 Story: 2006419 Task: 36309 --- ironic_python_agent/hardware.py | 12 +++++++++++- ironic_python_agent/tests/unit/test_hardware.py | 3 ++- .../notes/handle-fd0-devices-3d1f31c3b34819e8.yaml | 11 +++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/handle-fd0-devices-3d1f31c3b34819e8.yaml diff --git a/ironic_python_agent/hardware.py b/ironic_python_agent/hardware.py index 721289ca3..627e2bdbd 100644 --- a/ironic_python_agent/hardware.py +++ b/ironic_python_agent/hardware.py @@ -236,7 +236,8 @@ def _md_scan_and_assemble(): def list_all_block_devices(block_type='disk', - ignore_raid=False): + ignore_raid=False, + ignore_floppy=True): """List all physical block devices The switches we use for lsblk: P for KEY="value" output, b for size output @@ -250,6 +251,8 @@ def list_all_block_devices(block_type='disk', :param ignore_raid: Ignore auto-identified raid devices, example: md0 Defaults to false as these are generally disk devices and should be treated as such if encountered. + :param ignore_floppy: Ignore floppy disk devices in the block device + list. By default, these devices are filtered out. :return: A list of BlockDevices """ @@ -305,6 +308,13 @@ def list_all_block_devices(block_type='disk', if _is_known_device(devices, device.get('KNAME')): continue + # If we collected the RM column, we could consult it for removable + # media, however USB devices are also flagged as removable media. + # we have to explicitly do this as floppy disks are type disk. + if ignore_floppy and str(device.get('KNAME')).startswith('fd'): + LOG.debug('Ignoring floppy disk device %s', device) + continue + # Search for raid in the reply type, as RAID is a # disk device, and we should honor it if is present. # Other possible type values, which we skip recording: diff --git a/ironic_python_agent/tests/unit/test_hardware.py b/ironic_python_agent/tests/unit/test_hardware.py index e35b485a4..5042d2acb 100644 --- a/ironic_python_agent/tests/unit/test_hardware.py +++ b/ironic_python_agent/tests/unit/test_hardware.py @@ -142,7 +142,8 @@ BLK_DEVICE_TEMPLATE = ( 'KNAME="ram0" MODEL="" SIZE="8388608" ROTA="0" TYPE="disk"\n' 'KNAME="ram1" MODEL="" SIZE="8388608" ROTA="0" TYPE="disk"\n' 'KNAME="ram2" MODEL="" SIZE="8388608" ROTA="0" TYPE="disk"\n' - 'KNAME="ram3" MODEL="" SIZE="8388608" ROTA="0" TYPE="disk"' + 'KNAME="ram3" MODEL="" SIZE="8388608" ROTA="0" TYPE="disk"\n' + 'KNAME="fd1" MODEL="magic" SIZE="4096" ROTA="1" TYPE="disk"' ) # NOTE(pas-ha) largest device is 1 byte smaller than 4GiB diff --git a/releasenotes/notes/handle-fd0-devices-3d1f31c3b34819e8.yaml b/releasenotes/notes/handle-fd0-devices-3d1f31c3b34819e8.yaml new file mode 100644 index 000000000..d21a0a7ad --- /dev/null +++ b/releasenotes/notes/handle-fd0-devices-3d1f31c3b34819e8.yaml @@ -0,0 +1,11 @@ +--- +fixes: + - | + Fixes cleaning operations when floppy disk devices are present on the + baremetal node. +other: + - | + The default ``list_all_block_devices`` hardware manager method has been + changed to ignore floppy disk devices. An argument ``ignore_floppy`` + with a default value of ``True``. A value of ``False`` may be passed + to the ``list_all_block_devices`` method to include such devices.