Commit 36d78803 authored by Tom Niget's avatar Tom Niget

Fix graph in demo

parent 157ddf00
...@@ -94,6 +94,7 @@ class Re6stNode(nemu.Node): ...@@ -94,6 +94,7 @@ class Re6stNode(nemu.Node):
def __init__(self, name, short): def __init__(self, name, short):
super().__init__() super().__init__()
print("Re6stNode ctor %r %r" % (name, short))
self.name = name self.name = name
self.short = short self.short = short
self.Popen(('sysctl', '-q', self.Popen(('sysctl', '-q',
...@@ -427,11 +428,12 @@ def route_svg(ipv4, z=4, default=type('', (), {'short': None})): ...@@ -427,11 +428,12 @@ def route_svg(ipv4, z=4, default=type('', (), {'short': None})):
g = graph[n] = defaultdict(list) g = graph[n] = defaultdict(list)
g: dict[tuple[Re6stNode, bool], list[Re6stNode]] g: dict[tuple[Re6stNode, bool], list[Re6stNode]]
for r in n.get_routes(): for r in n.get_routes():
print("route_svg: %r" % r)
if (r.prefix and r.prefix.startswith('10.42.') if ipv4 else if (r.prefix and r.prefix.startswith('10.42.') if ipv4 else
r.prefix is None or r.prefix.startswith('2001:db8:')): r.prefix is None or r.prefix.startswith('2001:db8:')):
try: try:
g[node_by_ll(r.nexthop)].append( if r.prefix:
node_by_ll(r.prefix)[0] if r.prefix else default) g[node_by_ll(r.nexthop)].append(node_by_ll(r.prefix)[0])
except KeyError: except KeyError:
pass pass
gv = ["digraph { splines = true; edge[color=grey, labelangle=0];"] gv = ["digraph { splines = true; edge[color=grey, labelangle=0];"]
...@@ -452,7 +454,9 @@ def route_svg(ipv4, z=4, default=type('', (), {'short': None})): ...@@ -452,7 +454,9 @@ def route_svg(ipv4, z=4, default=type('', (), {'short': None})):
p2: Re6stNode p2: Re6stNode
l2: list[str] = [] l2: list[str] = []
arrowhead = 'none' arrowhead = 'none'
for r2 in sorted(r2.short for r2 in r): print("r=%r" % r)
print("processing: " + ", ".join("%r" % ((r2.name, r2.short),) for r2 in r))
for r2 in sorted(r2.short if r2.short else "NONE" for r2 in r):
if r2: if r2:
if r2 == p2.short: if r2 == p2.short:
r2 = '<font color="grey">%s</font>' % r2 r2 = '<font color="grey">%s</font>' % r2
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment