Improve function list_block_devices_check_skip_list

Fix minor issues suggested by dtantsur
Add an example of skip list specification to the documentation

A follow-up patch to I3bdad3cca8acb3e0a69ebb218216e8c8419e9d65

Change-Id: Ic94a33b7bc0572a1cc8f92b330474ec63a173e81
This commit is contained in:
Jakub Jelinek 2022-08-16 12:36:46 +00:00
parent 0212337bd5
commit 1ac61e1dbd
2 changed files with 20 additions and 25 deletions

View File

@ -113,10 +113,13 @@ unsafe conditions from occuring.
Devices Skip List Devices Skip List
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
A list of devices that Ironic does not touch during the cleaning process A list of devices that Ironic does not touch during the cleaning and deployment
can be specified in the node properties field under process can be specified in the node properties field under
``skip_block_devices``. This should be a list of dictionaries ``skip_block_devices``. This should be a list of dictionaries
containing hints to identify the drives. containing hints to identify the drives. For example::
'skip_block_devices': [{'name': '/dev/vda', 'vendor': '0x1af4'}]
Shared Disk Cluster Filesystems Shared Disk Cluster Filesystems
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -1396,28 +1396,20 @@ class GenericHardwareManager(HardwareManager):
include_partitions=include_partitions) include_partitions=include_partitions)
properties = node.get('properties', {}) properties = node.get('properties', {})
skip_list_hints = properties.get("skip_block_devices", []) skip_list_hints = properties.get("skip_block_devices", [])
if skip_list_hints is not None: if not skip_list_hints:
skip_list = None return block_devices
serialized_devs = [dev.serialize() for dev in block_devices] skip_list = set()
for hint in skip_list_hints: serialized_devs = [dev.serialize() for dev in block_devices]
found_devs = il_utils.find_devices_by_hints(serialized_devs, for hint in skip_list_hints:
hint) found_devs = il_utils.find_devices_by_hints(serialized_devs, hint)
excluded_devs = {dev['name'] for dev in found_devs} excluded_devs = {dev['name'] for dev in found_devs}
skipped_devices = None skipped_devices = excluded_devs.difference(skip_list)
if skip_list is None: skip_list = skip_list.union(excluded_devs)
skip_list = excluded_devs if skipped_devices:
skipped_devices = excluded_devs LOG.warning("Using hint %(hint)s skipping devices: %(devs)s",
else: {'hint': hint, 'devs': ','.join(skipped_devices)})
skipped_devices = excluded_devs.difference(skip_list) block_devices = [d for d in block_devices
skip_list = skip_list.union(excluded_devs) if d.name not in skip_list]
if skipped_devices is not None and len(skipped_devices) > 0:
for d in skipped_devices:
LOG.warning("Skipping device %(device)s "
"using hint %(hint)s",
{'device': d, 'hint': hint})
if skip_list is not None:
block_devices = [d for d in block_devices
if d.name not in skip_list]
return block_devices return block_devices
def get_os_install_device(self, permit_refresh=False): def get_os_install_device(self, permit_refresh=False):