aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ansible/group_vars/all/ipam.yml9
-rw-r--r--utils/main.go31
2 files changed, 31 insertions, 9 deletions
diff --git a/ansible/group_vars/all/ipam.yml b/ansible/group_vars/all/ipam.yml
index 27c40be..4caa80d 100644
--- a/ansible/group_vars/all/ipam.yml
+++ b/ansible/group_vars/all/ipam.yml
@@ -47,5 +47,14 @@ ipam6:
conflatorio: "fdb1:4242:3538:2008:8042:32ff:fe0c:7161"
danneri: "fdb1:4242:3538:2008:9422:d355:95b7:f170"
+ k8s:
+ range: "fdb1:4242:3538:3000::/52"
+ danneri_cluster:
+ range: "fdb1:4242:3538:3009::/112"
+ danneri_service:
+ range: "fdb1:4242:3538:300a::/100"
+ danneri_service2:
+ range: "fdb1:4242:3538:300a::/112"
+
dn42:
range: "fd00::/8"
diff --git a/utils/main.go b/utils/main.go
index f419292..42adbd6 100644
--- a/utils/main.go
+++ b/utils/main.go
@@ -13,7 +13,7 @@ import (
func main() {
err := work()
if err != nil {
- _, _ = fmt.Fprintf(os.Stderr, "Error reading file: %v\n", err)
+ _, _ = fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
}
}
@@ -36,12 +36,20 @@ func work() error {
fmt.Printf("digraph {\n")
//fmt.Printf(" layout=dot\n")
//fmt.Printf(" layout=twopi\n")
- fmt.Printf(" layout=circo\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(" 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 _, n := range networks {
@@ -59,7 +67,8 @@ func work() error {
for _, n := range networks {
for _, c := range ipam.networks {
if c.parent == n {
- fmt.Printf(" %s -> %s;\n", n.name, c.name)
+ fmt.Printf(" %s -> %s", n.name, c.name)
+ fmt.Printf(";\n")
}
}
}
@@ -88,6 +97,10 @@ type Ipam struct {
networks []*Network
}
+func contains(a, b netip.Prefix) bool {
+ return b.Bits() > a.Bits() && b.Overlaps(a)
+}
+
func (ipam *Ipam) ResolveParents() {
for _, n := range ipam.networks {
log.Printf("network %s/%s", n.name, n.prefix)
@@ -95,14 +108,14 @@ func (ipam *Ipam) ResolveParents() {
if n == p {
continue
}
- //log.Printf("candidate %s/%s", p.name, p.prefix)
- if p.prefix.Contains(n.prefix.Addr()) {
+ log.Printf(" candidate %s/%s", p.name, p.prefix)
+ if contains(p.prefix, n.prefix) {
if n.parent == nil {
- log.Printf("found parent %s/%s", p.name, p.prefix)
+ log.Printf(" found parent %s/%s", p.name, p.prefix)
n.parent = p
} else {
- if n.parent.prefix.Contains(p.prefix.Addr()) {
- log.Printf("found better parent %s/%s", p.name, p.prefix)
+ if n.parent.prefix.Bits() < p.prefix.Bits() {
+ log.Printf(" found better parent %s/%s", p.name, p.prefix)
n.parent = p
}
}