labctl: segments sur des bridges de l'hôte, routeurs et passerelle VRRP #2
All checks were successful
Tests / test (push) Successful in 3m46s
All checks were successful
Tests / test (push) Successful in 3m46s
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
e0de56a64f
commit
e9a0c19b72
24 changed files with 1766 additions and 578 deletions
|
|
@ -12,7 +12,7 @@ import (
|
|||
func (p *Plan) Write(w io.Writer) error {
|
||||
tw := tabwriter.NewWriter(w, 0, 0, 2, ' ', 0)
|
||||
|
||||
fmt.Fprintf(tw, "lab %s: nodes %d, segments %d, cables %d\n", p.Name, len(p.Nodes), len(p.Segments), len(p.Cables))
|
||||
fmt.Fprintf(tw, "lab %s: nodes %d, segments %d, ports %d\n", p.Name, len(p.Nodes), len(p.Segments), len(p.Ports))
|
||||
|
||||
fmt.Fprintf(tw, "\nnodes\n")
|
||||
fmt.Fprintf(tw, " name\trole\timage\tcpus\tmemory\tssh\n")
|
||||
|
|
@ -37,21 +37,29 @@ func (p *Plan) Write(w io.Writer) error {
|
|||
}
|
||||
|
||||
for _, s := range p.Segments {
|
||||
fmt.Fprintf(tw, "\nsegment %s: %s, mtu %d, switch %s, bridge %s, gateway %s\n",
|
||||
s.Name, s.Network, s.MTU, s.Switch, s.Bridge, s.Gateway)
|
||||
fmt.Fprintf(tw, " node\tinterface\taddress\tmac\tudp\t\tswitch port\tmac\tudp\n")
|
||||
for _, c := range p.Cables {
|
||||
if c.Segment != s.Name {
|
||||
fmt.Fprintf(tw, "\nsegment %s: %s, mtu %d, bridge %s, %s\n", s.Name, s.Network, s.MTU, s.Bridge, gateway(s))
|
||||
fmt.Fprintf(tw, " node\tinterface\taddress\tmac\ttap\n")
|
||||
for _, port := range p.Ports {
|
||||
if port.Segment != s.Name {
|
||||
continue
|
||||
}
|
||||
fmt.Fprintf(tw, " %s\t%s\t%s\t%s\t%d\t<->\t%s %s\t%s\t%d\n",
|
||||
c.Node, c.NodeInterface, c.NodeAddress, c.NodeMAC, c.NodePort,
|
||||
c.Switch, c.SwitchInterface, c.SwitchMAC, c.SwitchPort)
|
||||
fmt.Fprintf(tw, " %s\t%s\t%s\t%s\t%s\n", port.Node, port.Interface, port.Address, port.MAC, port.Tap)
|
||||
}
|
||||
}
|
||||
return tw.Flush()
|
||||
}
|
||||
|
||||
func gateway(s SegmentPlan) string {
|
||||
switch {
|
||||
case len(s.Routers) == 0:
|
||||
return "no gateway"
|
||||
case s.VRID == 0:
|
||||
return fmt.Sprintf("gateway %s on %s", s.Gateway, s.Routers[0])
|
||||
default:
|
||||
return fmt.Sprintf("gateway %s by vrrp %d on %s", s.Gateway, s.VRID, strings.Join(s.Routers, ", "))
|
||||
}
|
||||
}
|
||||
|
||||
func loopback(n NodePlan) string {
|
||||
if !n.Loopback.IsValid() {
|
||||
return ""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue