From 2fb09eb0dee06e74f94b6def6493066214c5f4a9 Mon Sep 17 00:00:00 2001 From: Mika Havela Date: Thu, 4 Sep 2008 15:13:00 +0000 Subject: Split Bgp and Zebra into separate controllers. Earlier there was no chance to start/stop zebra (only bgp) and the whole package was a strange mix of bgp and zebra. Now these processes has own Menuitems and are controlled separately (they both exist in acf-quagga though). git-svn-id: svn://svn.alpinelinux.org/acf/quagga/trunk@1447 ab2d0c66-481e-0410-8bed-d214d4d58bed --- Makefile | 3 +- bgp-controller.lua | 26 ++++++++++ bgp-details-html.lsp | 15 ++++++ bgp-expert-html.lsp | 1 + bgp-model.lua | 67 ++++++++++++++++++++++++++ bgp-startstop-html.lsp | 1 + bgp-status-html.lsp | 1 + bgp-welcome-html.lsp | 10 ++++ bgp.menu | 4 ++ bgp.roles | 2 + quagga-bgpexpert-html.lsp | 16 ------- quagga-bgpstartstop-html.lsp | 1 - quagga-bgpstatus-html.lsp | 1 - quagga-controller.lua | 30 ------------ quagga-expert-html.lsp | 1 - quagga-model.lua | 112 ------------------------------------------- quagga-startstop-html.lsp | 1 - quagga-status-html.lsp | 1 - quagga.menu | 5 -- quagga.roles | 2 - zebra-controller.lua | 22 +++++++++ zebra-expert-html.lsp | 1 + zebra-model.lua | 32 +++++++++++++ zebra-startstop-html.lsp | 1 + zebra-status-html.lsp | 1 + zebra.menu | 4 ++ zebra.roles | 2 + 27 files changed, 192 insertions(+), 171 deletions(-) create mode 100644 bgp-controller.lua create mode 100644 bgp-details-html.lsp create mode 120000 bgp-expert-html.lsp create mode 100644 bgp-model.lua create mode 120000 bgp-startstop-html.lsp create mode 120000 bgp-status-html.lsp create mode 100644 bgp-welcome-html.lsp create mode 100644 bgp.menu create mode 100644 bgp.roles delete mode 100644 quagga-bgpexpert-html.lsp delete mode 120000 quagga-bgpstartstop-html.lsp delete mode 120000 quagga-bgpstatus-html.lsp delete mode 100644 quagga-controller.lua delete mode 120000 quagga-expert-html.lsp delete mode 100644 quagga-model.lua delete mode 120000 quagga-startstop-html.lsp delete mode 120000 quagga-status-html.lsp delete mode 100644 quagga.menu delete mode 100644 quagga.roles create mode 100644 zebra-controller.lua create mode 120000 zebra-expert-html.lsp create mode 100644 zebra-model.lua create mode 120000 zebra-startstop-html.lsp create mode 120000 zebra-status-html.lsp create mode 100644 zebra.menu create mode 100644 zebra.roles diff --git a/Makefile b/Makefile index c5e0048..ac49ea2 100644 --- a/Makefile +++ b/Makefile @@ -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/bgp-controller.lua b/bgp-controller.lua new file mode 100644 index 0000000..b344230 --- /dev/null +++ b/bgp-controller.lua @@ -0,0 +1,26 @@ +module(..., package.seeall) + +-- Load libraries +require("controllerfunctions") + +default_action = "status" + +function welcome() +end + +function status(self) + return self.model.getstatus() +end + +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 BGP Config", "BGP Configuration Saved") +end + +function startstop(self) + return controllerfunctions.handle_startstop(self, self.model.startstop_service, self.model.getstatus, self.clientdata) +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("

DEBUGGING

DEBUG INFO: CFE

") +io.write(html.cfe_unpack(data)) +io.write("
") +--]] + +%> + +

BGP routes

+
+<% io.write(tostring(data.showipbgp.value)) %>
+
+ 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-bgpstatus-html.lsp b/quagga-bgpstatus-html.lsp deleted file mode 120000 index b2f8480..0000000 --- a/quagga-bgpstatus-html.lsp +++ /dev/null @@ -1 +0,0 @@ -../status-html.lsp \ No newline at end of file diff --git a/quagga-controller.lua b/quagga-controller.lua deleted file mode 100644 index e2bb4b3..0000000 --- a/quagga-controller.lua +++ /dev/null @@ -1,30 +0,0 @@ -module(..., package.seeall) - --- Load libraries -require("controllerfunctions") - -default_action = "status" - -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 Quagga Config", "Quagga 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) -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/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/zebra-status-html.lsp b/zebra-status-html.lsp new file mode 120000 index 0000000..b2f8480 --- /dev/null +++ b/zebra-status-html.lsp @@ -0,0 +1 @@ +../status-html.lsp \ No newline at end of file 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, -- cgit v1.2.3