Made all hosts available at /all, much shorter URLs when using many hosts
This commit is contained in:
parent
49ab7b003b
commit
3c76d1679f
28
lg.py
28
lg.py
@ -187,14 +187,12 @@ def inject_commands():
|
|||||||
return dict(commands=commands, commands_dict=commands_dict)
|
return dict(commands=commands, commands_dict=commands_dict)
|
||||||
|
|
||||||
|
|
||||||
@app.context_processor
|
|
||||||
def inject_all_host():
|
|
||||||
return dict(all_hosts="+".join(app.config["PROXY"].keys()))
|
|
||||||
|
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
def hello():
|
def hello():
|
||||||
return redirect("/summary/%s/ipv4" % "+".join(app.config["PROXY"].keys()))
|
if app.config.get("UNIFIED_DAEMON", False):
|
||||||
|
return redirect("/summary/all")
|
||||||
|
else:
|
||||||
|
return redirect("/summary/all/ipv4")
|
||||||
|
|
||||||
|
|
||||||
def error_page(text):
|
def error_page(text):
|
||||||
@ -237,13 +235,15 @@ SUMMARY_UNWANTED_PROTOS = ["Kernel", "Static", "Device", "BFD"]
|
|||||||
@app.route("/summary/<hosts>")
|
@app.route("/summary/<hosts>")
|
||||||
@app.route("/summary/<hosts>/<proto>")
|
@app.route("/summary/<hosts>/<proto>")
|
||||||
def summary(hosts, proto="ipv4"):
|
def summary(hosts, proto="ipv4"):
|
||||||
|
|
||||||
set_session("summary", hosts, proto, "")
|
set_session("summary", hosts, proto, "")
|
||||||
command = "show protocols"
|
command = "show protocols"
|
||||||
|
|
||||||
summary = {}
|
summary = {}
|
||||||
errors = []
|
errors = []
|
||||||
for host in hosts.split("+"):
|
hosts = hosts.split("+")
|
||||||
|
if hosts == ["all"]:
|
||||||
|
hosts = app.config["PROXY"].keys()
|
||||||
|
for host in hosts:
|
||||||
ret, res = bird_command(host, proto, command)
|
ret, res = bird_command(host, proto, command)
|
||||||
res = res.split("\n")
|
res = res.split("\n")
|
||||||
|
|
||||||
@ -298,7 +298,10 @@ def detail(hosts, proto):
|
|||||||
|
|
||||||
detail = {}
|
detail = {}
|
||||||
errors = []
|
errors = []
|
||||||
for host in hosts.split("+"):
|
hosts = hosts.split("+")
|
||||||
|
if hosts == ["all"]:
|
||||||
|
hosts = app.config["PROXY"].keys()
|
||||||
|
for host in hosts:
|
||||||
ret, res = bird_command(host, proto, command)
|
ret, res = bird_command(host, proto, command)
|
||||||
res = res.split("\n")
|
res = res.split("\n")
|
||||||
|
|
||||||
@ -344,7 +347,10 @@ def traceroute(hosts, proto):
|
|||||||
|
|
||||||
errors = []
|
errors = []
|
||||||
infos = {}
|
infos = {}
|
||||||
for host in hosts.split("+"):
|
hosts = hosts.split("+")
|
||||||
|
if hosts == ["all"]:
|
||||||
|
hosts = app.config["PROXY"].keys()
|
||||||
|
for host in hosts:
|
||||||
status, resultat = bird_proxy(host, proto, "traceroute", q)
|
status, resultat = bird_proxy(host, proto, "traceroute", q)
|
||||||
if status is False:
|
if status is False:
|
||||||
errors.append("%s" % resultat)
|
errors.append("%s" % resultat)
|
||||||
@ -689,6 +695,8 @@ def show_route(request_type, hosts, proto):
|
|||||||
detail = {}
|
detail = {}
|
||||||
errors = []
|
errors = []
|
||||||
hosts = hosts.split("+")
|
hosts = hosts.split("+")
|
||||||
|
if hosts == ["all"]:
|
||||||
|
hosts = app.config["PROXY"].keys()
|
||||||
allhosts = hosts[:]
|
allhosts = hosts[:]
|
||||||
for host in allhosts:
|
for host in allhosts:
|
||||||
ret, res = bird_command(host, proto, command)
|
ret, res = bird_command(host, proto, command)
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||||
<a class="navbar-brand" href="/">{{config.DOMAIN|capitalize}}</a>
|
<a class="navbar-brand" href="/">{{config.DOMAIN|capitalize}}</a>
|
||||||
<ul class="nav nav-pills">
|
<ul class="nav nav-pills">
|
||||||
<li class="nav-item hosts mr-1"><a class="nav-link" id="{{all_hosts}}" href="#">all</a></li>
|
<li class="nav-item hosts mr-1"><a class="nav-link" id="all" href="#">all</a></li>
|
||||||
|
|
||||||
{% for host in config.PROXY %}
|
{% for host in config.PROXY %}
|
||||||
<li class="nav-item hosts mr-1"><a class="nav-link" id="{{host}}" href="#">{{host}}</a></li>
|
<li class="nav-item hosts mr-1"><a class="nav-link" id="{{host}}" href="#">{{host}}</a></li>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user