fix: report a better error in validate-interfaces

When validate-interfaces runs if there is no interfaces key then we
would just have a KeyError exception that would be logged to the node.
This provides a clearer message back as to why this happened.

Change-Id: I307848a9a1733ecff534ae37541e59465b4e96b7
Signed-off-by: Doug Goldstein <cardoe@cardoe.com>
(cherry picked from commit d56a70e8ab)
This commit is contained in:
Doug Goldstein 2026-01-06 09:04:26 -06:00
parent 1fd21b19d8
commit e8de78ece7
2 changed files with 10 additions and 0 deletions

View file

@ -49,6 +49,11 @@ def get_interfaces(node, inventory):
result = {}
pxe_mac = get_pxe_mac(inventory)
if 'interfaces' not in inventory:
raise exception.InvalidNodeInventory(
node=node.uuid,
reason=_('no interfaces present in inventory'))
for iface in inventory['interfaces']:
name = iface.get('name')
mac = iface.get('mac_address')

View file

@ -0,0 +1,5 @@
---
fixes:
- |
Report a better error message than a KeyError when there are no interfaces
in the inspection data when running the validate-interfaces inspection hook.