1
0
Fork 0
mirror of https://github.com/sileht/bird-lg.git synced 2024-12-22 12:34:42 +01:00

Add show route for <prefix> all

This commit is contained in:
Mehdi ABAAKOUK 2011-12-18 12:32:00 +01:00
parent a9e511f12f
commit fb22ef2ff8
2 changed files with 22 additions and 7 deletions

14
lg.py
View file

@ -37,10 +37,10 @@ def check_ipv6(n):
def hello():
return render_template('index.html')
@app.route("/<host>/<proto>/prefix/")
@app.route("/<host>/<proto>/prefix/<prefix>")
@app.route("/<host>/<proto>/prefix/<prefix>/<mask>")
def prefix(host, proto, prefix="", mask=""):
@app.route("/<host>/<proto>/prefix<all>/")
@app.route("/<host>/<proto>/prefix<all>/<prefix>")
@app.route("/<host>/<proto>/prefix<all>/<prefix>/<mask>")
def prefix(host, proto, prefix="", mask="", all=False):
qprefix = prefix
@ -69,11 +69,11 @@ def prefix(host, proto, prefix="", mask=""):
else:
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 mask: qprefix = qprefix +"/"+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:
string = "\n".join([ s.replace("1007-"," ") for s in string.split("\n") if not s.startswith("0000") ])
output +='<pre>' + string + '</pre>'
@ -87,7 +87,7 @@ def prefix(host, proto, prefix="", mask=""):
else:
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/<name>")

View file

@ -30,6 +30,13 @@
$("#submit").click()
}
break;
case "prefix_detail":
$("#submit").show()
$("#prefix").show()
if ($("#prefix").val()) {
$("#submit").click()
}
break;
}
});
@ -46,6 +53,9 @@
case "prefix":
document.location = "/" + $("#host").val() + "/prefix/" + $("#prefix").val() ;
break;
case "prefix_detail":
document.location = "/" + $("#host").val() + "/prefix_detail/" + $("#prefix").val() ;
break;
}
});
@ -72,6 +82,10 @@
if ($("#prefix").val()) {
$("#submit").click()
}
case "prefix_detail":
if ($("#prefix").val()) {
$("#submit").click()
}
break;
}
});
@ -91,6 +105,7 @@
<option value="summary">summary</option>
<option value="detail">detail</option>
<option value="prefix">prefix</option>
<option value="prefix_detail">prefix detail</option>
</select>
<input type="text" id="name" style="display:none" value="{{ name }}"></input>