From b39e4b1400eced65df8aa6c8bd4d56e663d8112a Mon Sep 17 00:00:00 2001
From: iFargle
Date: Tue, 28 Mar 2023 20:02:58 +0900
Subject: [PATCH] test
---
renderer.py | 113 ++++++++++++++++++++++++++++------------------------
1 file changed, 60 insertions(+), 53 deletions(-)
diff --git a/renderer.py b/renderer.py
index c88320c..133db85 100644
--- a/renderer.py
+++ b/renderer.py
@@ -679,6 +679,10 @@ def render_routes():
# If there are no routes, just exit:
if len(all_routes) == 0: return Markup("
There are no routes to display!")
+ # Testing...
+
+ return Markup("
There are no routes to display!")
+
route_content = ""
failover_content = ""
exit_content = ""
@@ -757,7 +761,7 @@ def render_routes():
##############################################################################################
# Step 2: Get all failover routes only. Add a separate table per failover prefix
failover_route_prefix = []
- failover_content = markup_pre+failover_title
+ failover_available = False
for route in all_routes["routes"]:
# Get relevant info:
prefix = route["prefix"]
@@ -775,60 +779,63 @@ def render_routes():
if route["prefix"] not in failover_route_prefix:
# append the prefix to the failover_route_prefix list
failover_route_prefix.append(prefix)
+ failover_available = True
- # Build the display for failover routes:
- for route_prefix in failover_route_prefix:
- # Get all route_id's associated with the route prefix:
- failover_content += """
-
-
"""+str(route_prefix)+"""
-
-
-
- | Machine |
- Enabled |
- Primary |
-
-
-
- """
-
- # Get all route ID's associated with the route_prefix:
- route_id_list = []
- for route in all_routes["routes"]:
- if route["prefix"] == route_prefix:
- route_id_list.append(route["id"])
-
- # Build the display:
- for route_id in route_id_list:
- # Get info on every route in the list:
- machine = all_routes["routes"][int(route_id)]["machine"]["givenName"]
- machine_id = all_routes["routes"][int(route_id)]["machine"]["id"]
- is_primary = all_routes["routes"][int(route_id)]["isPrimary"]
- is_enabled = all_routes["routes"][int(route_id)]["enabled"]
- app.logger.debug("Machine: [%s] %s : %s / %s", str(machine_id), str(machine), str(is_enabled), str(is_primary))
-
- # Set up the display code:
- enabled = "fiber_manual_record"
- disabled = "fiber_manual_record"
-
- # Set the displays:
- enabled_display = disabled
- primary_display = disabled
-
- if is_enabled: enabled_display = enabled
- if is_primary: primary_display = enabled
-
- # Build a simple table for all non-exit routes:
+ if failover_available:
+ failover_content = markup_pre+failover_title
+ # Build the display for failover routes:
+ for route_prefix in failover_route_prefix:
+ # Get all route_id's associated with the route prefix:
failover_content += """
-
- | """+str(machine)+""" |
- """+str(enabled_display)+""" |
- """+str(primary_display)+""" |
-
- """
- failover_content += "
"
- failover_content += markup_post
+
+
"""+str(route_prefix)+"""
+
+
+
+ | Machine |
+ Enabled |
+ Primary |
+
+
+
+ """
+
+ # Get all route ID's associated with the route_prefix:
+ route_id_list = []
+ for route in all_routes["routes"]:
+ if route["prefix"] == route_prefix:
+ route_id_list.append(route["id"])
+
+ # Build the display:
+ for route_id in route_id_list:
+ # Get info on every route in the list:
+ machine = all_routes["routes"][int(route_id)]["machine"]["givenName"]
+ machine_id = all_routes["routes"][int(route_id)]["machine"]["id"]
+ is_primary = all_routes["routes"][int(route_id)]["isPrimary"]
+ is_enabled = all_routes["routes"][int(route_id)]["enabled"]
+ app.logger.debug("Machine: [%s] %s : %s / %s", str(machine_id), str(machine), str(is_enabled), str(is_primary))
+
+ # Set up the display code:
+ enabled = "fiber_manual_record"
+ disabled = "fiber_manual_record"
+
+ # Set the displays:
+ enabled_display = disabled
+ primary_display = disabled
+
+ if is_enabled: enabled_display = enabled
+ if is_primary: primary_display = enabled
+
+ # Build a simple table for all non-exit routes:
+ failover_content += """
+
+ | """+str(machine)+""" |
+ """+str(enabled_display)+""" |
+ """+str(primary_display)+""" |
+
+ """
+ failover_content += "
"
+ failover_content += markup_post
##############################################################################################
# Step 3: Get exit nodes only:
exit_node_list = []