Reload host pools when changing pools in v2/set/pool/members.lua

This commit is contained in:
Alfredo Cardigliano 2024-03-06 09:29:51 +01:00
parent ef881b43f1
commit 55d4334423

View file

@ -44,6 +44,7 @@ sendHTTPContentTypeHeader('application/json')
--]]
local rc = rest_utils.consts.success.ok
local host_pools_changed = false
-- Instantiate host pools
local s = host_pools:create()
@ -84,6 +85,7 @@ for member, info in pairs(_POST["associations"] or {}) do
if connectivity == "pass" then
if s:bind_member(member, pool_id) == true then
host_pools_changed = true
local current_interface = interface.getId() or -1 -- System Interface
res["associations"][member]["status"] = "OK"
interface.select(tostring(interface.getFirstInterfaceId()))
@ -98,6 +100,7 @@ for member, info in pairs(_POST["associations"] or {}) do
local terminate_cause = info["terminateCause"] or 3 -- Lost service
local current_interface = interface.getId() or -1 -- System Interface
s:bind_member(member, host_pools.DEFAULT_POOL_ID)
host_pools_changed = true
res["associations"][member]["status"] = "OK"
interface.select(tostring(interface.getFirstInterfaceId()))
local mac_info = interface.getMacInfo(member)
@ -111,5 +114,9 @@ for member, info in pairs(_POST["associations"] or {}) do
::continue::
end
if host_pools_changed then
ntop.reloadHostPools()
end
rest_utils.answer(rc, res)