Skip to content

Commit a360313

Browse files
Merge pull request #503 from inhogog2/main
Added GET API of the BGP Peer info
2 parents de15807 + b95cead commit a360313

14 files changed

+1123
-1
lines changed

api/models/b_g_p_neigh_get_entry.go

+59
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/restapi/configure_loxilb_rest_api.go

+1
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ func configureAPI(api *operations.LoxilbRestAPIAPI) http.Handler {
153153
api.GetMetricsHandler = operations.GetMetricsHandlerFunc(handler.ConfigGetPrometheusCounter)
154154

155155
// BGP Peer
156+
api.GetConfigBgpNeighAllHandler = operations.GetConfigBgpNeighAllHandlerFunc(handler.ConfigGetBGPNeigh)
156157
api.PostConfigBgpGlobalHandler = operations.PostConfigBgpGlobalHandlerFunc(handler.ConfigPostBGPGlobal)
157158
api.PostConfigBgpNeighHandler = operations.PostConfigBgpNeighHandlerFunc(handler.ConfigPostBGPNeigh)
158159
api.DeleteConfigBgpNeighIPAddressHandler = operations.DeleteConfigBgpNeighIPAddressHandlerFunc(handler.ConfigDeleteBGPNeigh)

api/restapi/embedded_spec.go

+176
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/restapi/handler/gobgp.go

+24-1
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,36 @@
1616
package handler
1717

1818
import (
19+
"net"
20+
1921
"github.com/go-openapi/runtime/middleware"
22+
"github.com/loxilb-io/loxilb/api/models"
2023
"github.com/loxilb-io/loxilb/api/restapi/operations"
2124
cmn "github.com/loxilb-io/loxilb/common"
2225
tk "github.com/loxilb-io/loxilib"
23-
"net"
2426
)
2527

28+
func ConfigGetBGPNeigh(params operations.GetConfigBgpNeighAllParams) middleware.Responder {
29+
tk.LogIt(tk.LogDebug, "[API] BGP Neighbor %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL)
30+
res, err := ApiHooks.NetGoBGPNeighGet()
31+
if err != nil {
32+
tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err)
33+
return &ResultResponse{Result: err.Error()}
34+
}
35+
var result []*models.BGPNeighGetEntry
36+
result = make([]*models.BGPNeighGetEntry, 0)
37+
for _, nei := range res {
38+
tmpNeigh := models.BGPNeighGetEntry{}
39+
tmpNeigh.IPAddress = nei.Addr
40+
tmpNeigh.RemoteAs = int64(nei.RemoteAS)
41+
tmpNeigh.State = nei.State
42+
tmpNeigh.Updowntime = nei.Uptime
43+
44+
result = append(result, &tmpNeigh)
45+
}
46+
47+
return operations.NewGetConfigBgpNeighAllOK().WithPayload(&operations.GetConfigBgpNeighAllOKBody{BgpNeiAttr: result})
48+
}
2649
func ConfigPostBGPNeigh(params operations.PostConfigBgpNeighParams) middleware.Responder {
2750
tk.LogIt(tk.LogDebug, "[API] BGP Neighbor %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL)
2851
var bgpNeighMod cmn.GoBGPNeighMod

0 commit comments

Comments
 (0)