diff options
author | Ted Trask <ttrask01@yahoo.com> | 2015-11-11 19:09:34 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2015-11-11 19:09:34 +0000 |
commit | 9c2bb7050036c98a560b6167ef28120a35b55867 (patch) | |
tree | cf2a3831c8a8e05e9ec33abbdb998613c23f1c32 /provisioning-model.lua | |
parent | ac39f5937993b186cb79ca684274ea727eb7fd59 (diff) | |
download | acf-provisioning-9c2bb7050036c98a560b6167ef28120a35b55867.tar.bz2 acf-provisioning-9c2bb7050036c98a560b6167ef28120a35b55867.tar.xz |
Modify bulkcreatedevices to accept substrings of label for device values that have options
Fix bulkcreatedevices class values to escape magic characters in value
Diffstat (limited to 'provisioning-model.lua')
-rw-r--r-- | provisioning-model.lua | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/provisioning-model.lua b/provisioning-model.lua index 669ed4a..0620018 100644 --- a/provisioning-model.lua +++ b/provisioning-model.lua @@ -2328,7 +2328,7 @@ mymodule.bulk_create_devices = function(self, devicelist) if not found then -- Check for string match for k,c in ipairs(class.option) do - if string.find(c.label, value) then + if string.find(c.label, format.escapemagiccharacters(value)) then if found then error("Ambiguous "..name.." class in line "..i) end @@ -2363,7 +2363,28 @@ mymodule.bulk_create_devices = function(self, devicelist) if values[j] and string.find(h, "%.") then local class,param = string.match(h, "^([^.]+)%.(.*)") if params.value[class] and params.value[class].value[param] then - params.value[class].value[param].value = values[j] + if params.value[class].value[param].type == "select" then + -- Allow the select value to be the value or a unique substring of the label + local found = false + for k,o in ipairs(params.value[class].value[param].option) do + if values[j] == o.value then + found = o.value + break + elseif string.find(o.label, format.escapemagiccharacters(values[j])) then + if found then + error("Ambiguous "..h.." value in line "..i) + end + found = o.value + end + end + if found then + params.value[class].value[param].value = found + else + error("Invalid "..h.." value in line "..i) + end + else + params.value[class].value[param].value = values[j] + end end end end |