-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
luci-app-babeld: add babeld overview
Add overview of babeld status, xroutes and routes. Signed-off-by: Nick Hainke <[email protected]>
- Loading branch information
1 parent
b43a5da
commit 35761aa
Showing
4 changed files
with
161 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
include $(TOPDIR)/rules.mk | ||
|
||
LUCI_TITLE:=LuCI support for babeld | ||
LUCI_DEPENDS:=+babeld +luci-compat | ||
LUCI_PKGARCH:=all | ||
|
||
include ../../luci.mk | ||
|
||
# call BuildPackage - OpenWrt buildroot signature | ||
|
127 changes: 127 additions & 0 deletions
127
applications/luci-app-babeld/luasrc/model/cbi/babeld.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
m = Map("babeld", translate("Babeld Overview")) | ||
m.pageaction = false | ||
|
||
s = m:section(NamedSection, "__babeldoverview__") | ||
|
||
function s.render(self, sid) | ||
local tpl = require "luci.template" | ||
|
||
tpl.render_string([[ | ||
<% | ||
local utl = require "luci.util" | ||
local v6_port = 33123 | ||
-- FIXME: check if call is correct | ||
local dump = utl.exec("(echo dump | nc ::1 %d)" % v6_port) | ||
local t = {} | ||
for strline in string.gmatch(dump, "[^\n]+") do | ||
t[#t+1] = strline; | ||
end | ||
local babel_version = t[1] | ||
local babeld_version = t[2] | ||
local babeld_host = string.split(t[3], " ")[2] | ||
local babeld_id = string.split(t[4], " ")[2] | ||
local babeld_status = t[5] | ||
%> | ||
<div class="cbi-section-node"> | ||
<h3>Babel-Info</h3> | ||
<div class="table" id=babel_status_main"> | ||
<div class="tr table-titles"> | ||
<div class="th">Version</div> | ||
<div class="th">Version-Daemon</div> | ||
<div class="th">Host</div> | ||
<div class="th">ID</div> | ||
<div class="th">Status</div> | ||
</div> | ||
<div class="tr"> | ||
<div class="td"><%= babel_version %></div> | ||
<div class="td"><%= babeld_version %></div> | ||
<div class="td"><%= babeld_host %></div> | ||
<div class="td"><%= babeld_id %></div> | ||
<div class="td"><%= babeld_status %></div> | ||
</div> | ||
</div> | ||
</div> | ||
<% | ||
local xroutes = {} | ||
for key,value in ipairs(t) do | ||
if string.match(value, "xroute") then | ||
xroutes[#xroutes+1] = value | ||
end | ||
end | ||
%> | ||
<div class="cbi-section-node"> | ||
<h3>X-Routes</h3> | ||
<div class="table" id=babel_overview_xroute"> | ||
<div class="tr table-titles"> | ||
<div class="th">Route</div> | ||
<div class="th">Prefix</div> | ||
<div class="th">From</div> | ||
<div class="th">Metric</div> | ||
</div> | ||
<% | ||
for key,route in ipairs(xroutes) do | ||
local route_sep = string.split(route," ") | ||
%> | ||
<div class="tr"> | ||
<div class="td"><%= route_sep[3] %></div> | ||
<div class="td"><%= route_sep[5] %></div> | ||
<div class="td"><%= route_sep[7] %></div> | ||
<div class="td"><%= route_sep[9] %></div> | ||
</div> | ||
<% | ||
end | ||
%> | ||
</div> | ||
</div> | ||
<% | ||
local routes = {} | ||
for key,value in ipairs(t) do | ||
if string.match(value, "add route") then | ||
routes[#routes+1] = value | ||
end | ||
end | ||
%> | ||
<div class="cbi-section-node"> | ||
<h3>Routes</h3> | ||
<div class="table" id=babel_overview_route"> | ||
<div class="tr table-titles"> | ||
<div class="th">Prefix</div> | ||
<div class="th">From</div> | ||
<div class="th">Installed</div> | ||
<div class="th">ID</div> | ||
<div class="th">Metric</div> | ||
<div class="th">Ref-Metric</div> | ||
<div class="th">Via</div> | ||
<div class="th">Interface</div> | ||
</div> | ||
<% | ||
for key,route in ipairs(routes) do | ||
local route_sep = string.split(route," ") | ||
%> | ||
<div class="tr"> | ||
<div class="td"><%= route_sep[5] %></div> | ||
<div class="td"><%= route_sep[7] %></div> | ||
<div class="td"><%= route_sep[9] %></div> | ||
<div class="td"><%= route_sep[11] %></div> | ||
<div class="td"><%= route_sep[13] %></div> | ||
<div class="td"><%= route_sep[15] %></div> | ||
<div class="td"><%= route_sep[17] %></div> | ||
<div class="td"><%= route_sep[19] %></div> | ||
</div> | ||
<% | ||
end | ||
%> | ||
</div> | ||
</div> | ||
]]) | ||
end | ||
|
||
return m |
13 changes: 13 additions & 0 deletions
13
applications/luci-app-babeld/root/usr/share/luci/menu.d/luci-app-babeld.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"admin/status/babeld": { | ||
"title": "Babeld", | ||
"action": { | ||
"type": "cbi", | ||
"path": "babeld", | ||
"post": { "cbi.submit": true } | ||
}, | ||
"depends": { | ||
"acl": [ "luci-app-babeld" ] | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
applications/luci-app-babeld/root/usr/share/rpcd/acl.d/luci-app-babeld.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"luci-app-babeld": { | ||
"description": "Grant UCI access for babeld", | ||
"read": { | ||
"uci": [ "babeld" ] | ||
}, | ||
"write": { | ||
"uci": [ "babeld" ] | ||
} | ||
} | ||
} |