|
16 | 16 | package handler
|
17 | 17 |
|
18 | 18 | import (
|
| 19 | + "net" |
| 20 | + |
19 | 21 | "github.com/go-openapi/runtime/middleware"
|
| 22 | + "github.com/loxilb-io/loxilb/api/models" |
20 | 23 | "github.com/loxilb-io/loxilb/api/restapi/operations"
|
21 | 24 | cmn "github.com/loxilb-io/loxilb/common"
|
22 | 25 | tk "github.com/loxilb-io/loxilib"
|
23 |
| - "net" |
24 | 26 | )
|
25 | 27 |
|
| 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 | +} |
26 | 49 | func ConfigPostBGPNeigh(params operations.PostConfigBgpNeighParams) middleware.Responder {
|
27 | 50 | tk.LogIt(tk.LogDebug, "[API] BGP Neighbor %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL)
|
28 | 51 | var bgpNeighMod cmn.GoBGPNeighMod
|
|
0 commit comments