diff options
author | Mika Havela <mika.havela@gmail.com> | 2008-09-16 11:32:24 +0000 |
---|---|---|
committer | Mika Havela <mika.havela@gmail.com> | 2008-09-16 11:32:24 +0000 |
commit | 2b83bc701c24101c10e062cdbfff11498370389f (patch) | |
tree | d07073e4950146e3adcbdf4d65356158bfe8a8d7 | |
parent | 8854cd82b4214373d61ae9d363de4f7127985c0b (diff) | |
download | acf-quagga-2b83bc701c24101c10e062cdbfff11498370389f.tar.bz2 acf-quagga-2b83bc701c24101c10e062cdbfff11498370389f.tar.xz |
Adding zebra routes on statuspage to show some debugging details
git-svn-id: svn://svn.alpinelinux.org/acf/quagga/trunk@1468 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r-- | zebra-controller.lua | 4 | ||||
-rw-r--r-- | zebra-details-html.lsp | 15 | ||||
-rw-r--r-- | zebra-model.lua | 54 | ||||
-rw-r--r-- | zebra-welcome-html.lsp | 10 | ||||
-rw-r--r-- | zebra.menu | 2 | ||||
-rw-r--r-- | zebra.roles | 2 |
6 files changed, 85 insertions, 2 deletions
diff --git a/zebra-controller.lua b/zebra-controller.lua index 8e65d57..113a819 100644 --- a/zebra-controller.lua +++ b/zebra-controller.lua @@ -9,6 +9,10 @@ function status(self) return self.model.getstatus() end +function details(self) + return self.model.getdetails() +end + function startstop(self) return controllerfunctions.handle_startstop(self, self.model.startstop_service, self.model.getstatus, self.clientdata) end diff --git a/zebra-details-html.lsp b/zebra-details-html.lsp new file mode 100644 index 0000000..11b8da9 --- /dev/null +++ b/zebra-details-html.lsp @@ -0,0 +1,15 @@ +<% local data = ... +require("viewfunctions") +--[[ DEBUG INFORMATION +io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>") +io.write(html.cfe_unpack(data)) +io.write("</span>") +--]] + +%> + +<H2>Zebra routes</H2> +<PRE> +<% io.write(tostring(data.value.showip.value)) %> +</PRE> + diff --git a/zebra-model.lua b/zebra-model.lua index 12d62b9..89bfc26 100644 --- a/zebra-model.lua +++ b/zebra-model.lua @@ -11,6 +11,52 @@ local processname = "zebra" local packagename = "quagga" -- ################################################################################ +-- LOCAL FUNCTIONS +local function parseconfigfile() + local conf = {} + local f = io.open(configfile, "r") + local line, key, _, k, v + + if not f then + return nil + end + + for line in f:lines() do + line = string.gsub(line, "%s*#.*", "") + local k,v = string.match(line, "^%s*(%S*)%s+(.*)") + if k then + conf[k] = v + end + end + f:close() + return conf +end + +local function telnetshowip() + local output = {} + local configfile = parseconfigfile() + local cmd_output_result, cmd_output_error + local cmd = path .. "echo -e '" .. (configfile.password or "") .. "\nshow ip route\nquit\n' | nc localhost zebra 2>/dev/null" + local f = io.popen( cmd ) + local line = f:read("*l") + local validoutput + while line do + if (string.find(line, "^Codes")) then + validoutput = true + end + if (string.find(line, "> quit")) then + validoutput = false + end + if (validoutput) then + table.insert(output,line) + end + line = f:read("*l") + end + return table.concat(output,"\n"),cmd_output_error +-- return configfile.password +end + +-- ################################################################################ -- PUBLIC FUNCTIONS function startstop_service(action) @@ -30,3 +76,11 @@ function setconfigfile(filedetails) return modelfunctions.setfiledetails(filedetails) end +function getdetails() + local status = {} + status.showip = cfe({ label="Zebra routes" }) + status.showip.value,status.showip.errtxt = telnetshowip() + return cfe({ type="group", value=status, label="Zebra Details" }) +end + + diff --git a/zebra-welcome-html.lsp b/zebra-welcome-html.lsp new file mode 100644 index 0000000..3670b93 --- /dev/null +++ b/zebra-welcome-html.lsp @@ -0,0 +1,10 @@ +<% local data, viewlibrary, page_info, session = ... +require("viewfunctions") +%> + +<% if viewlibrary and viewlibrary.dispatch_component and session.permissions[page_info.controller].status then + viewlibrary.dispatch_component("status") +end %> +<% if viewlibrary and viewlibrary.dispatch_component and session.permissions[page_info.controller].details then + viewlibrary.dispatch_component("details") +end %> @@ -1,4 +1,4 @@ #CAT GROUP/DESC TAB ACTION -Networking 46Zebra Status status +Networking 46Zebra Status welcome Networking 46Zebra Expert expert diff --git a/zebra.roles b/zebra.roles index c03bfdb..3c86963 100644 --- a/zebra.roles +++ b/zebra.roles @@ -1,2 +1,2 @@ -READ=zebra:status,zebra:details, +READ=zebra:welcome,zebra:status,zebra:details, UPDATE=zebra:startstop,zebra:expert, |