diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2024-10-29 21:58:47 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2024-10-29 21:58:47 +0100 |
commit | ab2409752fc8992a172e8caffa64fa19beafbcb7 (patch) | |
tree | bec8f72367bba8f584893f76219b034943039247 /utils/routers | |
parent | af7c5d500b76a6f2db790a1a8e0480f370da81ce (diff) | |
download | infra-ab2409752fc8992a172e8caffa64fa19beafbcb7.tar.gz infra-ab2409752fc8992a172e8caffa64fa19beafbcb7.tar.bz2 infra-ab2409752fc8992a172e8caffa64fa19beafbcb7.tar.xz infra-ab2409752fc8992a172e8caffa64fa19beafbcb7.zip |
utils: routers
Diffstat (limited to 'utils/routers')
-rw-r--r-- | utils/routers/routers.go | 49 |
1 files changed, 48 insertions, 1 deletions
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 } |