Removed recipient selection from pools. Only severity and category are used as filters now. New filtering based on pool to be done.

This commit is contained in:
Alfredo Cardigliano 2022-02-18 11:45:16 +01:00
parent f5178d4329
commit 29c0ba4594
28 changed files with 110 additions and 707 deletions

View file

@ -42,24 +42,8 @@ function flow_pools:get_all_members() return {} end
-- ##############################################
--@brief Tells the C++ core about the flow recipients
function flow_pools:set_flow_recipients(recipients)
-- Create a bitmap of all recipients responsible for flows (pool_id in this case is ignored)
local recipients_bitmap = 0
for _, recipient_id in ipairs(recipients) do
recipients_bitmap = recipients_bitmap | (1 << recipient_id)
end
-- Tell the C++ that flow recipients have changed
ntop.recipient_set_flow_recipients(recipients_bitmap)
end
-- ##############################################
--@brief Method called after a successful execution of method persist
function flow_pools:_post_persist(pool_id, name, members, recipients)
self:set_flow_recipients(recipients)
function flow_pools:_post_persist(pool_id, name, members)
end
-- ##############################################

View file

@ -13,8 +13,6 @@ local checks = require "checks"
local ts_utils = require "ts_utils_core"
local json = require "dkjson"
local recipients_mod = require "recipients"
-- ##############################################
local host_pools = {}
@ -42,17 +40,16 @@ function host_pools:create(args)
if locked then
-- Init the jail, if not already initialized.
-- By default, the jail has always empty members and empty recipients
-- By default, the jail has always empty members
local jailed_hosts_pool = self:get_pool(host_pools.DROP_HOST_POOL_ID)
if not jailed_hosts_pool then
-- Raw call to persist, no need to go through add_pool as here all the parameters are trusted and
-- there's no need to check.
-- Jail is always created with builtin recipients
self:_persist(host_pools.DROP_HOST_POOL_ID,
host_pools.DROP_HOST_POOL_NAME,
{} --[[ no members --]] ,
recipients_mod.get_builtin_recipients() --[[ builtin recipients --]], nil --[[ policy ]])
nil --[[ policy ]])
ntop.setMembersCache(self:_get_pool_ids_key(),
string.format("%d", host_pools.DROP_HOST_POOL_ID))
@ -89,7 +86,7 @@ end
-- ##############################################
-- Overwrite the pool name, members and recipients
-- Overwrite the pool name, members
function host_pools:set_pool_policy(pool_id, new_policy)
return self:edit_pool(pool_id, nil, nil, nil, new_policy)
end
@ -240,24 +237,9 @@ end
-- ##############################################
--@brief Tells the C++ core about the host recipients
function host_pools:set_host_recipients(recipients)
-- Create a bitmap of all recipients responsible for hosts (pool_id in this case is ignored)
local recipients_bitmap = 0
for _, recipient_id in ipairs(recipients) do
recipients_bitmap = recipients_bitmap | (1 << recipient_id)
end
-- Tell the C++ that host recipients have changed
ntop.recipient_set_host_recipients(recipients_bitmap)
end
-- ##############################################
-- @brief Persist pool details to disk. Possibly assign a pool id
-- @param pool_id The pool_id of the pool which needs to be persisted. If nil, a new pool id is assigned
function host_pools:_persist(pool_id, name, members, recipients, policy)
function host_pools:_persist(pool_id, name, members, policy)
-- OVERRIDE
-- Method must be overridden as host pool details and members are kept as hash caches, which are also used by the C++
@ -278,11 +260,6 @@ function host_pools:_persist(pool_id, name, members, recipients, policy)
ntop.setMembersCache(pool_members_key, member)
end
-- Recipients
if recipients then -- safety check
ntop.setHashCache(pool_details_key, "recipients", json.encode(recipients));
end
-- Policy
-- NB: the policy is already a string
ntop.setHashCache(pool_details_key, "policy", (policy or ""));
@ -293,11 +270,6 @@ function host_pools:_persist(pool_id, name, members, recipients, policy)
if not self.transaction_started then
-- Reload pools
ntop.reloadHostPools()
-- Set host recipients in the C++ core
if recipients then -- safety check
self:set_host_recipients(recipients)
end
end
-- Return the assigned pool_id
@ -366,10 +338,7 @@ end
-- ##############################################
function host_pools:get_pool(pool_id, recipient_details)
local recipient_details = recipient_details or true
function host_pools:get_pool(pool_id)
local pool_name = self:_get_pool_detail(pool_id, "name")
if pool_name == "" then
return nil -- Pool not existing
@ -387,36 +356,6 @@ function host_pools:get_pool(pool_id, recipient_details)
members = {}
end
-- Recipients
local recipients = self:_get_pool_detail(pool_id, "recipients")
if recipients then
recipients = json.decode(recipients) or {}
local temp_recipients = {}
-- get recipient metadata
for _, recipient_id in pairs(recipients) do
if tonumber(recipient_id) then -- Handles previously string-keyed recipients
local res = { recipient_id = recipient_id }
if recipient_details then
local recipient = recipients_mod.get_recipient(recipient_id)
if recipient and recipient.recipient_name then
res["recipient_name"] = recipient.recipient_name
res["recipient_check_categories"] = recipient.check_categories
res["recipient_minimum_severity"] = recipient.minimum_severity
end
end
temp_recipients[#temp_recipients + 1] = res
end
end
recipients = temp_recipients
else
recipients = {}
end
local policy = self:_get_pool_detail(pool_id, "policy")
local pool_details = {
@ -424,7 +363,6 @@ function host_pools:get_pool(pool_id, recipient_details)
name = pool_name,
members = members,
member_details = member_details,
recipients = recipients,
policy = policy,
}

View file

@ -9,7 +9,6 @@ package.path = dirs.installdir .. "/scripts/lua/modules/notifications/?.lua;" ..
require "lua_utils"
local checks = require "checks"
local recipients_mod = require "recipients"
local json = require "dkjson"
local ntop_info = ntop.getInfo()
@ -54,11 +53,6 @@ pools.MIN_ASSIGNED_POOL_ID = 2
-- ##############################################
-- Flag to remember if user bound a recipient to a pool
pools.FIRST_RECIPIENT_BOUND_CACHE_KEY = "ntopng.prefs.endpoint_hints.recipient_has_been_bound"
-- ##############################################
function pools:create(args)
if args then
-- We're being sub-classed
@ -101,17 +95,16 @@ function pools:_initialize()
if locked then
-- Init the default pool, if not already initialized.
-- The default pool has always empty members and empty recipients
-- The default pool has always empty members
local default_pool = self:get_pool(pools.DEFAULT_POOL_ID)
if not default_pool then
-- Raw call to persist, no need to go through add_pool as here all the parameters are trusted and
-- there's no need to check.
-- Default pool is always created with builtin recipients
self:_persist(pools.DEFAULT_POOL_ID,
pools.DEFAULT_POOL_NAME,
{} --[[ no members --]] ,
recipients_mod.get_builtin_recipients() --[[ builtin recipients --]], nil --[[ policy ]])
nil --[[ policy ]])
end
self:_unlock()
@ -242,14 +235,14 @@ function pools:_unlock() ntop.delCache(self:_get_pool_lock_key()) end
-- ##############################################
--@brief Method called after a successful execution of method persist
function pools:_post_persist(pool_id, name, members, recipients, policy)
function pools:_post_persist(pool_id, name, members, policy)
end
-- ##############################################
-- @brief Persist pool details to disk. Possibly assign a pool id
-- @param pool_id The pool_id of the pool which needs to be persisted. If nil, a new pool id is assigned
function pools:_persist(pool_id, name, members, recipients, policy)
function pools:_persist(pool_id, name, members, policy)
-- self:cleanup()
-- Default pool name and members cannot be modified
@ -262,12 +255,11 @@ function pools:_persist(pool_id, name, members, recipients, policy)
local pool_details = {
name = name,
members = members,
recipients = recipients
}
ntop.setCache(pool_details_key, json.encode(pool_details))
self:_post_persist(pool_id, name, members, recipients, policy)
self:_post_persist(pool_id, name, members, policy)
-- Return the assigned pool_id
return pool_id
@ -285,13 +277,13 @@ end
-- ##############################################
-- Create a new pool (unless it already exists)
function pools:add_pool(name, members, recipients, policy)
function pools:add_pool(name, members, policy)
local pool_id
local locked = self:_lock()
if locked then
if name and members and recipients then
if name and members then
local checks_ok = true
-- Check if duplicate names exist
@ -318,18 +310,11 @@ function pools:add_pool(name, members, recipients, policy)
end
end
-- Check if recipients are valid
if checks_ok then
if not self:are_valid_recipients(recipients) then
checks_ok = false
end
end
if checks_ok then
-- All the checks have succeeded
-- Now that everything is ok, the id can be assigned and the pool can be persisted with the assigned id
pool_id = self:_assign_pool_id()
self:_persist(pool_id, name, members, recipients, policy)
self:_persist(pool_id, name, members, policy)
self:_set_cache_flag()
end
end
@ -342,8 +327,8 @@ end
-- ##############################################
-- Add members and recipients (merge) to an existing pool
function pools:add_to_pool(name, members, recipients)
-- Add members (merge) to an existing pool
function pools:add_to_pool(name, members)
local ret = true
local err = pools.ERRORS.NO_ERROR
@ -367,20 +352,6 @@ function pools:add_to_pool(name, members, recipients)
end
end
end
-- Add recipients
if recipients then
for _, recipient_id in pairs(recipients) do
-- Check if recipient is valid
if self:is_valid_recipient(recipient_id) then
local retr, errr = self:_bind_recipient(recipient_id, pool_id)
if not retm then
ret = retr
err = errr
end
end
end
end
end
self:_unlock()
@ -392,9 +363,9 @@ end
-- ##############################################
-- Overwrite the pool name, members and recipients
-- Overwrite the pool name, members
-- Policy are used just by Host Pool
function pools:edit_pool(pool_id, new_name, new_members, new_recipients, new_policy)
function pools:edit_pool(pool_id, new_name, new_members, new_policy)
local ret = false
local locked = self:_lock()
@ -443,22 +414,6 @@ function pools:edit_pool(pool_id, new_name, new_members, new_recipients, new_pol
new_members = cur_pool_details["members"]
end
if new_recipients then
-- Check if recipients are valid
if checks_ok and not self:are_valid_recipients(new_recipients) then
checks_ok = false
end
else
-- In case recipients have not been sumbitted, new_recipients
-- are assumed to be the existing recipients
new_recipients = {}
-- Populate with recipient IDs
for _, recipient in pairs(cur_pool_details["recipients"] or {}) do
new_recipients[#new_recipients + 1] = recipient["recipient_id"]
end
end
if not new_policy then
-- In case policy have not been sumbitted, new_policy
-- is assumed to be the existing policy
@ -467,7 +422,7 @@ function pools:edit_pool(pool_id, new_name, new_members, new_recipients, new_pol
if checks_ok then
-- If here, all checks are valid and the pool can be edited
self:_persist(pool_id, new_name, new_members, new_recipients, new_policy)
self:_persist(pool_id, new_name, new_members, new_policy)
self:_set_cache_flag()
-- Pool edited successfully
ret = true
@ -548,8 +503,7 @@ end
-- ##############################################
function pools:get_pool(pool_id, recipient_details)
local recipient_details = recipient_details or true
function pools:get_pool(pool_id)
local pool_details
local pool_details_key = self:_get_pool_details_key(pool_id)
@ -571,30 +525,6 @@ function pools:get_pool(pool_id, recipient_details)
self:get_member_details(member)
end
end
if pool_details["recipients"] then
local recipients = {}
-- get recipient metadata
for _, recipient_id in pairs(pool_details["recipients"]) do
if tonumber(recipient_id) then -- Handles previously string-keyed recipients
local res = {recipient_id = recipient_id}
if recipient_details then
local recipient = recipients_mod.get_recipient(recipient_id)
if recipient and recipient.recipient_name then
-- Keep in in sync with overridden method in host_pool.lua
res["recipient_name"] = recipient.recipient_name
res["recipient_check_categories"] = recipient.check_categories
res["recipient_minimum_severity"] = recipient.minimum_severity
end
end
recipients[#recipients + 1] = res
end
end
pool_details["recipients"] = recipients
end
end
end
-- Upon success, pool details are returned, otherwise nil
@ -656,32 +586,6 @@ end
-- ##############################################
function pools:get_recipients(pool_id)
local pool_details
local res = {}
if pool_id == nil then return res end
local locked = self:_lock()
if locked then
pool_details = self:get_pool(pool_id)
self:_unlock()
end
if pool_details and pool_details["recipients"] then
for _, recipient in pairs(pool_details["recipients"]) do
res[#res + 1] = recipient
end
end
return res
end
-- ##############################################
-- @brief Delete all pools
function pools:cleanup()
-- Delete pool details
@ -725,154 +629,6 @@ end
-- ##############################################
-- @brief Parses recipients submitted via HTTP (validated as `pool_recipients` in `http_lint.lua`) into a table of members
function pools:parse_recipients(recipients_string)
local recipients = {}
if isEmptyString(recipients_string) then return recipients end
-- Unfold the recipients csv
recipients = recipients_string:split(",") or {recipients_string}
local res = {}
for _, recipient_id in pairs(recipients) do
local recipient_id = tonumber(recipient_id)
if recipient_id then
res[#res + 1] = recipient_id
end
end
return res
end
-- ##############################################
-- @brief Returns available recipient ids which can be added to a pool
function pools:get_available_recipient_ids()
-- Please note that recipient ids are shared across pools of all types
-- so all the recipient ids can be returned here without distinction
local recipients = recipients_mod.get_all_recipients()
local res = {}
for _, recipient in pairs(recipients) do
local recipient_id = recipient.recipient_id
res[recipient_id] = {
recipient_id = recipient_id,
recipient_name = recipient.recipient_name
}
end
return res
end
-- ##############################################
-- @brief Returns a boolean indicating whether the recipient_id is a valid recipient id
function pools:is_valid_recipient(recipient_id)
local all_recipients = self:get_available_recipient_ids()
return all_recipients[tonumber(recipient_id)] ~= nil
end
-- ##############################################
-- @brief Returns a boolean indicating whether the array of recipients passed
-- contains all valid recipients
function pools:are_valid_recipients(recipients)
for _, recipient_id in pairs(recipients) do
if not self:is_valid_recipient(recipient_id) then return false end
end
return true
end
-- ##############################################
-- @brief Unbind a recipient from all pools
function pools:unbind_all_recipient_id(recipient_id)
if not recipient_id then
-- Invalid argument
return
end
local locked = self:_lock()
if locked then
local all_pools = self:get_all_pools()
for _, pool in pairs(all_pools) do
local found = false
-- New recipients (all pool recipients except for the one being removed)
local new_recipients = {}
if pool["recipients"] then
for _, cur_recipient in pairs(pool["recipients"]) do
if tonumber(cur_recipient.recipient_id) ~= tonumber(recipient_id) then
new_recipients[#new_recipients + 1] = tonumber(cur_recipient.recipient_id)
else
found = true
end
end
end
if found then
-- Rewrite the pool using the new recipients set
self:_persist(pool["pool_id"], pool["name"], pool["members"], new_recipients, pool["policy"])
end
end
self:_unlock()
end
end
-- ##############################################
-- @brief Bind a recipient to all pools
function pools:bind_all_recipient_id(recipient_id)
if not recipient_id then
-- Invalid argument
return
end
local locked = self:_lock()
if locked then
local all_pools = self:get_all_pools()
for _, pool in pairs(all_pools) do
local found = false
-- All the recipients for the current pool
local new_recipients = {}
if pool["recipients"] then
for _, cur_recipient in pairs(pool["recipients"]) do
if tonumber(cur_recipient.recipient_id) == tonumber(recipient_id) then
-- Already bound for this pool, nothing to do
found = true
break
else
-- Prepare a lua array with integer recipient ids
new_recipients[#new_recipients + 1] = tonumber(cur_recipient.recipient_id)
end
end
if not found then
-- Append the recipient to the array of pool recipients
new_recipients[#new_recipients + 1] = tonumber(recipient_id)
-- Rewrite the pool using the extended recipients array
self:_persist(pool["pool_id"], pool["name"], pool["members"], new_recipients, pool["policy"])
end
end
end
self:_unlock()
end
end
-- ##############################################
-- @brief Parses members submitted via HTTP (validated as `pool_members` in `http_lint.lua`) into a table of members
function pools:parse_members(members_string)
local members = {}
@ -904,46 +660,6 @@ end
-- ##############################################
-- @brief Bind a recipient to a pool
-- PRIVATE FUNCTION, not to be called outside this class
-- The caller must lock
function pools:_bind_recipient(recipient_id, pool_id)
local ret, err = false, pools.ERRORS.GENERIC
-- ASSIGN the recipient to the pool with `pool_id`
local bind_pool = self:get_pool(pool_id, false)
if bind_pool then
-- Members stay the same
local bind_pool_members = bind_pool["members"]
-- Recipients are all pool recipients plus the recipient which is being bound
local bind_pool_recipients = {}
local already_present = false
for _, recipient in pairs(bind_pool["recipients"] or {}) do
bind_pool_recipients[#bind_pool_recipients + 1] = recipient.recipient_id
if recipient.recipient_id == recipient_id then
already_present = true
end
end
if not already_present then
bind_pool_recipients[#bind_pool_recipients + 1] = recipient_id
-- Persist the pool with the new `recipient`
self:_persist(bind_pool["pool_id"], bind_pool["name"],
bind_pool_members, bind_pool_recipients, bind_pool["policy"])
end
-- Bind has executed successfully
ret, err = true, pools.ERRORS.NO_ERROR
end
return ret, err
end
-- ##############################################
-- @brief Bind a member to a pool
-- PRIVATE FUNCTION, not to be called outside this class
-- The caller must lock and must check the member doesn't belong to
@ -965,15 +681,9 @@ function pools:_bind_member(member, pool_id)
local bind_pool_members = bind_pool["members"]
bind_pool_members[#bind_pool_members + 1] = member
-- Recipients stay the same, but we need to get their ids only
local bind_pool_recipients = {}
for _, recipient in pairs(bind_pool["recipients"] or {}) do
bind_pool_recipients[#bind_pool_recipients + 1] = recipient.recipient_id
end
-- Persist the pool with the new `member`
self:_persist(bind_pool["pool_id"], bind_pool["name"],
bind_pool_members, bind_pool_recipients, bind_pool["policy"])
bind_pool_members, bind_pool["policy"])
-- Bind has executed successfully
ret = true
@ -1014,15 +724,9 @@ function pools:bind_member(member, pool_id)
end
end
-- Recipients stay the same, but we need to get their ids only
local bind_pool_recipients = {}
for _, recipient in pairs(cur_pool["recipients"] or {}) do
bind_pool_recipients[#bind_pool_recipients + 1] = recipient.recipient_id
end
-- Persist the existing pool without the removed `member`
self:_persist(cur_pool["pool_id"], cur_pool["name"],
new_members, bind_pool_recipients, cur_pool["policy"])
-- Persist the existing pool without the removed `member`
self:_persist(cur_pool["pool_id"], cur_pool["name"],
new_members, cur_pool["policy"])
end
end
@ -1114,8 +818,6 @@ end
-- @brief Returns true for 'dummy' pool instances
-- that don't allow the creations of pools apart from the default one,
-- and also don't allow members to be set/removed.
-- This kind of pools only allow recipients to be added/removed from the
-- default pool.
function pools:default_only()
-- By default, pool instances are fully fledged, unless this method is
-- overridden in the subclass.

View file

@ -68,76 +68,4 @@ end
-- ################################################################################
-- @brief Returns an array of recipient ids responsible for a given an `entity_id` and a `pool_id`
-- @param entity_id One of alert_consts.alert_entities
-- @param pool_id The pool id of an existing entity pool
-- @param alert_severity An integer alert severity id as found in `alert_severities`
-- @param category_id The category for which we want the recipients (one id of checks.check_categories)
-- @return An array of recipient ids
function pools_alert_utils.get_entity_recipients_by_pool_id(entity_id, pool_id, alert_severity, category_id)
local res = {}
local entity = alert_consts.alertEntityById(entity_id)
-- Obtain the pools instance for the given entity
local pools_instance = pools_alert_utils.get_entity_pools_by_id(entity_id)
if not pool_id then
pool_id = pools.DEFAULT_POOL_ID
end
if pools_instance then
-- tprint("found pool instance for "..entity.label)
-- See if the pools for the current instance are in cache
if not alert_entity_all_pools[entity_id] then
-- List of pools not yet cached, let's create it
alert_entity_all_pools[entity_id] = {}
local all_pools = pools_instance:get_all_pools()
-- It's handy to have the cache as a lua table with pool ids as keys and pool details as values
for _, pool in pairs(all_pools) do
alert_entity_all_pools[entity_id][pool.pool_id] = pool
end
end
-- Access the cache
local entity_pool = alert_entity_all_pools[entity_id][pool_id]
if entity_pool and entity_pool["recipients"] then
for _, recipient in pairs(entity_pool["recipients"]) do
local recipient_ok = false
if category_id and recipient["recipient_check_categories"] ~= nil then
-- Make sure the user script category belongs to the recipient user script categories
for _, check_category in pairs(recipient["recipient_check_categories"]) do
if check_category == category_id then
recipient_ok = true
end
end
else
-- if there's no user script, check on the category id is not enforced
recipient_ok = true
end
if recipient_ok then
if alert_severity and recipient["recipient_minimum_severity"] ~= nil and
alert_severity < recipient["recipient_minimum_severity"] then
-- If the current alert severity is less than the minimum requested severity
-- exclude the recipient
recipient_ok = false
end
end
if recipient_ok then
-- Prepare the result with all the recipients
res[#res + 1] = recipient.recipient_id
-- tprint(string.format("Adding recipient [%s][%s][%i]", recipient.recipient_name, entity.label, pool_id))
end
end
end
end
return res
end
-- ################################################################################
return pools_alert_utils

View file

@ -43,28 +43,6 @@ end
-- ##############################################
-- @brief Call `instance:unbind_all_recipient_id` for every available pools `instance`
function pools_lua_utils.unbind_all_recipient_id(recipient_id)
local all_instances = pools_lua_utils.all_pool_instances_factory()
for _, instance in pairs(all_instances) do
instance:unbind_all_recipient_id(recipient_id)
end
end
-- ##############################################
-- @brief Call `instance:bind_all_recipient_id` for every available pools `instance`
function pools_lua_utils.bind_all_recipient_id(recipient_id)
local all_instances = pools_lua_utils.all_pool_instances_factory()
for _, instance in pairs(all_instances) do
instance:bind_all_recipient_id(recipient_id)
end
end
-- ##############################################
-- @brief Returns the pool url for a pool with a given `pool_key`
-- @param pool_key A pool key string as found inside `create` method of any pools instance.
-- If no pool key is found, the home of the pool url is returned.

View file

@ -23,7 +23,6 @@ local pools_rest_utils = {}
function pools_rest_utils.add_pool(pools)
local name = _POST["pool_name"]
local members = _POST["pool_members"]
local recipients = _POST["recipients"]
if not auth.has_capability(auth.capabilities.pools) then
rest_utils.answer(rest_utils.consts.err.not_granted)
@ -49,12 +48,10 @@ function pools_rest_utils.add_pool(pools)
end
members_list = s:parse_members(members)
recipients = s:parse_recipients(recipients)
local new_pool_id = s:add_pool(
name,
members_list --[[ an array of valid interface ids]],
recipients --[[ an array of valid recipient ids (names)]]
members_list --[[ an array of valid interface ids]]
)
if not new_pool_id then
@ -80,7 +77,6 @@ function pools_rest_utils.edit_pool(pools)
local pool_id = _POST["pool"]
local name = _POST["pool_name"]
local members = _POST["pool_members"]
local recipients = _POST["recipients"]
if not auth.has_capability(auth.capabilities.pools) then
rest_utils.answer(rest_utils.consts.err.not_granted)
@ -96,14 +92,12 @@ function pools_rest_utils.edit_pool(pools)
local s = pools:create()
members_list = s:parse_members(members)
recipients = s:parse_recipients(recipients)
-- pool_id as number
pool_id = tonumber(pool_id)
local res = s:edit_pool(pool_id,
name,
members_list --[[ an array of valid interface ids]],
recipients --[[ an array of valid recipient ids (names)]]
members_list --[[ an array of valid interface ids]]
)
if not res then
@ -267,33 +261,6 @@ end
-- ##############################################
-- @brief Get all pools of all the available (currently implemented) pool instances matching a given `recipient_id`
function pools_rest_utils.get_all_instances_pools_by_recipient(recipient_id)
local res = {}
local all_instances = pools_lua_utils.all_pool_instances_factory()
for _, instance in pairs(all_instances) do
local instance_pools = instance:get_all_pools()
for _, instance_pool in pairs(instance_pools) do
instance_pool["key"] = instance.key -- e.g., 'interface', 'host', etc.
for _, recipient in pairs(instance_pool["recipients"]) do
if tonumber(recipient.recipient_id) == (recipient_id) then
-- Match, return the recipient
instance_pool["key"] = instance.key -- e.g., 'interface', 'host', etc.
res[#res + 1] = instance_pool
break
end
end
end
end
local rc = rest_utils.consts.success.ok
rest_utils.answer(rc, res)
end
-- ##############################################
-- @brief Get all pools of all the available (currently implemented) pool instances
function pools_rest_utils.get_all_instances_pools()
local res = {}