f-41: config, frr: base BGP pilotée par l'agent au démarrage #41
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
94c2f82867
commit
bf0e83862f
12 changed files with 331 additions and 18 deletions
|
|
@ -13,7 +13,9 @@ import (
|
|||
agentapi "git.g3e.fr/syonad/two/internal/api/agent"
|
||||
configuration "git.g3e.fr/syonad/two/internal/config/agent"
|
||||
dispatcher "git.g3e.fr/syonad/two/internal/dispatcher/agent"
|
||||
"git.g3e.fr/syonad/two/internal/frr"
|
||||
"git.g3e.fr/syonad/two/internal/migration"
|
||||
"git.g3e.fr/syonad/two/internal/netif"
|
||||
agentmetrics "git.g3e.fr/syonad/two/internal/prometheus/agent"
|
||||
"git.g3e.fr/syonad/two/internal/watchdog"
|
||||
"git.g3e.fr/syonad/two/internal/watchdog/notify"
|
||||
|
|
@ -58,6 +60,14 @@ func main() {
|
|||
return
|
||||
}
|
||||
|
||||
if cfg.BGP.Enabled() {
|
||||
if err := applyBGPBase(cfg, frr.NewClient()); err != nil {
|
||||
log.Error("failed to apply the bgp base configuration", "error", err)
|
||||
return
|
||||
}
|
||||
log.Info("bgp base configuration applied", "asn", cfg.BGP.ASN, "route_reflectors", cfg.BGP.RouteReflectors)
|
||||
}
|
||||
|
||||
q := worker.New(cfg.Worker.BufferSize)
|
||||
q.Start(cfg.Worker.Count)
|
||||
|
||||
|
|
@ -110,6 +120,22 @@ func main() {
|
|||
closeDB = shutdown(log, q, servers, shutdownTimeout)
|
||||
}
|
||||
|
||||
type baseApplier interface {
|
||||
ApplyBase(frr.Base) error
|
||||
}
|
||||
|
||||
func applyBGPBase(cfg *configuration.Config, frrClient baseApplier) error {
|
||||
reflectors, err := cfg.BGP.Reflectors()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
vtep, err := netif.VTEPAddress(cfg.DefaultInterface)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return frrClient.ApplyBase(frr.Base{ASN: cfg.BGP.ASN, RouterID: vtep, RouteReflectors: reflectors})
|
||||
}
|
||||
|
||||
type httpShutdowner interface {
|
||||
Shutdown(context.Context) error
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue