From ab2409752fc8992a172e8caffa64fa19beafbcb7 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Tue, 29 Oct 2024 21:58:47 +0100 Subject: utils: routers --- utils/routers/routers.go | 49 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) (limited to 'utils/routers') diff --git a/utils/routers/routers.go b/utils/routers/routers.go index 0afb355..24d25e3 100644 --- a/utils/routers/routers.go +++ b/utils/routers/routers.go @@ -1,4 +1,51 @@ package routers -type Routers struct { +import ( + "fmt" + Ipam "utils/ipam" +) + +func RunRouters(ipam *Ipam.Ipam) error { + routers := ipam.Routers + + fmt.Printf("digraph {\n") + //fmt.Printf(" layout=dot\n") + //fmt.Printf(" layout=twopi\n") + fmt.Printf(" layout=fdp\n") + //fmt.Printf(" layout=circo\n") + //fmt.Printf(" layout=neato\n") + //fmt.Printf(" ranksep=3\n") + //fmt.Printf(" ratio=auto\n") + //fmt.Printf(" rankdir=LR\n") + //fmt.Printf(" rankdir=RL\n") + fmt.Printf(" rankdir=TB\n") + //fmt.Printf(" sep=3\n") + //fmt.Printf(" overlap_scaling=-10\n") + fmt.Printf("node [len=10];") + fmt.Printf("node [shape=box];") + fmt.Printf("overlap=false") + + fmt.Printf("\n") + fmt.Printf(" # Nodes\n") + for _, r := range routers { + fmt.Printf(" %s [ label = \"%s\"];\n", r.Name, r.Name) + } + + fmt.Printf("\n") + fmt.Printf(" # Connections\n") + for _, n := range routers { + fmt.Printf(" %s [ root = true ];\n", n.Name) + } + + fmt.Printf("\n") + fmt.Printf(" # Peers\n") + for _, r := range routers { + for _, p := range r.Peers { + fmt.Printf(" %s -> %s", r.Name, p.Name) + fmt.Printf(";\n") + } + } + fmt.Printf("}\n") + + return nil } -- cgit v1.2.3