diff options
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | bgp-controller.lua (renamed from quagga-controller.lua) | 20 | ||||
-rw-r--r-- | bgp-details-html.lsp | 15 | ||||
l--------- | bgp-expert-html.lsp | 1 | ||||
-rw-r--r-- | bgp-model.lua | 67 | ||||
l--------- | bgp-startstop-html.lsp | 1 | ||||
l--------- | bgp-status-html.lsp | 1 | ||||
-rw-r--r-- | bgp-welcome-html.lsp | 10 | ||||
-rw-r--r-- | bgp.menu | 4 | ||||
-rw-r--r-- | bgp.roles | 2 | ||||
-rw-r--r-- | quagga-bgpexpert-html.lsp | 16 | ||||
l--------- | quagga-bgpstartstop-html.lsp | 1 | ||||
l--------- | quagga-expert-html.lsp | 1 | ||||
-rw-r--r-- | quagga-model.lua | 112 | ||||
l--------- | quagga-startstop-html.lsp | 1 | ||||
l--------- | quagga-status-html.lsp | 1 | ||||
-rw-r--r-- | quagga.menu | 5 | ||||
-rw-r--r-- | quagga.roles | 2 | ||||
-rw-r--r-- | zebra-controller.lua | 22 | ||||
l--------- | zebra-expert-html.lsp | 1 | ||||
-rw-r--r-- | zebra-model.lua | 32 | ||||
l--------- | zebra-startstop-html.lsp | 1 | ||||
l--------- | zebra-status-html.lsp (renamed from quagga-bgpstatus-html.lsp) | 0 | ||||
-rw-r--r-- | zebra.menu | 4 | ||||
-rw-r--r-- | zebra.roles | 2 |
25 files changed, 173 insertions, 152 deletions
@@ -3,7 +3,8 @@ PACKAGE=acf-$(APP_NAME) VERSION=0.2.3 APP_DIST=\ - quagga* \ + bgp* \ + zebra* \ EXTRA_DIST=README Makefile config.mk diff --git a/quagga-controller.lua b/bgp-controller.lua index e2bb4b3..b344230 100644 --- a/quagga-controller.lua +++ b/bgp-controller.lua @@ -5,26 +5,22 @@ require("controllerfunctions") default_action = "status" +function welcome() +end + function status(self) return self.model.getstatus() end -function startstop(self) - return controllerfunctions.handle_startstop(self, self.model.startstop_service, self.model.getstatus, self.clientdata) +function details(self) + return self.model.getdetails() end function expert(self) - return controllerfunctions.handle_form(self, self.model.getconfigfile, self.model.setconfigfile, self.clientdata, "Save", "Edit Quagga Config", "Quagga Configuration Saved") + return controllerfunctions.handle_form(self, self.model.getconfigfile, self.model.setconfigfile, self.clientdata, "Save", "Edit BGP Config", "BGP Configuration Saved") end -function bgpstatus(self) - return self.model.getbgpstatus() -end - -function bgpstartstop(self) - return controllerfunctions.handle_startstop(self, self.model.bgpstartstop_service, self.model.getbgpstatus, self.clientdata) +function startstop(self) + return controllerfunctions.handle_startstop(self, self.model.startstop_service, self.model.getstatus, self.clientdata) end -function bgpexpert(self) - return controllerfunctions.handle_form(self, self.model.getbgpconfigfile, self.model.setbgpconfigfile, self.clientdata, "Save", "Edit BGP Config", "BGP Configuration Saved") -end diff --git a/bgp-details-html.lsp b/bgp-details-html.lsp new file mode 100644 index 0000000..025dab2 --- /dev/null +++ b/bgp-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>BGP routes</H2> +<PRE> +<% io.write(tostring(data.showipbgp.value)) %> +</PRE> + diff --git a/bgp-expert-html.lsp b/bgp-expert-html.lsp new file mode 120000 index 0000000..945bc0b --- /dev/null +++ b/bgp-expert-html.lsp @@ -0,0 +1 @@ +/usr/share/acf/app/expert-html.lsp
\ No newline at end of file diff --git a/bgp-model.lua b/bgp-model.lua new file mode 100644 index 0000000..c1426f9 --- /dev/null +++ b/bgp-model.lua @@ -0,0 +1,67 @@ +module(..., package.seeall) + +-- Load libraries +require("modelfunctions") + +-- Set variables +local path="PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin " + +local configfile = "/etc/quagga/bgpd.conf" +local processname = "bgpd" +local packagename = "quagga" + +-- ################################################################################ +-- LOCAL FUNCTIONS + +local function telnetshowipbgp() + local output = {} + local cmd_output_result, cmd_output_error + local cmd = path .. "echo -e 'zebpasswd\nshow ip bgp\nquit\n' | nc localhost bgpd 2>/dev/null" + local f = io.popen( cmd ) + local line = f:read("*l") + local validoutput + while line do + if (string.find(line, "^BGP")) then + validoutput = true + end + if (validoutput) then + table.insert(output,line) + end + if (line) and (string.find(line, "^Total number")) then + validoutput = false + end + line = f:read("*l") + end + return table.concat(output,"\n"),cmd_output_error +end + +-- ################################################################################ +-- PUBLIC FUNCTIONS + +function getstatus() + return modelfunctions.getstatus(processname, packagename, "BGP Status") +end + +function getconfigfile() + return modelfunctions.getfiledetails(configfile) +end + +function setconfigfile(filedetails) + filedetails.value.filename.value = configfile + return modelfunctions.setfiledetails(filedetails) +end + +function startstop_service(action) + return modelfunctions.startstop_service(processname, action) +end + +function getdetails() + local status = {} + status.showipbgp = cfe({ + name="showipbgp", + label="BGP routes", + }) + status.showipbgp.value,status.showipbgp.errtxt = telnetshowipbgp() + return status +end + diff --git a/bgp-startstop-html.lsp b/bgp-startstop-html.lsp new file mode 120000 index 0000000..ce3188f --- /dev/null +++ b/bgp-startstop-html.lsp @@ -0,0 +1 @@ +/usr/share/acf/app/startstop-html.lsp
\ No newline at end of file diff --git a/bgp-status-html.lsp b/bgp-status-html.lsp new file mode 120000 index 0000000..f61ec19 --- /dev/null +++ b/bgp-status-html.lsp @@ -0,0 +1 @@ +/usr/share/acf/app/status-html.lsp
\ No newline at end of file diff --git a/bgp-welcome-html.lsp b/bgp-welcome-html.lsp new file mode 100644 index 0000000..3670b93 --- /dev/null +++ b/bgp-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/bgp.menu b/bgp.menu new file mode 100644 index 0000000..7ea058b --- /dev/null +++ b/bgp.menu @@ -0,0 +1,4 @@ +#CAT GROUP/DESC TAB ACTION +Networking 47BGP Status welcome +Networking 47BGP Expert expert + diff --git a/bgp.roles b/bgp.roles new file mode 100644 index 0000000..83c2721 --- /dev/null +++ b/bgp.roles @@ -0,0 +1,2 @@ +READ=bgp:welcome,bgp:status,bgp:details, +UPDATE=bgp:startstop,bgp:expert, diff --git a/quagga-bgpexpert-html.lsp b/quagga-bgpexpert-html.lsp deleted file mode 100644 index ed28a11..0000000 --- a/quagga-bgpexpert-html.lsp +++ /dev/null @@ -1,16 +0,0 @@ -<% local form, viewlibrary, page_info, session = ... %> -<% require("viewfunctions") %> - -<% if viewlibrary and viewlibrary.dispatch_component then - viewlibrary.dispatch_component("bgpstatus") -end %> - -<% -local pattern = string.gsub(page_info.prefix..page_info.controller, "[%(%)%.%%%+%-%*%?%[%]%^%$]", "%%%1") -local func = haserl.loadfile(page_info.viewfile:gsub(pattern..".*$", "/") .. "filedetails-html.lsp") -func(form, viewlibrary, page_info, session) -%> - -<% if viewlibrary and viewlibrary.dispatch_component and session.permissions[page_info.controller].startstop then - viewlibrary.dispatch_component("bgpstartstop") -end %> diff --git a/quagga-bgpstartstop-html.lsp b/quagga-bgpstartstop-html.lsp deleted file mode 120000 index 0ea2627..0000000 --- a/quagga-bgpstartstop-html.lsp +++ /dev/null @@ -1 +0,0 @@ -../startstop-html.lsp
\ No newline at end of file diff --git a/quagga-expert-html.lsp b/quagga-expert-html.lsp deleted file mode 120000 index 207f324..0000000 --- a/quagga-expert-html.lsp +++ /dev/null @@ -1 +0,0 @@ -../expert-html.lsp
\ No newline at end of file diff --git a/quagga-model.lua b/quagga-model.lua deleted file mode 100644 index ec1c328..0000000 --- a/quagga-model.lua +++ /dev/null @@ -1,112 +0,0 @@ -module(..., package.seeall) - --- Load libraries -require("modelfunctions") ---require("fs") ---require("format") ---require("posix") ---require("validator") - --- Set variables -local configfile = "/etc/quagga/zebra.conf" -local processname = "zebra" -local packagename = "quagga" - -local bgpconfigfile = "/etc/quagga/bgpd.conf" -local bgpprocessname = "bgpd" - --- ################################################################################ --- LOCAL FUNCTIONS ---[[ -local function get_routes() - local cmd_output_result, cmd_output_error - local cmd = "/sbin/route -n 2>/dev/null" - local f = io.popen( cmd ) - local cmd_output_result = f:read("*a") - return cmd_output_result,cmd_output_error -end - -local function get_iproute() - local cmd_output_result, cmd_output_error - local cmd = "/bin/ip route 2>/dev/null" - local f = io.popen( cmd ) - local cmd_output_result = f:read("*a") - return cmd_output_result,cmd_output_error -end - -local function get_bgpinfo() - local cmd_output_result, cmd_output_error - local cmd = "/usr/sbin/bgpd --version 2>/dev/null" - local f = io.popen( cmd ) - local cmd_output_result = f:read("*a") - -- bgpdport=179 - return cmd_output_result,cmd_output_error -end - -local function process_status_text(procname) - local t = procps.pidof(procname) - if (t) and (#t > 0) then - return "Enabled" - else - return "Disabled" - end -end ---]] --- ################################################################################ --- PUBLIC FUNCTIONS - -function startstop_service(action) - return modelfunctions.startstop_service(processname, action) -end - -function getstatus() - return modelfunctions.getstatus(processname, packagename, "Quaga Status") -end - -function getconfigfile() - return modelfunctions.getfiledetails(configfile) -end - -function setconfigfile(filedetails) - filedetails.value.filename.value = configfile - return modelfunctions.setfiledetails(filedetails) -end - -function bgpstartstop_service(action) - return modelfunctions.startstop_service(bgpprocessname, action) -end - -function getbgpstatus() - return modelfunctions.getstatus(bgpprocessname, packagename, "BGP Status") ---[[ - status.iproute = cfe({ name="iproute", - label="ip route", - value=get_iproute(), - }) - - status.routes = cfe({ name="routes", - label="route -n", - value=get_routes(), - }) - - status.bgpstats = cfe({ name="bgpstats", - label="BGP version", - value=get_bgpinfo(), - }) - - return status--]] -end ---[[ -function getconfig() - local config = {} - return config -end ---]] -function getbgpconfigfile() - return modelfunctions.getfiledetails(bgpconfigfile) -end - -function setbgpconfigfile(filedetails) - filedetails.value.filename.value = bgpconfigfile - return modelfunctions.setfiledetails(filedetails) -end diff --git a/quagga-startstop-html.lsp b/quagga-startstop-html.lsp deleted file mode 120000 index 0ea2627..0000000 --- a/quagga-startstop-html.lsp +++ /dev/null @@ -1 +0,0 @@ -../startstop-html.lsp
\ No newline at end of file diff --git a/quagga-status-html.lsp b/quagga-status-html.lsp deleted file mode 120000 index b2f8480..0000000 --- a/quagga-status-html.lsp +++ /dev/null @@ -1 +0,0 @@ -../status-html.lsp
\ No newline at end of file diff --git a/quagga.menu b/quagga.menu deleted file mode 100644 index e2b3005..0000000 --- a/quagga.menu +++ /dev/null @@ -1,5 +0,0 @@ -#CAT GROUP/DESC TAB ACTION -Networking 46BGP Status status -Networking 46BGP Expert expert -Networking 46BGP BGP_Status bgpstatus -Networking 46BGP BGP_Expert bgpexpert diff --git a/quagga.roles b/quagga.roles deleted file mode 100644 index c1f83ac..0000000 --- a/quagga.roles +++ /dev/null @@ -1,2 +0,0 @@ -READ=quagga:status,quagga:bgpstatus -UPDATE=quagga:startstop,quagga:expert,quagga:bgpstartstop,quagga:bgpexpert diff --git a/zebra-controller.lua b/zebra-controller.lua new file mode 100644 index 0000000..90aacdd --- /dev/null +++ b/zebra-controller.lua @@ -0,0 +1,22 @@ +module(..., package.seeall) + +-- Load libraries +require("controllerfunctions") + +default_action = "status" + +function welcome() +end + +function status(self) + return self.model.getstatus() +end + +function startstop(self) + return controllerfunctions.handle_startstop(self, self.model.startstop_service, self.model.getstatus, self.clientdata) +end + +function expert(self) + return controllerfunctions.handle_form(self, self.model.getconfigfile, self.model.setconfigfile, self.clientdata, "Save", "Edit Zebra Config", "Zebra Configuration Saved") +end + diff --git a/zebra-expert-html.lsp b/zebra-expert-html.lsp new file mode 120000 index 0000000..945bc0b --- /dev/null +++ b/zebra-expert-html.lsp @@ -0,0 +1 @@ +/usr/share/acf/app/expert-html.lsp
\ No newline at end of file diff --git a/zebra-model.lua b/zebra-model.lua new file mode 100644 index 0000000..12d62b9 --- /dev/null +++ b/zebra-model.lua @@ -0,0 +1,32 @@ +module(..., package.seeall) + +-- Load libraries +require("modelfunctions") + +-- Set variables +local path="PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin " + +local configfile = "/etc/quagga/zebra.conf" +local processname = "zebra" +local packagename = "quagga" + +-- ################################################################################ +-- PUBLIC FUNCTIONS + +function startstop_service(action) + return modelfunctions.startstop_service(processname, action) +end + +function getstatus() + return modelfunctions.getstatus(processname, packagename, "Zebra Status") +end + +function getconfigfile() + return modelfunctions.getfiledetails(configfile) +end + +function setconfigfile(filedetails) + filedetails.value.filename.value = configfile + return modelfunctions.setfiledetails(filedetails) +end + diff --git a/zebra-startstop-html.lsp b/zebra-startstop-html.lsp new file mode 120000 index 0000000..ce3188f --- /dev/null +++ b/zebra-startstop-html.lsp @@ -0,0 +1 @@ +/usr/share/acf/app/startstop-html.lsp
\ No newline at end of file diff --git a/quagga-bgpstatus-html.lsp b/zebra-status-html.lsp index b2f8480..b2f8480 120000 --- a/quagga-bgpstatus-html.lsp +++ b/zebra-status-html.lsp diff --git a/zebra.menu b/zebra.menu new file mode 100644 index 0000000..9a59eb8 --- /dev/null +++ b/zebra.menu @@ -0,0 +1,4 @@ +#CAT GROUP/DESC TAB ACTION +Networking 46Zebra Status status +Networking 46Zebra Expert expert + diff --git a/zebra.roles b/zebra.roles new file mode 100644 index 0000000..3c86963 --- /dev/null +++ b/zebra.roles @@ -0,0 +1,2 @@ +READ=zebra:welcome,zebra:status,zebra:details, +UPDATE=zebra:startstop,zebra:expert, |