summaryrefslogtreecommitdiffstats
path: root/bgp-model.lua
diff options
context:
space:
mode:
authorMika Havela <mika.havela@gmail.com>2008-09-04 15:13:00 +0000
committerMika Havela <mika.havela@gmail.com>2008-09-04 15:13:00 +0000
commit2fb09eb0dee06e74f94b6def6493066214c5f4a9 (patch)
tree82dd74c9c2891a13efd278e3b40c76a80bb9960b /bgp-model.lua
parentbb571803d2cce176d5aaab9659733c852bf85b1b (diff)
downloadacf-quagga-2fb09eb0dee06e74f94b6def6493066214c5f4a9.tar.bz2
acf-quagga-2fb09eb0dee06e74f94b6def6493066214c5f4a9.tar.xz
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
Diffstat (limited to 'bgp-model.lua')
-rw-r--r--bgp-model.lua67
1 files changed, 67 insertions, 0 deletions
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
+