diff options
author | r.kuralamudhan <kuralamudhan.ramakrishnan@intel.com> | 2019-11-22 13:20:52 -0800 |
---|---|---|
committer | r.kuralamudhan <kuralamudhan.ramakrishnan@intel.com> | 2019-11-22 16:20:35 -0800 |
commit | b86512e598d5e59fe1f2048159e68dea4d229164 (patch) | |
tree | d585098207df9fc477bb895b399767bd508ff5e5 /kud/tests/sdwan/build/commands.lua | |
parent | dfdc0206daee4b3474072e2fdd6bc39ab77af5c0 (diff) |
Adding SDWAN testing for KUD containerized installer script
Please refer ICN SDWAN Module Design for architecture
link:https://wiki.akraino.org/display/AK/SDWAN+Module+Design
Issue-ID: MULTICLOUD-956
Co-authored-by: Huifeng Le <huifeng.le@intel.com>
Signed-off-by: r.kuralamudhan <kuralamudhan.ramakrishnan@intel.com>
Change-Id: I4bc35bc62f6bab52a5d290829f7406424d72d5ae
Diffstat (limited to 'kud/tests/sdwan/build/commands.lua')
-rw-r--r-- | kud/tests/sdwan/build/commands.lua | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/kud/tests/sdwan/build/commands.lua b/kud/tests/sdwan/build/commands.lua new file mode 100644 index 00000000..d99f4579 --- /dev/null +++ b/kud/tests/sdwan/build/commands.lua @@ -0,0 +1,43 @@ +-- Licensed to the public under the GNU General Public License v2. + +module("luci.controller.commands", package.seeall) + +sys = require "luci.sys" +ut = require "luci.util" +io = require "io" + +ip = "ip -4 " + +function index() + entry({"admin", "config", "command"}, + call("execute")).dependent = false +end + +function trim(s) + return s:match("^%s*(.-)%s*$") +end + +function split_and_trim(str, sep) + local array = {} + local reg = string.format("([^%s]+)", sep) + for item in string.gmatch(str, reg) do + item_trimed = trim(item) + if string.len(item_trimed) > 0 then + table.insert(array, item_trimed) + end + end + return array +end + +function execute() + local commands = luci.http.formvalue("command") + io.stderr:write("Execute command: %s\n" % commands) + + local command_array = split_and_trim(commands, ";") + for index, command in ipairs(command_array) do + sys.exec(command) + end + + luci.http.prepare_content("application/json") + luci.http.write_json("{'status':'ok'}") +end |