summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--zebra-controller.lua4
-rw-r--r--zebra-details-html.lsp15
-rw-r--r--zebra-model.lua54
-rw-r--r--zebra-welcome-html.lsp10
-rw-r--r--zebra.menu2
-rw-r--r--zebra.roles2
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 %>
diff --git a/zebra.menu b/zebra.menu
index 9a59eb8..2a7386e 100644
--- a/zebra.menu
+++ b/zebra.menu
@@ -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,