summaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2013-09-23 18:13:03 +0000
committerTed Trask <ttrask01@yahoo.com>2013-09-23 18:13:03 +0000
commitfb00ff8f05dae3c110beceb929ea036e4cd14ae1 (patch)
tree51d124ce1c65e3a600a7da7b9dd57ffafd83f910 /config
parent60ef6e20019e046aa801325d29893ada12b5d5af (diff)
downloadacf-provisioning-fb00ff8f05dae3c110beceb929ea036e4cd14ae1.tar.bz2
acf-provisioning-fb00ff8f05dae3c110beceb929ea036e4cd14ae1.tar.xz
Change function prototypes to pass self and use self.model instead of functions table
Changed the order of the first two parameters passed to validate function in provisioning_params Replaced all APP references with self, now that self is available Still need to implement swapvalidateparams script
Diffstat (limited to 'config')
-rw-r--r--config/delete_device.lua10
-rw-r--r--config/determine_class.lua6
-rw-r--r--config/process_put.lua10
-rw-r--r--config/update_device.lua6
-rw-r--r--config/update_device_params.lua18
5 files changed, 25 insertions, 25 deletions
diff --git a/config/delete_device.lua b/config/delete_device.lua
index 4f5fee7..81c2afb 100644
--- a/config/delete_device.lua
+++ b/config/delete_device.lua
@@ -1,20 +1,20 @@
-- This is the script run after deleting a device (and all of its params)
-local functions, olddevice, oldparams = ...
+local self, olddevice, oldparams = ...
require("posix")
local root = "/var/www/provisioning/htdocs/"
---APP.logevent("got to delete_device script")
+--self.logevent("got to delete_device script")
-- First, we delete the associated config files for Polycom with valid MAC (not blank or all 0's)
if oldparams.value.device and string.match(oldparams.value.device.label, "Polycom") and oldparams.value.device.value.mac and string.match(oldparams.value.device.value.mac.value, "[1-9A-F]") then
- --APP.logevent("Deleting files for "..oldparams.value.device.value.mac.value)
+ --self.logevent("Deleting files for "..oldparams.value.device.value.mac.value)
local path = root.."Polycom/"
if posix.stat(path, "type") == "directory" then
for d in posix.files(path) do
if string.match(d, string.lower(oldparams.value.device.value.mac.value)) and posix.stat(path..d, "type") == "regular" then
- --APP.logevent("deleting "..path..d)
+ --self.logevent("deleting "..path..d)
os.remove(path..d)
end
end
@@ -56,5 +56,5 @@ setmetatable (env, {__index = _G})
-- so we set env 0, not env 1
setfenv (0, env)
local f = loadfile("/etc/provisioning/update_device_params.lua")
-if (f) then f(functions, params, oldparams) end
+if (f) then f(self, params, oldparams) end
setfenv (0, _G)
diff --git a/config/determine_class.lua b/config/determine_class.lua
index 675e6e8..53a1884 100644
--- a/config/determine_class.lua
+++ b/config/determine_class.lua
@@ -1,7 +1,7 @@
-- This is the script run to determine the device class from the HTTP user agent
-local functions, agent, classes = ...
+local self, agent, classes = ...
---APP.logevent("got to determine_class script")
+--self.logevent("got to determine_class script")
local manufacture, model
@@ -16,7 +16,7 @@ elseif string.match(agent, "snom") then
model = string.match(agent, "snom(%d+)")
end
---APP.logevent("Found "..(manufacture or "").." model "..(model or ""))
+--self.logevent("Found "..(manufacture or "").." model "..(model or ""))
if manufacture and model then
for i,c in ipairs(classes.value) do
diff --git a/config/process_put.lua b/config/process_put.lua
index 4eabb1a..1a34042 100644
--- a/config/process_put.lua
+++ b/config/process_put.lua
@@ -1,10 +1,10 @@
-- This is the script run to process uploaded config files
-local functions, mac, data, device_id = ...
+local self, mac, data, device_id = ...
---APP.logevent("got to process_put script")
+--self.logevent("got to process_put script")
-- Get the params
-local params = functions.get_device_params(device_id)
+local params = self.get_device_params(self, device_id)
function process_polycom()
local before, xml, after = string.match(data, "(.*<OVERRIDES)([^/]*)(/>.*)")
@@ -18,7 +18,7 @@ function process_polycom()
end
-- for n,v in pairs(attrs) do
--- APP.logevent("name "..n.." val "..(v or ""))
+-- self.logevent("name "..n.." val "..(v or ""))
-- end
-- Read attributes from attrs and generate paramaters for ACF
@@ -57,7 +57,7 @@ if string.match(params.value.device.label, "Polycom") then
end
-- Update the params
-local params = functions.set_device_params(params)
+local params = self.set_device_params(self, params)
-- Return the updated data
return data
diff --git a/config/update_device.lua b/config/update_device.lua
index 7295062..9823e95 100644
--- a/config/update_device.lua
+++ b/config/update_device.lua
@@ -1,7 +1,7 @@
-- This is the script run after editing a device - the label, classes
-local functions, device, olddevice, params, oldparams = ...
+local self, device, olddevice, params, oldparams = ...
---APP.logevent("got to update_device script")
+--self.logevent("got to update_device script")
-- We'll handle the changing of the device by handling the resulting changing of the params
local env = {}
@@ -10,5 +10,5 @@ setmetatable (env, {__index = _G})
-- so we set env 0, not env 1
setfenv (0, env)
local f = loadfile("/etc/provisioning/update_device_params.lua")
-if (f) then f(functions, params, oldparams) end
+if (f) then f(self, params, oldparams) end
setfenv (0, _G)
diff --git a/config/update_device_params.lua b/config/update_device_params.lua
index 6d7ae23..42560c3 100644
--- a/config/update_device_params.lua
+++ b/config/update_device_params.lua
@@ -1,17 +1,17 @@
-- This is the script run after editing device params
-local functions, params, oldparams = ...
+local self, params, oldparams = ...
require("posix")
local root = "/var/www/provisioning/htdocs/"
---APP.logevent("got to update_device_params script")
+--self.logevent("got to update_device_params script")
local function findip(mac)
if not mac or mac == "" then
return nil
end
- local ipaddr = functions.getselectresponse("SELECT ip FROM provisioning_requests WHERE mac~*'"..mac.."'")
+ local ipaddr = self.getselectresponse("SELECT ip FROM provisioning_requests WHERE mac~*'"..mac.."'")
if ipaddr and ipaddr[1] then
return ipaddr[1].ip
end
@@ -20,10 +20,10 @@ end
local notify_device = function(mac, extension)
local ipaddr = findip(mac)
if ipaddr then
- --APP.logevent("Notifying "..ipaddr.." to update for "..(mac or ""))
+ --self.logevent("Notifying "..ipaddr.." to update for "..(mac or ""))
os.execute("/etc/provisioning/notify_device "..ipaddr.." "..extension)
else
- --APP.logevent("Warning - could not find IP address for "..(mac or ""))
+ --self.logevent("Warning - could not find IP address for "..(mac or ""))
end
end
@@ -34,10 +34,10 @@ if oldparams.value.device and oldparams.value.device.value.mac and oldparams.val
if string.match(oldparams.value.device.label, "Polycom") and string.match(oldparams.value.device.value.mac.value, "[1-9A-F]") then
local deletefiles = true
if string.match(params.value.device.value.mac.value, "[1-9A-F]") then
- --APP.logevent("Moving files for "..oldparams.value.device.value.mac.value)
+ --self.logevent("Moving files for "..oldparams.value.device.value.mac.value)
deletefiles = false
else
- --APP.logevent("Deleting files for "..oldparams.value.device.value.mac.value)
+ --self.logevent("Deleting files for "..oldparams.value.device.value.mac.value)
end
local path = root.."Polycom/"
if posix.stat(path, "type") == "directory" then
@@ -45,10 +45,10 @@ if oldparams.value.device and oldparams.value.device.value.mac and oldparams.val
if string.match(d, string.lower(oldparams.value.device.value.mac.value)) and posix.stat(path..d, "type") == "regular" then
local newfile = string.gsub(d, string.lower(oldparams.value.device.value.mac.value), string.lower(params.value.device.value.mac.value))
if deletefiles then
- --APP.logevent("deleting "..path..d)
+ --self.logevent("deleting "..path..d)
os.remove(path..d)
else
- --APP.logevent("moving "..path..d.." to "..path..newfile)
+ --self.logevent("moving "..path..d.." to "..path..newfile)
os.rename(path..d, path..newfile)
end
end