Skip to content

Commit 1ac61e1

Browse files
committed
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
1 parent 0212337 commit 1ac61e1

File tree

2 files changed

+20
-25
lines changed

2 files changed

+20
-25
lines changed

doc/source/admin/hardware_managers.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,13 @@ unsafe conditions from occuring.
113113
Devices Skip List
114114
~~~~~~~~~~~~~~~~~
115115

116-
A list of devices that Ironic does not touch during the cleaning process
117-
can be specified in the node properties field under
116+
A list of devices that Ironic does not touch during the cleaning and deployment
117+
process can be specified in the node properties field under
118118
``skip_block_devices``. This should be a list of dictionaries
119-
containing hints to identify the drives.
119+
containing hints to identify the drives. For example::
120+
121+
'skip_block_devices': [{'name': '/dev/vda', 'vendor': '0x1af4'}]
122+
120123

121124
Shared Disk Cluster Filesystems
122125
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ironic_python_agent/hardware.py

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,28 +1396,20 @@ def list_block_devices_check_skip_list(self, node,
13961396
include_partitions=include_partitions)
13971397
properties = node.get('properties', {})
13981398
skip_list_hints = properties.get("skip_block_devices", [])
1399-
if skip_list_hints is not None:
1400-
skip_list = None
1401-
serialized_devs = [dev.serialize() for dev in block_devices]
1402-
for hint in skip_list_hints:
1403-
found_devs = il_utils.find_devices_by_hints(serialized_devs,
1404-
hint)
1405-
excluded_devs = {dev['name'] for dev in found_devs}
1406-
skipped_devices = None
1407-
if skip_list is None:
1408-
skip_list = excluded_devs
1409-
skipped_devices = excluded_devs
1410-
else:
1411-
skipped_devices = excluded_devs.difference(skip_list)
1412-
skip_list = skip_list.union(excluded_devs)
1413-
if skipped_devices is not None and len(skipped_devices) > 0:
1414-
for d in skipped_devices:
1415-
LOG.warning("Skipping device %(device)s "
1416-
"using hint %(hint)s",
1417-
{'device': d, 'hint': hint})
1418-
if skip_list is not None:
1419-
block_devices = [d for d in block_devices
1420-
if d.name not in skip_list]
1399+
if not skip_list_hints:
1400+
return block_devices
1401+
skip_list = set()
1402+
serialized_devs = [dev.serialize() for dev in block_devices]
1403+
for hint in skip_list_hints:
1404+
found_devs = il_utils.find_devices_by_hints(serialized_devs, hint)
1405+
excluded_devs = {dev['name'] for dev in found_devs}
1406+
skipped_devices = excluded_devs.difference(skip_list)
1407+
skip_list = skip_list.union(excluded_devs)
1408+
if skipped_devices:
1409+
LOG.warning("Using hint %(hint)s skipping devices: %(devs)s",
1410+
{'hint': hint, 'devs': ','.join(skipped_devices)})
1411+
block_devices = [d for d in block_devices
1412+
if d.name not in skip_list]
14211413
return block_devices
14221414

14231415
def get_os_install_device(self, permit_refresh=False):

0 commit comments

Comments
 (0)