Skip to content

Commit

Permalink
Merge pull request #732 from TrekkieCoder/main
Browse files Browse the repository at this point in the history
gh-48 Add support for url-path in LB args
  • Loading branch information
UltraInstinct14 authored Jul 16, 2024
2 parents 2affddb + af80917 commit 3932fb3
Show file tree
Hide file tree
Showing 12 changed files with 1,116 additions and 11 deletions.
3 changes: 3 additions & 0 deletions api/models/loadbalance_entry.go

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

3 changes: 2 additions & 1 deletion api/restapi/configure_loxilb_rest_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ func configureAPI(api *operations.LoxilbRestAPIAPI) http.Handler {

// Load balancer add and delete and get
api.PostConfigLoadbalancerHandler = operations.PostConfigLoadbalancerHandlerFunc(handler.ConfigPostLoadbalancer)
api.DeleteConfigLoadbalancerExternalipaddressIPAddressPortPortProtocolProtoHandler = operations.DeleteConfigLoadbalancerExternalipaddressIPAddressPortPortProtocolProtoHandlerFunc(handler.ConfigDeleteLoadbalancer)
api.DeleteConfigLoadbalancerUrlpathUrlpathExternalipaddressIPAddressPortPortProtocolProtoHandler = operations.DeleteConfigLoadbalancerUrlpathUrlpathExternalipaddressIPAddressPortPortProtocolProtoHandlerFunc(handler.ConfigDeleteLoadbalancer)
api.DeleteConfigLoadbalancerExternalipaddressIPAddressPortPortProtocolProtoHandler = operations.DeleteConfigLoadbalancerExternalipaddressIPAddressPortPortProtocolProtoHandlerFunc(handler.ConfigDeleteLoadbalancerWithoutPath)
api.GetConfigLoadbalancerAllHandler = operations.GetConfigLoadbalancerAllHandlerFunc(handler.ConfigGetLoadbalancer)
api.DeleteConfigLoadbalancerAllHandler = operations.DeleteConfigLoadbalancerAllHandlerFunc(handler.ConfigDeleteAllLoadbalancer)
api.DeleteConfigLoadbalancerNameLbNameHandler = operations.DeleteConfigLoadbalancerNameLbNameHandlerFunc(handler.ConfigDeleteLoadbalancerByName)
Expand Down
202 changes: 202 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.

35 changes: 34 additions & 1 deletion api/restapi/handler/loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func ConfigPostLoadbalancer(params operations.PostConfigLoadbalancerParams) midd
lbRules.Serv.ProbeRetries = int(params.Attr.ServiceArguments.ProbeRetries)
lbRules.Serv.Name = params.Attr.ServiceArguments.Name
lbRules.Serv.Oper = cmn.LBOp(params.Attr.ServiceArguments.Oper)
lbRules.Serv.Path = params.Attr.ServiceArguments.Path

if lbRules.Serv.Proto == "sctp" {
for _, data := range params.Attr.SecondaryIPs {
Expand Down Expand Up @@ -77,14 +78,19 @@ func ConfigPostLoadbalancer(params operations.PostConfigLoadbalancerParams) midd
return &ResultResponse{Result: "Success"}
}

func ConfigDeleteLoadbalancer(params operations.DeleteConfigLoadbalancerExternalipaddressIPAddressPortPortProtocolProtoParams) middleware.Responder {
func ConfigDeleteLoadbalancer(params operations.DeleteConfigLoadbalancerUrlpathUrlpathExternalipaddressIPAddressPortPortProtocolProtoParams) middleware.Responder {
tk.LogIt(tk.LogDebug, "[API] Load balancer %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL)

var lbServ cmn.LbServiceArg
var lbRules cmn.LbRuleMod
lbServ.ServIP = params.IPAddress
lbServ.ServPort = uint16(params.Port)
lbServ.Proto = params.Proto
if params.Urlpath == "any" {
lbServ.Path = ""
} else {
lbServ.Path = params.Urlpath
}
if params.Block != nil {
lbServ.BlockNum = uint16(*params.Block)
}
Expand All @@ -102,6 +108,32 @@ func ConfigDeleteLoadbalancer(params operations.DeleteConfigLoadbalancerExternal
return &ResultResponse{Result: "Success"}
}

func ConfigDeleteLoadbalancerWithoutPath(params operations.DeleteConfigLoadbalancerExternalipaddressIPAddressPortPortProtocolProtoParams) middleware.Responder {
tk.LogIt(tk.LogDebug, "[API] Load balancer %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL)

var lbServ cmn.LbServiceArg
var lbRules cmn.LbRuleMod
lbServ.ServIP = params.IPAddress
lbServ.ServPort = uint16(params.Port)
lbServ.Proto = params.Proto
lbServ.Path = ""
if params.Block != nil {
lbServ.BlockNum = uint16(*params.Block)
}
if params.Bgp != nil {
lbServ.Bgp = *params.Bgp
}

lbRules.Serv = lbServ
tk.LogIt(tk.LogDebug, "[API] lbRules (w/o Path): %v\n", lbRules)
_, err := ApiHooks.NetLbRuleDel(&lbRules)
if err != nil {
tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err)
return &ResultResponse{Result: err.Error()}
}
return &ResultResponse{Result: "Success"}
}

func ConfigGetLoadbalancer(params operations.GetConfigLoadbalancerAllParams) middleware.Responder {
// Get LB rules
tk.LogIt(tk.LogDebug, "[API] Load balancer %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL)
Expand Down Expand Up @@ -133,6 +165,7 @@ func ConfigGetLoadbalancer(params operations.GetConfigLoadbalancerAllParams) mid
tmpSvc.Probeport = lb.Serv.ProbePort
tmpSvc.Name = lb.Serv.Name
tmpSvc.Snat = lb.Serv.Snat
tmpSvc.Path = lb.Serv.Path

tmpLB.ServiceArguments = &tmpSvc

Expand Down

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

Loading

0 comments on commit 3932fb3

Please sign in to comment.