mirror of
https://github.com/luscis/openlan.git
synced 2025-10-06 00:57:03 +08:00
fea:support nexthop group for routing ha (#57)
This commit is contained in:
@@ -8,11 +8,17 @@ import (
|
||||
)
|
||||
|
||||
type Route struct {
|
||||
Prefix string `json:"prefix"`
|
||||
Prefix string `json:"prefix"`
|
||||
NextHop string `json:"nexthop"`
|
||||
Metric int `json:"metric"`
|
||||
Mode string `json:"mode"`
|
||||
Origin string `json:"origin"`
|
||||
MultiPath []MultiPath `json:"multipath,omitempty"`
|
||||
}
|
||||
|
||||
type MultiPath struct {
|
||||
NextHop string `json:"nexthop"`
|
||||
Metric int `json:"metric"`
|
||||
Mode string `json:"mode"`
|
||||
Origin string `json:"origin"`
|
||||
Weight int `json:"weight"`
|
||||
}
|
||||
|
||||
func NewRoute(prefix string, nexthop, mode string) (this *Route) {
|
||||
|
@@ -102,12 +102,21 @@ func NewNetworkSchema(n *Network) schema.Network {
|
||||
}
|
||||
|
||||
func NewRouteSchema(route *Route) schema.PrefixRoute {
|
||||
multiPath := make([]schema.MultiPath, 0, len(route.MultiPath))
|
||||
|
||||
for _, mp := range route.MultiPath {
|
||||
multiPath = append(multiPath, schema.MultiPath{
|
||||
NextHop: mp.NextHop,
|
||||
Weight: mp.Weight,
|
||||
})
|
||||
}
|
||||
pr := schema.PrefixRoute{
|
||||
Prefix: route.Prefix,
|
||||
NextHop: route.NextHop,
|
||||
Metric: route.Metric,
|
||||
Mode: route.Mode,
|
||||
Origin: route.Origin,
|
||||
Prefix: route.Prefix,
|
||||
NextHop: route.NextHop,
|
||||
Metric: route.Metric,
|
||||
Mode: route.Mode,
|
||||
Origin: route.Origin,
|
||||
MultiPath: multiPath,
|
||||
}
|
||||
return pr
|
||||
}
|
||||
|
Reference in New Issue
Block a user