diff options
-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 |