fix: Add device_id to interfaces for neighbor discovery in agent polling
Fixes KeyError when processing neighbor discovery during agent polling. NeighborDiscovery.discover_neighbors/2 requires interfaces to have a :device_id field for building neighbor records, but interfaces from the database only have :snmp_device_id. Solution matches the approach in DevicePollerWorker which adds device_id to interfaces before calling discover_neighbors.
This commit is contained in:
parent
f17ee2183c
commit
26e5d20510
1 changed files with 4 additions and 1 deletions
|
|
@ -951,8 +951,11 @@ defmodule ToweropsWeb.AgentChannel do
|
|||
# Fetch interfaces once for reuse across multiple operations
|
||||
interfaces = Towerops.Snmp.list_interfaces(device.snmp_device.id)
|
||||
|
||||
# Add device_id to interfaces for neighbor discovery (required by build_neighbor_record)
|
||||
interfaces_with_device_id = Enum.map(interfaces, &Map.put(&1, :device_id, device.id))
|
||||
|
||||
# Process neighbors (LLDP/CDP)
|
||||
case NeighborDiscovery.discover_neighbors(client_opts, interfaces) do
|
||||
case NeighborDiscovery.discover_neighbors(client_opts, interfaces_with_device_id) do
|
||||
{:ok, neighbors} when neighbors != [] ->
|
||||
Towerops.Snmp.Discovery.save_neighbors(device.id, neighbors)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue