From 3f288ef2a025af51d2cd8d149c2e11dd638c3aa9 Mon Sep 17 00:00:00 2001 From: jim Date: Sun, 16 Jun 2024 09:09:34 -0700 Subject: [PATCH] Move link info to router page --- mnet/driver.py | 12 +++++++++++- mnet/frr_topo.py | 6 ++++-- mnet/templates/main.html | 31 +++++++++++++++++-------------- mnet/templates/router.html | 18 ++++++++++-------- 4 files changed, 42 insertions(+), 25 deletions(-) diff --git a/mnet/driver.py b/mnet/driver.py index 51cd5e4..6c0fdb1 100644 --- a/mnet/driver.py +++ b/mnet/driver.py @@ -115,6 +115,16 @@ def root(request: Request): good, total = context.frrt.update_monitor_stats() routers = context.frrt.get_router_list() links = context.frrt.get_link_list() + link_stats = {} + link_stats["count"] = len(links) + up_count = 0 + for link in links: + up1, up2 = context.frrt.get_link_state(link[0], link[1]) + if up1 and up2: + up_count += 1 + + link_stats["up_count"] = up_count + src_stats = context.frrt.get_stat_samples() stats = [] for stat in src_stats: @@ -136,7 +146,7 @@ def root(request: Request): "current_time": current_time, "run_time": run_time, "routers": routers, - "links": links, + "link_stats": link_stats, "events": events, "stats": stats, "ping_stats": ping_stats, diff --git a/mnet/frr_topo.py b/mnet/frr_topo.py index d247293..bef4ccd 100644 --- a/mnet/frr_topo.py +++ b/mnet/frr_topo.py @@ -574,9 +574,11 @@ def get_router(self, name: str): for neighbor in self.graph.adj[name].keys(): edge = self.graph.adj[name][neighbor] result["neighbors"][neighbor] = { - "ip": edge["ip"][neighbor], + "ip_local": edge["ip"][name], + "ip_remote": edge["ip"][neighbor], "up": self.get_link_state(name, neighbor), - "intf": edge["intf"][neighbor], + "intf_local": edge["intf"][name], + "intf_remote": edge["intf"][neighbor], } return result diff --git a/mnet/templates/main.html b/mnet/templates/main.html index e471eaa..46b6611 100644 --- a/mnet/templates/main.html +++ b/mnet/templates/main.html @@ -92,6 +92,23 @@

SatNetMiniSim

); +

Links

+ + +

Events

+ + +

Ground Stations

-

Links ({{ info["links"]| length}})

- - -

Events

- diff --git a/mnet/templates/router.html b/mnet/templates/router.html index 105b20c..56cdcc2 100644 --- a/mnet/templates/router.html +++ b/mnet/templates/router.html @@ -7,16 +7,18 @@

Router {{ router["name"] }}

Interfaces

Connectivity