Update app.py
This commit is contained in:
parent
b922846bbd
commit
0c473e034d
1 changed files with 34 additions and 2 deletions
36
app.py
36
app.py
|
|
@ -8,7 +8,7 @@ from flask import Flask, render_template_string, jsonify, url_for, redirect, ren
|
|||
|
||||
app = Flask(__name__)
|
||||
|
||||
from modules.parse import run_bgp_curl_command, run_arp_curl_command, run_neighbors_curl_command, run_interfaces_curl_command, run_bgp_route_curl_command, run_rpki_cache_connection_curl_command, run_rpki_lookup_curl_command
|
||||
from modules.parse import run_bgp_curl_command, run_arp_curl_command, run_neighbors_curl_command, run_interfaces_curl_command, run_bgp_route_curl_command, run_rpki_cache_connection_curl_command, run_rpki_lookup_curl_command, run_bgp_neighbor_detail_curl_command, run_bfd_peers_curl_command, run_bfd_peer_detail_curl_command
|
||||
|
||||
from modules.bgp import parse_bgp_data, generate_bgp_json
|
||||
|
||||
|
|
@ -24,6 +24,8 @@ from modules.librenms import get_port_id, fetch_graph_base64
|
|||
|
||||
from modules.rpki import parse_rpki_cache_data, parse_rpki_lookup_data
|
||||
|
||||
from modules.bfd import parse_bfd_peers_data
|
||||
|
||||
from modules.visual_route import generate_visual_route_graph
|
||||
|
||||
@app.context_processor
|
||||
|
|
@ -53,7 +55,21 @@ def bgp():
|
|||
def bgp_json():
|
||||
bgp_data = run_bgp_curl_command()
|
||||
ipv4_info, ipv4_peers, ipv6_info, ipv6_peers = parse_bgp_data(bgp_data)
|
||||
return jsonify(generate_bgp_json(ipv4_info, ipv4_peers, ipv6_info, ipv6_peers))
|
||||
|
||||
bfd_data = run_bfd_peers_curl_command()
|
||||
bfd_peers = parse_bfd_peers_data(bfd_data)
|
||||
|
||||
return jsonify(generate_bgp_json(ipv4_info, ipv4_peers, ipv6_info, ipv6_peers, bfd_peers))
|
||||
|
||||
@app.route('/bfd/peer/<string:peer_ip>')
|
||||
def bfd_peer_detail(peer_ip):
|
||||
try:
|
||||
raw_data = run_bfd_peer_detail_curl_command(peer_ip)
|
||||
bfd_details = raw_data.get('data', 'Geen data gevonden voor deze BFD peer.')
|
||||
return render_template('bfd_peer_detail.html', peer_ip=peer_ip, bfd_data=bfd_details)
|
||||
except Exception as e:
|
||||
error_message = f"Kon de BFD-details niet ophalen: {e}"
|
||||
return render_template('bfd_peer_detail.html', peer_ip=peer_ip, error=error_message)
|
||||
|
||||
@app.route("/arp")
|
||||
def arp():
|
||||
|
|
@ -75,6 +91,22 @@ def neighborsp_json():
|
|||
neighbors_table = parse_neighbors_data(neighbors_data)
|
||||
return jsonify(generate_neighbors_json(neighbors_table))
|
||||
|
||||
@app.route('/bgp/neighbor/<string:ip_version>/<string:neighbor_ip>')
|
||||
def bgp_neighbor_detail(ip_version, neighbor_ip):
|
||||
if ip_version not in ['ipv4', 'ipv6']:
|
||||
abort(404)
|
||||
|
||||
try:
|
||||
raw_data = run_bgp_neighbor_detail_curl_command(ip_version, neighbor_ip)
|
||||
|
||||
neighbor_details = raw_data.get('data', 'No data found for this neighbor.')
|
||||
|
||||
return render_template('bgp_neighbor_detail.html', neighbor_ip=neighbor_ip, neighbor_data=neighbor_details)
|
||||
except Exception as e:
|
||||
error_message = f"Unable to retrieve details: {e}"
|
||||
return render_template('bgp_neighbor_detail.html', neighbor_ip=neighbor_ip, error=error_message)
|
||||
|
||||
|
||||
@app.route('/interfaces')
|
||||
def interface_table_page():
|
||||
return render_template("interfaces.html")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue