nif ci fix complie in ci
This commit is contained in:
parent
b663d484cf
commit
25397139c1
9 changed files with 26 additions and 29 deletions
|
|
@ -26,7 +26,6 @@ defmodule Towerops.Snmp.AgentDiscovery do
|
|||
{:ok, %Device{}}
|
||||
"""
|
||||
|
||||
alias Ecto.Association.NotLoaded
|
||||
alias Towerops.Devices
|
||||
alias Towerops.Devices.Device, as: DeviceSchema
|
||||
alias Towerops.Snmp.Adapters.Replay
|
||||
|
|
@ -112,11 +111,7 @@ defmodule Towerops.Snmp.AgentDiscovery do
|
|||
end
|
||||
|
||||
defp count_interfaces(discovered_device) do
|
||||
case discovered_device.interfaces do
|
||||
%NotLoaded{} -> 0
|
||||
list when is_list(list) -> length(list)
|
||||
_ -> 0
|
||||
end
|
||||
length(discovered_device.interfaces)
|
||||
end
|
||||
|
||||
# Build connection opts for Replay adapter
|
||||
|
|
@ -141,7 +136,6 @@ defmodule Towerops.Snmp.AgentDiscovery do
|
|||
@spec count_sensors(DiscoveredDevice.t()) :: non_neg_integer()
|
||||
defp count_sensors(discovered_device) do
|
||||
case discovered_device.sensors do
|
||||
%NotLoaded{} -> 0
|
||||
list when is_list(list) -> length(list)
|
||||
_ -> 0
|
||||
end
|
||||
|
|
|
|||
|
|
@ -349,7 +349,7 @@ defmodule Towerops.Snmp.Discovery do
|
|||
results =
|
||||
Enum.reduce(device_list, %{enqueued: 0, failed: 0, errors: []}, fn device, acc ->
|
||||
case DiscoveryWorker.enqueue(device.id) do
|
||||
{:ok, _job} ->
|
||||
:ok ->
|
||||
%{acc | enqueued: acc.enqueued + 1}
|
||||
|
||||
{:error, reason} ->
|
||||
|
|
|
|||
|
|
@ -182,8 +182,6 @@ defmodule Towerops.Workers.DiscoveryWorker do
|
|||
|
||||
error
|
||||
end
|
||||
|
||||
result
|
||||
end
|
||||
|
||||
# Private helpers
|
||||
|
|
|
|||
|
|
@ -462,11 +462,12 @@ defmodule ToweropsWeb.AgentChannel do
|
|||
)
|
||||
|
||||
# Broadcast for real-time UI updates
|
||||
Phoenix.PubSub.broadcast(
|
||||
Towerops.PubSub,
|
||||
"device:#{device.id}",
|
||||
{:discovery_completed, device.id}
|
||||
)
|
||||
_ =
|
||||
Phoenix.PubSub.broadcast(
|
||||
Towerops.PubSub,
|
||||
"device:#{device.id}",
|
||||
{:discovery_completed, device.id}
|
||||
)
|
||||
|
||||
:ok
|
||||
|
||||
|
|
|
|||
|
|
@ -88,9 +88,10 @@ defmodule ToweropsWeb.Api.V1.DevicesController do
|
|||
case Devices.create_device(device_params, opts) do
|
||||
{:ok, device} ->
|
||||
# Trigger SNMP discovery if enabled
|
||||
if device.snmp_enabled do
|
||||
DiscoveryWorker.enqueue(device.id)
|
||||
end
|
||||
_ =
|
||||
if device.snmp_enabled do
|
||||
DiscoveryWorker.enqueue(device.id)
|
||||
end
|
||||
|
||||
conn
|
||||
|> put_status(:created)
|
||||
|
|
|
|||
|
|
@ -158,10 +158,11 @@ defmodule ToweropsWeb.DeviceLive.Show do
|
|||
# Private functions
|
||||
|
||||
defp maybe_subscribe_and_schedule_refresh(socket, device_id) do
|
||||
if connected?(socket) do
|
||||
_ = Phoenix.PubSub.subscribe(Towerops.PubSub, "device:#{device_id}")
|
||||
_ = Process.send_after(self(), :refresh_data, 10_000)
|
||||
end
|
||||
_ =
|
||||
if connected?(socket) do
|
||||
_ = Phoenix.PubSub.subscribe(Towerops.PubSub, "device:#{device_id}")
|
||||
Process.send_after(self(), :refresh_data, 10_000)
|
||||
end
|
||||
|
||||
:ok
|
||||
end
|
||||
|
|
|
|||
|
|
@ -57,9 +57,10 @@ defmodule ToweropsWeb.GraphLive.Show do
|
|||
end
|
||||
|
||||
defp maybe_subscribe_to_device(socket, device_id) do
|
||||
if connected?(socket) do
|
||||
_ = Phoenix.PubSub.subscribe(Towerops.PubSub, "device:#{device_id}")
|
||||
end
|
||||
_ =
|
||||
if connected?(socket) do
|
||||
Phoenix.PubSub.subscribe(Towerops.PubSub, "device:#{device_id}")
|
||||
end
|
||||
|
||||
:ok
|
||||
end
|
||||
|
|
|
|||
|
|
@ -26,9 +26,10 @@ defmodule ToweropsWeb.Plugs.UpdateSessionActivity do
|
|||
def call(conn, _opts) do
|
||||
token = get_session(conn, :user_token)
|
||||
|
||||
if token do
|
||||
_ = Task.start(fn -> update_session_activity(token) end)
|
||||
end
|
||||
_ =
|
||||
if token do
|
||||
Task.start(fn -> update_session_activity(token) end)
|
||||
end
|
||||
|
||||
conn
|
||||
end
|
||||
|
|
|
|||
2
mix.exs
2
mix.exs
|
|
@ -10,7 +10,7 @@ defmodule Towerops.MixProject do
|
|||
start_permanent: Mix.env() == :prod,
|
||||
aliases: aliases(),
|
||||
deps: deps(),
|
||||
compilers: [:phoenix_live_view] ++ Mix.compilers(),
|
||||
compilers: [:towerops_nif, :phoenix_live_view] ++ Mix.compilers(),
|
||||
listeners: [Phoenix.CodeReloader],
|
||||
dialyzer: dialyzer()
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue