Improve device hints logging

1) Log which hints matches the final root device
2) Log each rejection for easier debugging
3) Remove mentions of "root" from find_devices_by_hints, it's going
   to be also used for RAID ddevices.

Change-Id: I90e39f9a9bc9f690d0453bfe00cea8c08e8dbda1
This commit is contained in:
Dmitry Tantsur 2020-03-10 12:26:43 +01:00
parent 380038c131
commit cb19b075a9
1 changed files with 12 additions and 7 deletions

View File

@ -357,7 +357,7 @@ def find_devices_by_hints(devices, root_device_hints):
:returns: A generator with all matching devices as dictionaries.
"""
LOG.debug('Trying to find devices from "%(devs)s" that match the '
'root device hints "%(hints)s"',
'device hints "%(hints)s"',
{'devs': ', '.join([d.get('name') for d in devices]),
'hints': root_device_hints})
parsed_hints = parse_root_device_hints(root_device_hints)
@ -385,7 +385,7 @@ def find_devices_by_hints(devices, root_device_hints):
# in GiB for now
device_value = device_value / units.Gi
LOG.debug('Trying to match the root device hint "%(hint)s" '
LOG.debug('Trying to match the device hint "%(hint)s" '
'with a value of "%(hint_value)s" against the same '
'device\'s (%(dev)s) attribute with a value of '
'"%(dev_value)s"', {'hint': hint, 'dev': device_name,
@ -408,10 +408,15 @@ def find_devices_by_hints(devices, root_device_hints):
break
if device_value == hint_value:
continue
break
if not specs_matcher.match(device_value, hint_value):
break
elif specs_matcher.match(device_value, hint_value):
continue
LOG.debug('The attribute "%(attr)s" (with value "%(value)s") '
'of device "%(dev)s" does not match the hint %(hint)s',
{'attr': hint, 'value': device_value,
'dev': device_name, 'hint': hint_value})
break
else:
yield dev
@ -452,8 +457,8 @@ def match_root_device_hints(devices, root_device_hints):
LOG.warning('No device found that matches the root device hints %s',
root_device_hints)
else:
LOG.info('Device found! The device "%s" matches the root '
'device hints', dev)
LOG.info('Root device found! The device "%s" matches the root '
'device hints %s', dev, root_device_hints)
return dev