Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added GET API of the BGP Peer info #503

Merged
merged 1 commit into from
Jan 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
@@ -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)
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
@@ -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
Loading