Ignore devices with size 0 when collecting inventory
delete_configuration still fetches all devices as it needs to clean ones with broken RAID. Story: #2007907 Task: #40307 Change-Id: I4b0be2b0755108490f9cd3c4f3b71a5e036761a1
This commit is contained in:
parent
9d9a6bce5c
commit
1f3b70c4e9
@ -294,7 +294,8 @@ def _md_scan_and_assemble():
|
|||||||
|
|
||||||
def list_all_block_devices(block_type='disk',
|
def list_all_block_devices(block_type='disk',
|
||||||
ignore_raid=False,
|
ignore_raid=False,
|
||||||
ignore_floppy=True):
|
ignore_floppy=True,
|
||||||
|
ignore_empty=True):
|
||||||
"""List all physical block devices
|
"""List all physical block devices
|
||||||
|
|
||||||
The switches we use for lsblk: P for KEY="value" output, b for size output
|
The switches we use for lsblk: P for KEY="value" output, b for size output
|
||||||
@ -310,6 +311,7 @@ def list_all_block_devices(block_type='disk',
|
|||||||
devices and should be treated as such if encountered.
|
devices and should be treated as such if encountered.
|
||||||
:param ignore_floppy: Ignore floppy disk devices in the block device
|
:param ignore_floppy: Ignore floppy disk devices in the block device
|
||||||
list. By default, these devices are filtered out.
|
list. By default, these devices are filtered out.
|
||||||
|
:param ignore_empty: Whether to ignore disks with size equal 0.
|
||||||
:return: A list of BlockDevices
|
:return: A list of BlockDevices
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -403,6 +405,12 @@ def list_all_block_devices(block_type='disk',
|
|||||||
LOG.debug('Skipping RAM device %s', device)
|
LOG.debug('Skipping RAM device %s', device)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# NOTE(dtantsur): some hardware represents virtual floppy devices as
|
||||||
|
# normal block devices with size 0. Filter them out.
|
||||||
|
if ignore_empty and not int(device['SIZE'] or 0):
|
||||||
|
LOG.debug('Skipping device %s with zero size', device)
|
||||||
|
continue
|
||||||
|
|
||||||
name = os.path.join('/dev', device['KNAME'])
|
name = os.path.join('/dev', device['KNAME'])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -1780,7 +1788,8 @@ class GenericHardwareManager(HardwareManager):
|
|||||||
utils.execute('mdadm', '--assemble', '--scan',
|
utils.execute('mdadm', '--assemble', '--scan',
|
||||||
check_exit_code=False)
|
check_exit_code=False)
|
||||||
raid_devices = list_all_block_devices(block_type='raid',
|
raid_devices = list_all_block_devices(block_type='raid',
|
||||||
ignore_raid=False)
|
ignore_raid=False,
|
||||||
|
ignore_empty=False)
|
||||||
return raid_devices
|
return raid_devices
|
||||||
|
|
||||||
raid_devices = _scan_raids()
|
raid_devices = _scan_raids()
|
||||||
|
@ -137,7 +137,8 @@ BLK_DEVICE_TEMPLATE = (
|
|||||||
'KNAME="ram1" 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="ram2" MODEL="" SIZE="8388608" ROTA="0" TYPE="disk"\n'
|
||||||
'KNAME="ram3" MODEL="" SIZE="8388608" ROTA="0" TYPE="disk"\n'
|
'KNAME="ram3" MODEL="" SIZE="8388608" ROTA="0" TYPE="disk"\n'
|
||||||
'KNAME="fd1" MODEL="magic" SIZE="4096" ROTA="1" TYPE="disk"'
|
'KNAME="fd1" MODEL="magic" SIZE="4096" ROTA="1" TYPE="disk"\n'
|
||||||
|
'KNAME="sdf" MODEL="virtual floppy" SIZE="0" ROTA="1" TYPE="disk"'
|
||||||
)
|
)
|
||||||
|
|
||||||
# NOTE(pas-ha) largest device is 1 byte smaller than 4GiB
|
# NOTE(pas-ha) largest device is 1 byte smaller than 4GiB
|
||||||
@ -168,7 +169,8 @@ RAID_BLK_DEVICE_TEMPLATE = (
|
|||||||
'KNAME="md0" MODEL="RAID" SIZE="1765517033470" '
|
'KNAME="md0" MODEL="RAID" SIZE="1765517033470" '
|
||||||
'ROTA="0" TYPE="raid1"\n'
|
'ROTA="0" TYPE="raid1"\n'
|
||||||
'KNAME="md0" MODEL="RAID" SIZE="1765517033470" '
|
'KNAME="md0" MODEL="RAID" SIZE="1765517033470" '
|
||||||
'ROTA="0" TYPE="raid1"'
|
'ROTA="0" TYPE="raid1"\n'
|
||||||
|
'KNAME="md1" MODEL="RAID" SIZE="" ROTA="0" TYPE="raid1"'
|
||||||
)
|
)
|
||||||
RAID_BLK_DEVICE_TEMPLATE_DEVICES = [
|
RAID_BLK_DEVICE_TEMPLATE_DEVICES = [
|
||||||
hardware.BlockDevice(name='/dev/sda', model='DRIVE 0',
|
hardware.BlockDevice(name='/dev/sda', model='DRIVE 0',
|
||||||
@ -180,6 +182,9 @@ RAID_BLK_DEVICE_TEMPLATE_DEVICES = [
|
|||||||
hardware.BlockDevice(name='/dev/md0', model='RAID',
|
hardware.BlockDevice(name='/dev/md0', model='RAID',
|
||||||
size=1765517033470, rotational=False,
|
size=1765517033470, rotational=False,
|
||||||
vendor="FooTastic"),
|
vendor="FooTastic"),
|
||||||
|
hardware.BlockDevice(name='/dev/md1', model='RAID',
|
||||||
|
size=0, rotational=False,
|
||||||
|
vendor="FooTastic"),
|
||||||
]
|
]
|
||||||
|
|
||||||
SHRED_OUTPUT_0_ITERATIONS_ZERO_FALSE = ()
|
SHRED_OUTPUT_0_ITERATIONS_ZERO_FALSE = ()
|
||||||
@ -4264,7 +4269,7 @@ class TestModuleFunctions(base.IronicAgentTest):
|
|||||||
mocked_readlink.return_value = '../../sda'
|
mocked_readlink.return_value = '../../sda'
|
||||||
mocked_fromdevfile.return_value = {}
|
mocked_fromdevfile.return_value = {}
|
||||||
mocked_execute.return_value = (RAID_BLK_DEVICE_TEMPLATE, '')
|
mocked_execute.return_value = (RAID_BLK_DEVICE_TEMPLATE, '')
|
||||||
result = hardware.list_all_block_devices()
|
result = hardware.list_all_block_devices(ignore_empty=False)
|
||||||
mocked_execute.assert_called_once_with(
|
mocked_execute.assert_called_once_with(
|
||||||
'lsblk', '-Pbia', '-oKNAME,MODEL,SIZE,ROTA,TYPE',
|
'lsblk', '-Pbia', '-oKNAME,MODEL,SIZE,ROTA,TYPE',
|
||||||
check_exit_code=[0])
|
check_exit_code=[0])
|
||||||
|
6
releasenotes/notes/zero-size-78d3be2ac8fd59c2.yaml
Normal file
6
releasenotes/notes/zero-size-78d3be2ac8fd59c2.yaml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Devices with size 0 are now ignored when collecting inventory. Some
|
||||||
|
hardware represents virtual floppy devices this way, see e.g.
|
||||||
|
https://www.dell.com/community/Systems-Management-General/How-to-disable-iDRAC-Virtual-CD/td-p/4734424
|
Loading…
Reference in New Issue
Block a user