diff --git a/ironic_python_agent/hardware.py b/ironic_python_agent/hardware.py index 00b33865a..fbba74e60 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 35c1cb03e..dcb890dcd 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.