summaryrefslogtreecommitdiffstats
path: root/provisioning-model.lua
diff options
context:
space:
mode:
Diffstat (limited to 'provisioning-model.lua')
-rw-r--r--provisioning-model.lua22
1 files changed, 11 insertions, 11 deletions
diff --git a/provisioning-model.lua b/provisioning-model.lua
index 943267e..1b5dd54 100644
--- a/provisioning-model.lua
+++ b/provisioning-model.lua
@@ -68,7 +68,7 @@ local createdatabase = function()
table.insert(result, errtxt)
table.insert(result, cmdresult)
end
-
+
-- Create the database
local cmd = "CREATE DATABASE "..DatabaseName.." WITH OWNER "..DatabaseUser
cmdresult, errtxt = modelfunctions.run_executable({"psql", "-U", "postgres", "-c", cmd}, true)
@@ -83,11 +83,11 @@ local createdatabase = function()
return table.concat(result, "\n")
end
-
+
-- Delete the database and roles
local deletedatabase = function()
local result = {}
-
+
local cmd = "DROP DATABASE "..DatabaseName
local cmdresult, errtxt = modelfunctions.run_executable({"psql", "-U", "postgres", "-c", cmd}, true)
table.insert(result, errtxt)
@@ -474,7 +474,7 @@ local set_device_params = function(params, editable)
end
end
end
-
+
local tmp = saved_device_params[params.value.device_id.value]
local p = params
if not editable then
@@ -1183,7 +1183,7 @@ mymodule.update_group = function(self, group, action, create)
success = false
group.value.name.errtxt = "Cannot be blank"
-- Group name cannot be device_id, name, or label or will mess up get_device_params
- elseif group.value.name.value == "device_id" or group.value.name.value == "name" or group.value.name.value == "label" then
+ elseif group.value.name.value == "device_id" or group.value.name.value == "name" or group.value.name.value == "label" then
success = false
group.value.name.errtxt = "Illegal name"
elseif string.find(group.value.name.value, "%W") then
@@ -1722,7 +1722,7 @@ mymodule.delete_device = function(self, delreq)
else
if not saved_device_params[device_id] then get_device_params(device_id) end
if not saved_devices[device_id] then get_device(device_id) end
-
+
sql = "DELETE FROM provisioning_values WHERE device_id='"..provdb.escape(device_id).."'"
runsqlcommand(sql)
sql = "DELETE FROM devices_to_classes WHERE device_id='"..provdb.escape(device_id).."'"
@@ -1776,7 +1776,7 @@ mymodule.get_class_values = function(self, retval)
retval.errtxt = nil
retval.value.label = cfe({ value=tmp[1].label or "", label="Label", seq=3})
retval.value.values = cfe({type="structure", value={}, label="Parameter Values"})
-
+
local sql = "SELECT g.name AS group, p.name, p.type, CASE WHEN g2p.value IS NOT NULL THEN g2p.value ELSE p.value END AS value "..
"FROM (provisioning_classes t JOIN classes_to_param_groups t2g USING(class_id) JOIN provisioning_groups g USING(group_id) "..
"JOIN param_groups_to_params g2p USING(group_id) JOIN provisioning_params p USING(param_id)) "..
@@ -2170,7 +2170,7 @@ function mymodule.put_file(self, clientdata)
local mac = clientdata.mac
local data = clientdata.data
local retval = cfe({ label="PUT Data" })
-
+
-- Error if there's no mac
if not mac or mac == "" then
retval.errtxt = "No MAC Address"
@@ -2179,7 +2179,7 @@ function mymodule.put_file(self, clientdata)
local res, err = pcall(function()
connected = databaseconnect()
-
+
-- Now, let's see if this device exists
local search = mymodule.get_search_options()
search.value.id.value = "device.mac"
@@ -2237,7 +2237,7 @@ mymodule.list_requests = function(self, clientdata)
local res, err = pcall(function()
connected = databaseconnect(true)
-
+
local filter = {}
columns.data = nil -- Cannot regex filter based on date because of the timestamp type
for c,f in pairs(retval.value.filter.value) do
@@ -2369,7 +2369,7 @@ mymodule.create_from_request = function(self, request)
handlesqlexception(connected, err)
request.errtxt = err
end
-
+
if not success and not request.errtxt then
request.errtxt = "Failed to create device"
end