mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-01 00:19:33 +00:00
[VS] Fix backup configs (#7961)
This commit is contained in:
parent
1efe883551
commit
f25c177b5e
5 changed files with 203 additions and 52 deletions
|
|
@ -5,11 +5,13 @@
|
|||
local dirs = ntop.getDirs()
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/import_export/?.lua;" .. package.path
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/vulnerability_scan/?.lua;" .. package.path
|
||||
|
||||
require "lua_utils"
|
||||
local import_export = require "import_export"
|
||||
local host_pools = require "host_pools"
|
||||
local am_utils = require "am_utils"
|
||||
local vs_utils = require "vs_utils"
|
||||
|
||||
-- ##############################################
|
||||
|
||||
|
|
@ -38,9 +40,12 @@ end
|
|||
-- @brief Import configuration
|
||||
-- @param conf The configuration to be imported
|
||||
-- @return A table with a key "success" set to true is returned on success. A key "err" is set in case of failure, with one of the errors defined in rest_utils.consts.err.
|
||||
function am_import_export:import(conf)
|
||||
function am_import_export:import(config)
|
||||
local res = {}
|
||||
|
||||
local conf = config.res
|
||||
local vs_conf = config.vs_config
|
||||
|
||||
-- TODO Validate the configuration and set
|
||||
-- res.err = rest_utils.consts.err.bad_content
|
||||
|
||||
|
|
@ -58,6 +63,9 @@ function am_import_export:import(conf)
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
vs_utils.restore_config_backup(vs_conf)
|
||||
|
||||
if not res.err then
|
||||
res.success = true
|
||||
end
|
||||
|
|
@ -82,8 +90,16 @@ function am_import_export:export()
|
|||
res[host_key] = host_conf
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local hosts_to_scan = vs_utils.retrieve_hosts_backup()
|
||||
|
||||
local am_configs = {
|
||||
res = res,
|
||||
vs_config = hosts_to_scan
|
||||
}
|
||||
|
||||
return res
|
||||
return am_configs
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue