All checks were successful
Documentation / publish (push) Successful in 1m27s
Release Pipeline / set-release-target (push) Successful in 2s
Release Pipeline / upload-assets (agent.service, systemd/agent.service) (push) Successful in 8s
Release Pipeline / upload-assets (dhcp@.service, systemd/dhcp@.service) (push) Successful in 7s
Release Pipeline / upload-assets (dnsmasq@.service, systemd/dnsmasq@.service) (push) Successful in 7s
Release Pipeline / upload-assets (metadata@.service, systemd/metadata@.service) (push) Successful in 7s
Release Pipeline / upload-assets (run-dhcp-in-netns.sh, scripts/run-dhcp-in-netns.sh) (push) Successful in 7s
Release Pipeline / build (dhcp, amd64, linux) (push) Successful in 0s
Release Pipeline / build (agent, amd64, linux) (push) Successful in 0s
Release Pipeline / build (metadata, amd64, linux) (push) Successful in 0s
Release Pipeline / upload-assets (run-dnsmasq-in-netns.sh, scripts/run-dnsmasq-in-netns.sh) (push) Successful in 7s
Release Pipeline / checksums (push) Successful in 8s
Release Pipeline / release (push) Successful in 28s
Release Pipeline / publish (push) Successful in 0s
Release Pipeline / build (push) Successful in 2m9s
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
49 lines
947 B
Go
49 lines
947 B
Go
package frr
|
|
|
|
import (
|
|
"fmt"
|
|
"net"
|
|
"strings"
|
|
)
|
|
|
|
type VNIState struct {
|
|
Type string
|
|
State string
|
|
RouterMAC string
|
|
}
|
|
|
|
func (c *Client) NeighborEstablished(peer net.IP) (bool, error) {
|
|
out, err := c.exec("show bgp neighbors " + peer.String())
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
return strings.Contains(out, "BGP state = Established"), nil
|
|
}
|
|
|
|
func (c *Client) VNI(vni uint32) (VNIState, error) {
|
|
out, err := c.exec(fmt.Sprintf("show evpn vni %d", vni))
|
|
if err != nil {
|
|
return VNIState{}, err
|
|
}
|
|
return parseVNI(out), nil
|
|
}
|
|
|
|
func parseVNI(out string) VNIState {
|
|
var s VNIState
|
|
for _, l := range strings.Split(out, "\n") {
|
|
key, value, ok := strings.Cut(strings.TrimSpace(l), ": ")
|
|
if !ok {
|
|
continue
|
|
}
|
|
value = strings.TrimSpace(value)
|
|
switch strings.ToLower(key) {
|
|
case "type":
|
|
s.Type = value
|
|
case "state":
|
|
s.State = value
|
|
case "router mac":
|
|
s.RouterMAC = strings.ToLower(value)
|
|
}
|
|
}
|
|
return s
|
|
}
|