summaryrefslogtreecommitdiffhomepage
path: root/modules/admin-full/luasrc/model/cbi/admin_network
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2008-08-26 23:00:44 +0000
committerSteven Barth <steven@midlink.org>2008-08-26 23:00:44 +0000
commit91ba7c42f5b45614c9f4c803d09399f08a8e27b1 (patch)
tree21d1e1d67b3bee82eb123c0c5dbb274f2fcb6b59 /modules/admin-full/luasrc/model/cbi/admin_network
parent43b3217e5595acc91ff6d7614a5c21c88696fbcc (diff)
UCI API changes
Diffstat (limited to 'modules/admin-full/luasrc/model/cbi/admin_network')
-rw-r--r--modules/admin-full/luasrc/model/cbi/admin_network/dhcp.lua5
-rw-r--r--modules/admin-full/luasrc/model/cbi/admin_network/dhcpleases.lua2
-rw-r--r--modules/admin-full/luasrc/model/cbi/admin_network/ifaces.lua12
-rw-r--r--modules/admin-full/luasrc/model/cbi/admin_network/network.lua9
-rw-r--r--modules/admin-full/luasrc/model/cbi/admin_network/routes.lua5
-rw-r--r--modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua6
-rw-r--r--modules/admin-full/luasrc/model/cbi/admin_network/wireless.lua12
7 files changed, 21 insertions, 30 deletions
diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/dhcp.lua b/modules/admin-full/luasrc/model/cbi/admin_network/dhcp.lua
index af018eaa8..42b93b599 100644
--- a/modules/admin-full/luasrc/model/cbi/admin_network/dhcp.lua
+++ b/modules/admin-full/luasrc/model/cbi/admin_network/dhcp.lua
@@ -24,7 +24,8 @@ s.anonymous = true
iface = s:option(ListValue, "interface", translate("interface"))
luci.tools.webadmin.cbi_add_networks(iface)
-luci.model.uci.foreach("network", "interface",
+local uci = luci.model.uci.cursor()
+uci:foreach("network", "interface",
function (section)
if section[".name"] ~= "loopback" then
iface.default = iface.default or section[".name"]
@@ -32,7 +33,7 @@ luci.model.uci.foreach("network", "interface",
end
end)
-luci.model.uci.foreach("network", "alias",
+uci:foreach("network", "alias",
function (section)
iface:value(section[".name"])
s:depends("interface", section[".name"])
diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/dhcpleases.lua b/modules/admin-full/luasrc/model/cbi/admin_network/dhcpleases.lua
index 3c89de31d..0b2f55a31 100644
--- a/modules/admin-full/luasrc/model/cbi/admin_network/dhcpleases.lua
+++ b/modules/admin-full/luasrc/model/cbi/admin_network/dhcpleases.lua
@@ -16,7 +16,7 @@ require("luci.tools.webadmin")
m2 = Map("luci_ethers", translate("dhcp_leases"))
local leasefn, leasefp, leases
-luci.model.uci.foreach("dhcp", "dnsmasq",
+luci.model.uci.cursor():foreach("dhcp", "dnsmasq",
function(section)
leasefn = section.leasefile
end
diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/ifaces.lua b/modules/admin-full/luasrc/model/cbi/admin_network/ifaces.lua
index 716631232..5470b8a24 100644
--- a/modules/admin-full/luasrc/model/cbi/admin_network/ifaces.lua
+++ b/modules/admin-full/luasrc/model/cbi/admin_network/ifaces.lua
@@ -49,8 +49,8 @@ if zones then
fwzone.rmempty = true
fwzone:value("", "- " .. translate("none") .. " -")
fwzone:value(arg[1])
- luci.model.uci.load_config("firewall")
- luci.model.uci.foreach("firewall", "zone",
+ m.uci:load("firewall")
+ m.uci:foreach("firewall", "zone",
function (section)
fwzone:value(section.name)
end
@@ -61,14 +61,14 @@ if zones then
local stat
if not zone then
- stat = luci.model.uci.section("firewall", "zone", nil, {
+ stat = m.uci:section("firewall", "zone", nil, {
name = value,
network = section
})
else
- local net = luci.model.uci.get("firewall", zone, "network")
+ local net = m.uci:get("firewall", zone, "network")
net = (net or value) .. " " .. section
- stat = luci.model.uci.set("firewall", zone, "network", net)
+ stat = m.uci:set("firewall", zone, "network", net)
end
if stat then
@@ -80,7 +80,7 @@ if zones then
fwzone.value = table.concat(zones, ", ")
end
fwzone.titleref = luci.dispatcher.build_url("admin", "network", "firewall", "zones")
- luci.model.uci.unload("firewall")
+ m.uci:unload("firewall")
end
ipaddr = s:option(Value, "ipaddr", translate("ipaddress"))
diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/network.lua b/modules/admin-full/luasrc/model/cbi/admin_network/network.lua
index 3924e7c6c..c32aea891 100644
--- a/modules/admin-full/luasrc/model/cbi/admin_network/network.lua
+++ b/modules/admin-full/luasrc/model/cbi/admin_network/network.lua
@@ -15,11 +15,7 @@ $Id$
require("luci.sys")
require("luci.tools.webadmin")
-luci.model.uci.load_state("network")
-local netstate = luci.model.uci.get_all("network")
-luci.model.uci.unload("network")
-
-
+local netstate = luci.model.uci.cursor_state():get_all("network")
m = Map("network", translate("interfaces"))
local created
@@ -70,7 +66,8 @@ end
ifname.titleref = luci.dispatcher.build_url("admin", "network", "vlan")
-if luci.model.uci.load("firewall") then
+
+if luci.model.uci.cursor():load("firewall") then
zone = s:option(DummyValue, "_zone", translate("zone"))
zone.titleref = luci.dispatcher.build_url("admin", "network", "firewall", "zones")
diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/routes.lua b/modules/admin-full/luasrc/model/cbi/admin_network/routes.lua
index d7b851968..aa32324e6 100644
--- a/modules/admin-full/luasrc/model/cbi/admin_network/routes.lua
+++ b/modules/admin-full/luasrc/model/cbi/admin_network/routes.lua
@@ -48,11 +48,6 @@ s = m:section(TypedSection, "route", translate("a_n_routes_static"))
s.addremove = true
s.anonymous = true
-function s.render(...)
- luci.model.uci.load_config("network")
- TypedSection.render(...)
-end
-
s.template = "cbi/tblsection"
iface = s:option(ListValue, "interface", translate("interface"))
diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua b/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua
index e53fb14fd..46f05a3af 100644
--- a/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua
+++ b/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua
@@ -86,12 +86,12 @@ network.combobox_manual = translate("a_w_netmanual")
luci.tools.webadmin.cbi_add_networks(network)
function network.write(self, section, value)
- if not luci.model.uci.get("network", value) then
+ if not m:uci.get("network", value) then
m:chain("network")
- luci.model.uci.set("network", value, "interface")
+ m.uci:set("network", value, "interface")
Value.write(self, section, value)
else
- if luci.model.uci.get("network", value) == "interface" then
+ if m.uci:get("network", value) == "interface" then
Value.write(self, section, value)
end
end
diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/wireless.lua b/modules/admin-full/luasrc/model/cbi/admin_network/wireless.lua
index 4c7794db9..4f19f4e2c 100644
--- a/modules/admin-full/luasrc/model/cbi/admin_network/wireless.lua
+++ b/modules/admin-full/luasrc/model/cbi/admin_network/wireless.lua
@@ -15,10 +15,7 @@ $Id$
require("luci.sys")
require("luci.tools.webadmin")
-luci.model.uci.load_state("wireless")
-local wireless = luci.model.uci.get_all("wireless")
-luci.model.uci.unload("wireless")
-
+local wireless = luci.model.uci.cursor_state():get_all("wireless")
local wifidata = luci.sys.wifi.getiwconfig()
local ifaces = {}
@@ -123,9 +120,10 @@ for k, v in pairs(wireless) do
end
function create.write(self, section, value)
- luci.model.uci.load_config("wireless")
- luci.model.uci.section("wireless", "wifi-iface", nil, {device=value})
- luci.model.uci.save_config("wireless")
+ local uci = luci.model.uci.cursor()
+ uci:load("wireless")
+ uci:section("wireless", "wifi-iface", nil, {device=value})
+ uci:save("wireless")
luci.http.redirect(luci.http.getenv("REQUEST_URI") .. "/" .. value)
end