diff --git a/modules/admin-core/luasrc/tools/status.lua b/modules/admin-core/luasrc/tools/status.lua index e5c517f238..3ececa8f13 100644 --- a/modules/admin-core/luasrc/tools/status.lua +++ b/modules/admin-core/luasrc/tools/status.lua @@ -153,35 +153,40 @@ function wifi_network(id) return { } end -function switch_status(dev) - local ports = { } - local swc = io.popen("swconfig dev %q show" % dev, "r") - if swc then - local l - repeat - l = swc:read("*l") - if l then - local port, up = l:match("port:(%d+) link:(%w+)") - if port then - local speed = l:match(" speed:(%d+)") - local duplex = l:match(" (%w+)-duplex") - local txflow = l:match(" (txflow)") - local rxflow = l:match(" (rxflow)") - local auto = l:match(" (auto)") +function switch_status(devs) + local dev + local switches = { } + for dev in devs:gmatch("[^%s,]+") do + local ports = { } + local swc = io.popen("swconfig dev %q show" % dev, "r") + if swc then + local l + repeat + l = swc:read("*l") + if l then + local port, up = l:match("port:(%d+) link:(%w+)") + if port then + local speed = l:match(" speed:(%d+)") + local duplex = l:match(" (%w+)-duplex") + local txflow = l:match(" (txflow)") + local rxflow = l:match(" (rxflow)") + local auto = l:match(" (auto)") - ports[#ports+1] = { - port = tonumber(port) or 0, - speed = tonumber(speed) or 0, - link = (up == "up"), - duplex = (duplex == "full"), - rxflow = (not not rxflow), - txflow = (not not txflow), - auto = (not not auto) - } + ports[#ports+1] = { + port = tonumber(port) or 0, + speed = tonumber(speed) or 0, + link = (up == "up"), + duplex = (duplex == "full"), + rxflow = (not not rxflow), + txflow = (not not txflow), + auto = (not not auto) + } + end end - end - until not l - swc:close() + until not l + swc:close() + end + switches[dev] = ports end - return ports + return switches end diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/vlan.lua b/modules/admin-full/luasrc/model/cbi/admin_network/vlan.lua index 9dc3f2f636..b0de19133d 100644 --- a/modules/admin-full/luasrc/model/cbi/admin_network/vlan.lua +++ b/modules/admin-full/luasrc/model/cbi/admin_network/vlan.lua @@ -14,6 +14,8 @@ You may obtain a copy of the License at m = Map("network", translate("Switch"), translate("The network ports on this device can be combined to several VLANs in which computers can communicate directly with each other. VLANs are often used to separate different network segments. Often there is by default one Uplink port for a connection to the next greater network like the internet and other ports for a local network.")) +local switches = { } + m.uci:foreach("network", "switch", function(x) local sid = x['.name'] @@ -199,7 +201,7 @@ m.uci:foreach("network", "switch", end - local vid = s:option(Value, has_vlan4k or "vlan", "VLAN ID") + local vid = s:option(Value, has_vlan4k or "vlan", "VLAN ID", "
" % switch_name) vid.rmempty = false vid.forcewrite = true @@ -276,12 +278,13 @@ m.uci:foreach("network", "switch", port_opts[#port_opts+1] = po end - - -- Switch status template - s = m:section(SimpleSection) - s.template = "admin_network/switch_status" - s.switch = switch_name + switches[#switches+1] = switch_name end ) +-- Switch status template +s = m:section(SimpleSection) +s.template = "admin_network/switch_status" +s.switches = switches + return m diff --git a/modules/admin-full/luasrc/view/admin_network/switch_status.htm b/modules/admin-full/luasrc/view/admin_network/switch_status.htm index 0b284833e7..b299575e2f 100644 --- a/modules/admin-full/luasrc/view/admin_network/switch_status.htm +++ b/modules/admin-full/luasrc/view/admin_network/switch_status.htm @@ -1,31 +1,28 @@