From cdc275fc78488777472445d5417dcc9e63b8b6b5 Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Sat, 19 Oct 2013 23:58:47 +0000 Subject: Remove all calls to 'module' in preparation for move to Lua 5.2 Use mymodule parameter for module definition. This was also helpful in revealing places where the code relied on the global environment. --- qos-controller.lua | 18 ++++++++++-------- qos-model.lua | 24 +++++++++++++----------- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/qos-controller.lua b/qos-controller.lua index f2c45ae..7c5d938 100644 --- a/qos-controller.lua +++ b/qos-controller.lua @@ -1,27 +1,29 @@ -module(..., package.seeall) +local mymodule = {} -default_action = "status" +mymodule.default_action = "status" -function status(self) +function mymodule.status(self) return self.model.getstatus() end -function startstopinterface(self) +function mymodule.startstopinterface(self) return self.handle_form(self, self.model.get_startstop, self.model.startstop_service, self.clientdata) end -function details(self) +function mymodule.details(self) return self.model.listinterfacedetails(self) end -function enable(self) +function mymodule.enable(self) return self.handle_form(self, self.model.get_enable, self.model.enable, self.clientdata, "Enable", "Enable QOS on Interface", "Enabled QOS on Interface") end -function config(self) +function mymodule.config(self) return self.handle_form(self, self.model.get_config, self.model.update_config, self.clientdata, "Save", "Edit QOS Config", "Configuration Set") end -function expert(self) +function mymodule.expert(self) return self.handle_form(self, self.model.get_filedetails, self.model.update_filedetails, self.clientdata, "Save", "Edit QOS Config", "Configuration Set") end + +return mymodule diff --git a/qos-model.lua b/qos-model.lua index 8a30a7a..1afd2b2 100644 --- a/qos-model.lua +++ b/qos-model.lua @@ -1,4 +1,4 @@ -module(..., package.seeall) +local mymodule = {} -- Load libraries modelfunctions = require("modelfunctions") @@ -52,19 +52,19 @@ end -- ################################################################################ -- PUBLIC FUNCTIONS -function get_startstop(self, clientdata) +function mymodule.get_startstop(self, clientdata) return modelfunctions.get_startstop(clientdata.init) end -function startstop_service(self, startstop, action) +function mymodule.startstop_service(self, startstop, action) return modelfunctions.startstop_service(startstop, action) end -function getstatus() +function mymodule.getstatus() return modelfunctions.getstatus(nil, packagename, "QOS Status") end -function listinterfacedetails(self) +function mymodule.listinterfacedetails(self) local result = {} local interface for i,int in ipairs(list_interfaces(self)) do @@ -82,13 +82,13 @@ function listinterfacedetails(self) return cfe({ type="structure", value=result, label="QOS Interface List" }) end -function get_enable(self, clientdata) +function mymodule.get_enable(self, clientdata) local retval = {} retval.interface = cfe({ value=clientdata.interface or "", label="Interface" }) return cfe({ type="group", value=retval, label="Enable QOS on Interface" }) end -function enable(self, int_enable) +function mymodule.enable(self, int_enable) local interface = int_enable.value.interface.value local init = initfile.."."..interface int_enable.errtxt = "Failed to enable QOS" @@ -114,15 +114,15 @@ function enable(self, int_enable) return int_enable end -function get_filedetails(self, clientdata) +function mymodule.get_filedetails(self, clientdata) return modelfunctions.getfiledetails(clientdata.filename, validate_filename) end -function update_filedetails(self, filedetails) +function mymodule.update_filedetails(self, filedetails) return modelfunctions.setfiledetails(self, filedetails, validate_filename) end -function get_config(self, clientdata) +function mymodule.get_config(self, clientdata) local interface = clientdata.DEV local config = {} local ifbs = {""} @@ -154,7 +154,7 @@ function get_config(self, clientdata) return cfe({ type="group", value=config, label=interface.." QOS Config" }) end -function update_config(self, config) +function mymodule.update_config(self, config) local success = false config.value.DEV.errtxt = "Invalid device" for i,int in ipairs(list_interfaces(self)) do @@ -220,3 +220,5 @@ function update_config(self, config) return config end + +return mymodule -- cgit v1.2.3