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
This commit is contained in:
Julia Kreger 2019-08-19 15:17:53 -04:00
parent 95e5468ab0
commit b98bc678b9
3 changed files with 24 additions and 2 deletions
ironic_python_agent
releasenotes/notes

@ -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:

@ -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

@ -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.