summaryrefslogtreecommitdiffstats
path: root/provisioning-model.lua
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2019-03-16 02:31:10 +0000
committerTed Trask <ttrask01@yahoo.com>2019-10-02 20:46:41 +0000
commita219d102fe69697773800cd91f508443ec293fbf (patch)
tree81d25bac034c7034bfd06738fdf13b0244e85fad /provisioning-model.lua
parent8961d795e450e61d38da8ac22e8c3288722edb58 (diff)
downloadacf-provisioning-master.tar.bz2
acf-provisioning-master.tar.xz
Implement deletedeviceparamgroup actionHEADmaster
The deletedeviceparamgroup action will delete a parameter group from a device and move up all of the subsequent parameter groups. Only works for parameter groups with names ending with numbers, such as regX. This can be used to delete a registration and move up all of the subsequent registrations, working around the Polycom bug where subsequent registrations do not show up on the device.
Diffstat (limited to 'provisioning-model.lua')
-rw-r--r--provisioning-model.lua64
1 files changed, 64 insertions, 0 deletions
diff --git a/provisioning-model.lua b/provisioning-model.lua
index 6c60ace..8e7c8c8 100644
--- a/provisioning-model.lua
+++ b/provisioning-model.lua
@@ -1887,6 +1887,70 @@ mymodule.set_all_device_params = function(self, params)
return set_device_params(params, false)
end
+mymodule.get_delete_device_param_group = function(self, clientdata)
+ clientdata = clientdata or {}
+ local device_id = clientdata.device_id
+ local retval = {}
+ retval.device_id = cfe({value=device_id or "", label="Device ID", seq=0})
+ local errtxt = "Cannot find device"
+ if device_id and device_id ~= "" then
+ local values = get_device_values(device_id)
+ if not values.errtxt then
+ errtxt = nil
+ retval.group = cfe({type="select", value={}, label="Group", option={}, seq=1})
+ local reverseoption = {}
+ for name in pairs(values.value) do
+ if not reverseoption[name] and string.match(name, "%d$") then
+ reverseoption[name] = true
+ retval.group.option[#retval.group.option+1] = name
+ end
+ end
+ table.sort(retval.group.option)
+ end
+ end
+
+ return cfe({ type="group", value=retval, label="Provisioning Device Parameter Groups", errtxt=errtxt })
+end
+
+mymodule.delete_device_param_group = function(self, group)
+ local connected
+ local success = (not group.errtxt)
+ success = modelfunctions.validateselect(group.value.group) and success
+ if success then
+ local res, err = pcall(function()
+ connected = databaseconnect(true)
+ local params = get_device_params(group.value.device_id.value, false)
+ if params.errtxt or not params.value[group.value.group.value] then
+ group.errtxt = "Failed to delete parameter group"
+ group.value.device_id.errtxt = params.errtxt
+ else
+ local number = tonumber(string.match(group.value.group.value, "%d+$"))
+ local name = string.match(group.value.group.value, "(.*)"..number.."$");
+ local temp = params.value[group.value.group.value]
+ local i=number+1
+ while params.value[name..i] do
+ params.value[name..(i-1)] = params.value[name..i]
+ i = i+1
+ end
+ for n,v in pairs(temp.value) do
+ v.value = v.default
+ end
+ params.value[name..(i-1)] = temp
+ params = set_device_params(params)
+ group.errtxt = params.errtxt
+ end
+ if connected then databasedisconnect() end
+ end)
+ if not res and err then
+ handlesqlexception(connected, err)
+ group.errtxt = err
+ end
+ else
+ group.errtxt = "Failed to delete parameter group"
+ end
+ return group
+end
+
mymodule.fetch_device_values = function(self, search)
local connected
local res, err = pcall(function()