Skip to content

Commit c8c6c41

Browse files
authored
Fix LLDP report for single-interface hosts (#2122)
lldpctl returns a dict instead of a list when only one interface has LLDP neighbors. Normalize the interface data to always be a list so iteration works in both cases. AI-assisted: Claude Code Signed-off-by: Christian Berendt <berendt@osism.tech>
1 parent 0a6b540 commit c8c6c41

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

osism/commands/report.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,12 @@ def take_action(self, parsed_args):
241241
continue
242242

243243
lldp_data = json.loads(lldp_result.stdout)
244-
interfaces = lldp_data.get("lldp", {}).get("interface", [])
244+
interfaces = lldp_data.get("lldp", {}).get("interface", {})
245+
246+
# lldpctl returns a list of dicts for multiple interfaces,
247+
# but a single dict for one interface. Normalize to list.
248+
if isinstance(interfaces, dict):
249+
interfaces = [{k: v} for k, v in interfaces.items()]
245250

246251
for iface_entry in interfaces:
247252
for local_iface, iface_data in iface_entry.items():

0 commit comments

Comments
 (0)