mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-01 00:19:33 +00:00
Implements RESTful edit of interface pools and members
Implements #4107
This commit is contained in:
parent
ca1a011c2b
commit
519fec5f94
4 changed files with 40 additions and 8 deletions
|
|
@ -4,21 +4,47 @@
|
|||
|
||||
local dirs = ntop.getDirs()
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/pools/?.lua;" .. package.path
|
||||
|
||||
require "lua_utils"
|
||||
local json = require "dkjson"
|
||||
local rest_utils = require "rest_utils"
|
||||
local interface_pools = require "interface_pools"
|
||||
|
||||
--
|
||||
-- Edit an existing pool
|
||||
--
|
||||
|
||||
local pool_id = _GET["pool"]
|
||||
local name = _GET["pool_name"]
|
||||
local members = _GET["pool_members"]
|
||||
local confset_id = _GET["confset_id"]
|
||||
|
||||
sendHTTPHeader('application/json')
|
||||
|
||||
if not isAdministrator() then
|
||||
print(rest_utils.rc(rest_utils.consts_not_granted))
|
||||
return
|
||||
end
|
||||
|
||||
if not pool_id or not name or not members or not confset_id then
|
||||
print(rest_utils.rc(rest_utils.consts_invalid_args))
|
||||
return
|
||||
end
|
||||
|
||||
-- pool_id as number
|
||||
pool_id = tonumber(pool_id)
|
||||
-- Unfold the members csv
|
||||
members = members:split(",") or {members}
|
||||
-- confset_id as number
|
||||
confset_id = tonumber(confset_id)
|
||||
|
||||
local s = interface_pools:create()
|
||||
local res = s:edit_pool(pool_id, name, members --[[ an array of valid interface ids]], confset_id --[[ a valid configset_id --]])
|
||||
|
||||
if not res then
|
||||
print(rest_utils.rc(rest_utils.consts_edit_pool_failed))
|
||||
end
|
||||
|
||||
local rc = rest_utils.consts_ok
|
||||
local res = {
|
||||
-- STUB
|
||||
}
|
||||
|
||||
print(rest_utils.rc(rc, res))
|
||||
|
||||
print(rest_utils.rc(rc))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue