"Connection failed"
}
+local session_id = nil
+
+local function call(cmd, args)
+ if type(args) == "table" and session_id then
+ args.ubus_rpc_session = session_id
+ end
+ return util.ubus("uci", cmd, args)
+end
+
function cursor()
return _M
return "/tmp/.uci"
end
+function get_session_id(self)
+ return session_id
+end
+
function set_confdir(self, directory)
return false
end
return false
end
+function set_session_id(self, id)
+ session_id = id
+ return true
+end
+
function load(self, config)
return true
function changes(self, config)
- local rv = util.ubus("uci", "changes", { config = config })
+ local rv = call("changes", { config = config })
local res = {}
if type(rv) == "table" and type(rv.changes) == "table" then
function revert(self, config)
- local _, err = util.ubus("uci", "revert", { config = config })
+ local _, err = call("revert", { config = config })
return (err == nil), ERRSTR[err]
end
function commit(self, config)
- local _, err = util.ubus("uci", "commit", { config = config })
+ local _, err = call("commit", { config = config })
return (err == nil), ERRSTR[err]
end
if type(configs) == "table" then
for _, config in ipairs(configs) do
- util.ubus("service", "event", {
+ call("service", "event", {
type = "config.change",
data = { package = config }
})
function foreach(self, config, stype, callback)
if type(callback) == "function" then
- local rv, err = util.ubus("uci", "get", {
+ local rv, err = call("get", {
config = config,
type = stype
})
if section == nil then
return nil
elseif type(option) == "string" and option:byte(1) ~= 46 then
- local rv, err = util.ubus("uci", operation, {
+ local rv, err = call(operation, {
config = config,
section = section,
option = option
end
function get_all(self, config, section)
- local rv, err = util.ubus("uci", "get", {
+ local rv, err = call("get", {
config = config,
section = section
})
function section(self, config, stype, name, values)
- local rv, err = util.ubus("uci", "add", {
+ local rv, err = call("add", {
config = config,
type = stype,
name = name,
local sname, err = self:section(config, option, section)
return (not not sname), err
else
- local _, err = util.ubus("uci", "set", {
+ local _, err = call("set", {
config = config,
section = section,
values = { [option] = value }
end
function tset(self, config, section, values)
- local _, err = util.ubus("uci", "set", {
+ local _, err = call("set", {
config = config,
section = section,
values = values
return false, "Invalid argument"
end
- local _, err = util.ubus("uci", "order", {
+ local _, err = call("order", {
config = config,
sections = sections
})
function delete(self, config, section, option)
- local _, err = util.ubus("uci", "delete", {
+ local _, err = call("delete", {
config = config,
section = section,
option = option
function delete_all(self, config, stype, comparator)
local _, err
if type(comparator) == "table" then
- _, err = util.ubus("uci", "delete", {
+ _, err = call("delete", {
config = config,
type = stype,
match = comparator
})
elseif type(comparator) == "function" then
- local rv = util.ubus("uci", "get", {
+ local rv = call("get", {
config = config,
type = stype
})
local sname, section
for sname, section in pairs(rv.values) do
if comparator(section) then
- _, err = util.ubus("uci", "delete", {
+ _, err = call("delete", {
config = config,
section = sname
})
end
end
elseif comparator == nil then
- _, err = util.ubus("uci", "delete", {
+ _, err = call("delete", {
config = config,
type = stype
})