diff options
author | Ted Trask <ttrask01@yahoo.com> | 2008-07-11 20:46:35 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2008-07-11 20:46:35 +0000 |
commit | aff09ec85031849e3f626f19e776e42953310363 (patch) | |
tree | 8b0425b636749fdc5f5e1e52f054b20aafb197eb /quagga-model.lua | |
parent | 21412c6fc93671faf917f3c4fefba915a39f9fac (diff) | |
download | acf-quagga-aff09ec85031849e3f626f19e776e42953310363.tar.bz2 acf-quagga-aff09ec85031849e3f626f19e776e42953310363.tar.xz |
Updated quagga to separate quagga functions from bgp functions. Implemented status, startstop, and expert.
git-svn-id: svn://svn.alpinelinux.org/acf/quagga/trunk@1296 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'quagga-model.lua')
-rw-r--r-- | quagga-model.lua | 170 |
1 files changed, 40 insertions, 130 deletions
diff --git a/quagga-model.lua b/quagga-model.lua index dd13d7d..73e9859 100644 --- a/quagga-model.lua +++ b/quagga-model.lua @@ -1,26 +1,23 @@ module(..., package.seeall) -- Load libraries -require("fs") -require("procps") -require("format") -require("posix") -require("daemoncontrol") -require("validator") ---require("socket") -require("processinfo") +require("modelfunctions") +--require("fs") +--require("format") +--require("posix") +--require("validator") -- Set variables -local configfile = "/etc/quagga/bgpd.conf" -local processname = "bgpd" +local configfile = "/etc/conf.d/zebra" +local processname = "zebra" local packagename = "quagga" -local baseurl = "/etc/quagga/" -local descr = { -} + +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" @@ -54,40 +51,34 @@ local function process_status_text(procname) return "Disabled" end end - +--]] -- ################################################################################ -- PUBLIC FUNCTIONS -function startstop_service ( self, action ) - local cmd = action.value - local cmdresult,cmdmessage,cmderror,cmdaction = daemoncontrol.daemoncontrol(processname, cmd) - action.descr=cmdmessage - action.errtxt=cmderror - return cmdresult,action +function startstop_service(action) + return modelfunctions.startstop_service(processname, action) end function getstatus() - local status = {} - - local value, errtxt = processinfo.package_version(packagename) - status.version = cfe({ name = "version", - label="Program version", - value=value, - errtxt=errtxt, - }) - - status.status = cfe({ name="status", - label="Program status", - value=process_status_text(processname), - }) + return modelfunctions.getstatus(processname, packagename, "Quaga Status") +end - local autostart_sequense, autostart_errtxt = processinfo.process_botsequence(processname) - status.autostart = cfe({ name="autostart", - label="Autostart sequence", - value=autostart_sequense, - errtxt=autostart_errtxt, - }) +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(), @@ -103,100 +94,19 @@ function getstatus() value=get_bgpinfo(), }) - return status + return status--]] end - -function get_logfile () - local file = {} - local cmdtxt = "grep " .. processname .. " /var/log/messages" - local cmd, error = io.popen(cmdtxt ,r) - local cmdoutput = cmd:read("*a") - cmd:close() - - file["filename"] = cfe({ - name="filename", - label="File name", - value=cmdtxt, - }) - - file["filecontent"] = cfe({ - type="longtext", - name="filecontent", - label="File content", - value=cmdoutput, - }) - - return file -end - +--[[ function getconfig() local config = {} return config end - -function get_filedetails(self,num) - local path - if (num == "2") then - path = configfile2 - else - path = configfile - end - local file = {} - local filedetails = {} - local config = {} - local filenameerrtxt - if (path) and (fs.is_file(path)) then - filedetails = fs.stat(path) - config = getconfig(path) - else - config = {} - config.filename = {} - config["filename"]["errtxt"]="Config file '".. path .. "' is missing!" - end - - file["filename" .. (num or "")] = cfe({ - name="filename" .. (num or ""), - label="File name", - value=path, - errtxt=filenameerrtxt - }) - file["filesize" .. (num or "")] = cfe({ - name="filesize" .. (num or ""), - label="File size", - value=filedetails.size or 0, - }) - file["mtime" .. (num or "")] = cfe({ - name="mtime" .. (num or ""), - label="File date", - value=filedetails.mtime or "---", - }) - file["filecontent" .. (num or "")] = cfe({ - type="longtext", - name="filecontent" .. (num or ""), - label="File content", - value=fs.read_file(path), - }) - - -- Sum all errors into one cfe - local sumerrors = "" - for k,v in pairs(config) do - if (config[k]) and (config[k]["errtxt"]) and (config[k]["errtxt"] ~= "") then - sumerrors = sumerrors .. config[k]["errtxt"] .. "\n" - end - end - if (sumerrors ~= "") then - file["sumerrors" .. (num or "")] = cfe ({ - name="sumerrors" .. (num or ""), - label = "Configuration errors", - errtxt = string.match(sumerrors, "(.-)\n$"), - }) - end - - return file -end -function update_filecontent (self, modifications) - local path = configfile - local file_result,err = fs.write_file(path, format.dostounix(modifications)) - return file_result +--]] +function getbgpconfigfile() + return modelfunctions.getfiledetails(bgpconfigfile) end +function setbgpconfigfile(filedetails) + filedetails.value.filename.value = bgpconfigfile + return modelfunctions.setfiledetails(filedetails) +end |