Skip to content

Commit

Permalink
Added GET API of the BGP Peer info
Browse files Browse the repository at this point in the history
  • Loading branch information
inhogog2 committed Jan 23, 2024
1 parent de15807 commit b95cead
Show file tree
Hide file tree
Showing 14 changed files with 1,123 additions and 1 deletion.
59 changes: 59 additions & 0 deletions api/models/b_g_p_neigh_get_entry.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions api/restapi/configure_loxilb_rest_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ func configureAPI(api *operations.LoxilbRestAPIAPI) http.Handler {
api.GetMetricsHandler = operations.GetMetricsHandlerFunc(handler.ConfigGetPrometheusCounter)

// BGP Peer
api.GetConfigBgpNeighAllHandler = operations.GetConfigBgpNeighAllHandlerFunc(handler.ConfigGetBGPNeigh)
api.PostConfigBgpGlobalHandler = operations.PostConfigBgpGlobalHandlerFunc(handler.ConfigPostBGPGlobal)
api.PostConfigBgpNeighHandler = operations.PostConfigBgpNeighHandlerFunc(handler.ConfigPostBGPNeigh)
api.DeleteConfigBgpNeighIPAddressHandler = operations.DeleteConfigBgpNeighIPAddressHandlerFunc(handler.ConfigDeleteBGPNeigh)
Expand Down
176 changes: 176 additions & 0 deletions api/restapi/embedded_spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 24 additions & 1 deletion api/restapi/handler/gobgp.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,36 @@
package handler

import (
"net"

"github.com/go-openapi/runtime/middleware"
"github.com/loxilb-io/loxilb/api/models"
"github.com/loxilb-io/loxilb/api/restapi/operations"
cmn "github.com/loxilb-io/loxilb/common"
tk "github.com/loxilb-io/loxilib"
"net"
)

func ConfigGetBGPNeigh(params operations.GetConfigBgpNeighAllParams) middleware.Responder {
tk.LogIt(tk.LogDebug, "[API] BGP Neighbor %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL)
res, err := ApiHooks.NetGoBGPNeighGet()
if err != nil {
tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err)
return &ResultResponse{Result: err.Error()}
}
var result []*models.BGPNeighGetEntry
result = make([]*models.BGPNeighGetEntry, 0)
for _, nei := range res {
tmpNeigh := models.BGPNeighGetEntry{}
tmpNeigh.IPAddress = nei.Addr
tmpNeigh.RemoteAs = int64(nei.RemoteAS)
tmpNeigh.State = nei.State
tmpNeigh.Updowntime = nei.Uptime

result = append(result, &tmpNeigh)
}

return operations.NewGetConfigBgpNeighAllOK().WithPayload(&operations.GetConfigBgpNeighAllOKBody{BgpNeiAttr: result})
}
func ConfigPostBGPNeigh(params operations.PostConfigBgpNeighParams) middleware.Responder {
tk.LogIt(tk.LogDebug, "[API] BGP Neighbor %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL)
var bgpNeighMod cmn.GoBGPNeighMod
Expand Down
Loading

0 comments on commit b95cead

Please sign in to comment.