mirror of
https://github.com/sileht/bird-lg.git
synced 2024-11-21 22:44:43 +01:00
Add show route for <prefix> all
This commit is contained in:
parent
a9e511f12f
commit
fb22ef2ff8
14
lg.py
14
lg.py
|
@ -37,10 +37,10 @@ def check_ipv6(n):
|
||||||
def hello():
|
def hello():
|
||||||
return render_template('index.html')
|
return render_template('index.html')
|
||||||
|
|
||||||
@app.route("/<host>/<proto>/prefix/")
|
@app.route("/<host>/<proto>/prefix<all>/")
|
||||||
@app.route("/<host>/<proto>/prefix/<prefix>")
|
@app.route("/<host>/<proto>/prefix<all>/<prefix>")
|
||||||
@app.route("/<host>/<proto>/prefix/<prefix>/<mask>")
|
@app.route("/<host>/<proto>/prefix<all>/<prefix>/<mask>")
|
||||||
def prefix(host, proto, prefix="", mask=""):
|
def prefix(host, proto, prefix="", mask="", all=False):
|
||||||
qprefix = prefix
|
qprefix = prefix
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,11 +69,11 @@ def prefix(host, proto, prefix="", mask=""):
|
||||||
else:
|
else:
|
||||||
allowed = False
|
allowed = False
|
||||||
|
|
||||||
output = '<h3>' + host + ' (' + proto + ') show route for ' + prefix + (prefix != qprefix and " (%s)"%qprefix or "") + (mask and '/' + mask or '' ) + '</h3>'
|
output = '<h3>' + host + ' (' + proto + ') show route for ' + prefix + (prefix != qprefix and " (%s)"%qprefix or "") + (mask and '/' + mask or '' ) + (all and " all" or "") + '</h3>'
|
||||||
if allowed:
|
if allowed:
|
||||||
if mask: qprefix = qprefix +"/"+mask
|
if mask: qprefix = qprefix +"/"+mask
|
||||||
if mask: prefix = prefix +"/"+mask
|
if mask: prefix = prefix +"/"+mask
|
||||||
ok, string = get_cmd_result(host , proto, "show route for " + qprefix)
|
ok, string = get_cmd_result(host , proto, "show route for " + qprefix + (all and "all" or ""))
|
||||||
if ok:
|
if ok:
|
||||||
string = "\n".join([ s.replace("1007-"," ") for s in string.split("\n") if not s.startswith("0000") ])
|
string = "\n".join([ s.replace("1007-"," ") for s in string.split("\n") if not s.startswith("0000") ])
|
||||||
output +='<pre>' + string + '</pre>'
|
output +='<pre>' + string + '</pre>'
|
||||||
|
@ -87,7 +87,7 @@ def prefix(host, proto, prefix="", mask=""):
|
||||||
else:
|
else:
|
||||||
output += 'prefix missing'
|
output += 'prefix missing'
|
||||||
|
|
||||||
return render_template('index.html', output=output, typ="prefix", host=host+"/"+proto, prefix=prefix)
|
return render_template('index.html', output=output, typ="prefix" + (all and "_detail" or ""), host=host+"/"+proto, prefix=prefix)
|
||||||
|
|
||||||
@app.route("/<host>/<proto>/detail/")
|
@app.route("/<host>/<proto>/detail/")
|
||||||
@app.route("/<host>/<proto>/detail/<name>")
|
@app.route("/<host>/<proto>/detail/<name>")
|
||||||
|
|
|
@ -30,6 +30,13 @@
|
||||||
$("#submit").click()
|
$("#submit").click()
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "prefix_detail":
|
||||||
|
$("#submit").show()
|
||||||
|
$("#prefix").show()
|
||||||
|
if ($("#prefix").val()) {
|
||||||
|
$("#submit").click()
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -46,6 +53,9 @@
|
||||||
case "prefix":
|
case "prefix":
|
||||||
document.location = "/" + $("#host").val() + "/prefix/" + $("#prefix").val() ;
|
document.location = "/" + $("#host").val() + "/prefix/" + $("#prefix").val() ;
|
||||||
break;
|
break;
|
||||||
|
case "prefix_detail":
|
||||||
|
document.location = "/" + $("#host").val() + "/prefix_detail/" + $("#prefix").val() ;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -72,6 +82,10 @@
|
||||||
if ($("#prefix").val()) {
|
if ($("#prefix").val()) {
|
||||||
$("#submit").click()
|
$("#submit").click()
|
||||||
}
|
}
|
||||||
|
case "prefix_detail":
|
||||||
|
if ($("#prefix").val()) {
|
||||||
|
$("#submit").click()
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -91,6 +105,7 @@
|
||||||
<option value="summary">summary</option>
|
<option value="summary">summary</option>
|
||||||
<option value="detail">detail</option>
|
<option value="detail">detail</option>
|
||||||
<option value="prefix">prefix</option>
|
<option value="prefix">prefix</option>
|
||||||
|
<option value="prefix_detail">prefix detail</option>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<input type="text" id="name" style="display:none" value="{{ name }}"></input>
|
<input type="text" id="name" style="display:none" value="{{ name }}"></input>
|
||||||
|
|
Loading…
Reference in a new issue