fix: Use snmp_device.id for sync_processors and sync_storage

Fixes KeyError when processing processors/storage during agent polling.
The sync_processors and sync_storage functions expect device.id to be
the snmp_device id, not the main device id.

Changed from:
  %{device_id: device.id}

To:
  %{id: device.snmp_device.id}

This matches the expected structure for these sync functions which
query where snmp_device_id == device.id.
This commit is contained in:
Graham McIntire 2026-02-06 12:06:30 -06:00 committed by Graham McIntire
parent c6ec9ab891
commit 184c2bc999
No known key found for this signature in database

View file

@ -998,7 +998,7 @@ defmodule ToweropsWeb.AgentChannel do
# Process processors
case Base.discover_processors(client_opts) do
{:ok, processors} when processors != [] ->
discovered_device = %{device_id: device.id}
discovered_device = %{id: device.snmp_device.id}
Towerops.Snmp.Discovery.sync_processors(discovered_device, processors)
_ ->
@ -1008,7 +1008,7 @@ defmodule ToweropsWeb.AgentChannel do
# Process storage
case Base.discover_storage(client_opts) do
{:ok, storage} when storage != [] ->
discovered_device = %{device_id: device.id}
discovered_device = %{id: device.snmp_device.id}
Towerops.Snmp.Discovery.sync_storage(discovered_device, storage)
_ ->