root/luci/trunk/applications/luci-diag-devinfo/luasrc/controller/luci_diag/smap_common.lua @ 7336

Revision 7336, 3.3 KB (checked in by jow, 22 months ago)

applications/luci-diag-devinfo: add index() stubs to controller files (#281)

  • Property svn:keywords set to Id
Line 
1--[[
2
3Luci diag - Diagnostics controller module
4(c) 2009 Daniel Dickinson
5
6Licensed under the Apache License, Version 2.0 (the "License");
7you may not use this file except in compliance with the License.
8You may obtain a copy of the License at
9
10        http://www.apache.org/licenses/LICENSE-2.0
11
12]]--
13
14module("luci.controller.luci_diag.smap_common", package.seeall)
15
16require("luci.i18n")
17require("luci.util")
18require("luci.sys")
19require("luci.cbi")
20require("luci.model.uci")
21
22local translate = luci.i18n.translate
23local DummyValue = luci.cbi.DummyValue
24local SimpleSection = luci.cbi.SimpleSection
25
26function index()
27    return -- no-op
28end
29
30function get_params()
31
32   local smapnets_uci = luci.model.uci.cursor()
33   smapnets_uci:load("luci_devinfo")
34   local nettable = smapnets_uci:get_all("luci_devinfo")
35
36   local i
37   local subnet
38   local smapout
39
40   local outnets = {}
41
42   i = next(nettable, nil)
43
44   while (i) do
45      if (smapnets_uci:get("luci_devinfo", i) == "smap_scannet") then 
46     local scannet = smapnets_uci:get_all("luci_devinfo", i)
47     if scannet["subnet"] and (scannet["subnet"] ~= "") and scannet["enable"] and ( scannet["enable"] == "1") then
48        local output = ""
49        local outrow = {}
50        outrow["subnet"] = scannet["subnet"]
51        ports = "5060"
52        if scannet["ports"] and ( scannet["ports"] ~= "" ) then
53           ports = scannet["ports"]     
54        end
55        outrow["timeout"] = 10
56        local timeout = tonumber(scannet["timeout"]) 
57        if timeout and ( timeout > 0 ) then
58           outrow["timeout"] = scannet["timeout"]
59        end
60
61        outrow["repeat_count"] = 1
62        local repcount = tonumber(scannet["repeat_count"]) 
63        if repcount and ( repcount > 0 ) then
64           outrow["repeat_count"] = scannet["repeat_count"]
65        end
66
67        outrow["sleepreq"] = 100
68        local repcount = tonumber(scannet["sleepreq"]) 
69        if repcount and ( repcount > 0 ) then
70           outrow["sleepreq"] = scannet["sleepreq"]
71        end
72
73        if scannet["interface"] and ( scannet["interface"] ~= "" ) then
74           outrow["interface"] = scannet["interface"]
75        else
76           outrow["interface"] = ""
77        end
78
79        outrow["ports"] = ports
80        outrow["output"] = output
81        outnets[i] = outrow
82     end
83      end
84      i = next(nettable, i)
85   end
86   return outnets
87end
88
89function command_function(outnets, i) 
90
91   local interface = luci.controller.luci_diag.devinfo_common.get_network_device(outnets[i]["interface"])
92
93   return "/usr/bin/netsmap-to-devinfo -r " .. outnets[i]["subnet"] .. " -t " .. outnets[i]["timeout"] .. " -i " .. interface .. " -x -p " ..  outnets[i]["ports"]  .. " -c " .. outnets[i]["repeat_count"] .. " -s " .. outnets[i]["sleepreq"] .. " </dev/null"
94end
95
96function action_links(smapmap, mini) 
97   luci.i18n.loadc("diag_devinfo")
98   s = smapmap:section(SimpleSection, "", translate("Actions")) 
99   b = s:option(DummyValue, "_config", translate("Configure Scans"))
100   b.value = ""
101   if (mini) then
102      b.titleref = luci.dispatcher.build_url("mini", "voice", "phones", "phone_scan_config")
103   else
104      b.titleref = luci.dispatcher.build_url("admin", "network", "diag_config", "smap_devinfo_config")
105   end
106   b = s:option(DummyValue, "_scans", translate("Repeat Scans (this can take a few minutes)"))
107   b.value = ""
108   if (mini) then
109      b.titleref = luci.dispatcher.build_url("mini", "diag", "phone_scan")
110   else
111      b.titleref = luci.dispatcher.build_url("admin", "status", "smap_devinfo")
112   end
113end
Note: See TracBrowser for help on using the browser.