Web looking glass for FRRouting
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.5 KiB

# Explicitly provide key and passphrase
from paramiko import SSHClient, AutoAddPolicy
import time, re, os, os.path
from graphviz import Digraph
import config
#Diagram paths generation
def gen_diagram(as_list, lg_asn, fname, self_graph=False):
img_path = f"static/img/{fname}"
g = Digraph('G', filename= img_path, format='svg', graph_attr={'rankdir':'LR', 'concentrate': 'true'})
as_path_count = 0
g.edge("AS" + lg_asn, "AS" + lg_asn + " ")
return True
for as_path in as_list:
as_path = as_path.split(" ")
for asn in config.ignored_asn:
as_path = list(filter((asn).__ne__, as_path))
original_asn = as_path[0]
border_asn = as_path[-1]
except IndexError:
original_asn = ""
border_asn = ""
precedent_asn = original_asn
for asn in as_path:
if asn != original_asn:
g.edge("AS" + asn, "AS" + precedent_asn)
precedent_asn = asn
if asn == border_asn:
g.edge("AS" + lg_asn, "AS" + asn)
precedent_asn = asn
as_path_count += 1
#If empty as_path
if as_path_count == 0:
return False
#Delete GraphViz file
except Exception as e:
print(f"Can't remove Graphviz file. Ignoring...\n{e}")
return True