Skip to content

Commit fdd5c6b

Browse files
committed
Don't put None values in local_link_info - abort if its incomplete
1 parent 8fa443f commit fdd5c6b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

python/ironic-understack/ironic_understack/update_baremetal_port.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,12 @@ def _parse_lldp(lldp_data: LldpData, node_id: str) -> dict[str, str]:
102102
decoded[tlv_type] = []
103103
decoded[tlv_type].append(bytearray(binascii.unhexlify(tlv_value)))
104104

105-
local_link = {
106-
"port_id": _extract_port_id(decoded),
107-
"switch_id": _extract_switch_id(decoded),
108-
"switch_info": _extract_hostname(decoded),
109-
}
110-
return { k: v for k, v in local_link.items() if v }
105+
port_id = _extract_port_id(decoded)
106+
switch_id = _extract_switch_id(decoded)
107+
switch_info = _extract_hostname(decoded)
108+
if port_id and switch_id and switch_info:
109+
return {"port_id": port_id, "switch_id": switch_id, "switch_info": switch_info}
110+
LOG.warning("Failed to extract local_link_info from LLDP data for %s", node_id)
111111
except (binascii.Error, core.MappingError, netaddr.AddrFormatError) as e:
112112
LOG.warning("Failed to parse lldp_raw data for Node %s: %s", node_id, e)
113113
return {}

0 commit comments

Comments
 (0)