Skip to content

Commit

Permalink
gh-48 Add support for url-path in LB args
Browse files Browse the repository at this point in the history
  • Loading branch information
TrekkieCoder committed Jul 16, 2024
1 parent cee717f commit af80917
Show file tree
Hide file tree
Showing 5 changed files with 280 additions and 1 deletion.
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 @@ -61,6 +61,7 @@ func configureAPI(api *operations.LoxilbRestAPIAPI) http.Handler {
// Load balancer add and delete and get
api.PostConfigLoadbalancerHandler = operations.PostConfigLoadbalancerHandlerFunc(handler.ConfigPostLoadbalancer)
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
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.

32 changes: 31 additions & 1 deletion api/restapi/handler/loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ func ConfigDeleteLoadbalancer(params operations.DeleteConfigLoadbalancerUrlpathU
lbServ.ServIP = params.IPAddress
lbServ.ServPort = uint16(params.Port)
lbServ.Proto = params.Proto
lbServ.Path = params.Urlpath
if params.Urlpath == "any" {
lbServ.Path = ""
} else {
lbServ.Path = params.Urlpath
}
if params.Block != nil {
lbServ.BlockNum = uint16(*params.Block)
}
Expand All @@ -104,6 +108,32 @@ func ConfigDeleteLoadbalancer(params operations.DeleteConfigLoadbalancerUrlpathU
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
12 changes: 12 additions & 0 deletions api/restapi/operations/loxilb_rest_api_api.go

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

60 changes: 60 additions & 0 deletions api/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,66 @@ paths:
description: Maintanence mode
schema:
$ref: '#/definitions/Error'
'/config/loadbalancer/externalipaddress/{ip_address}/port/{port}/protocol/{proto}':
delete:
summary: Delete an existing Load balancer service
description: Delete an existing load balancer service with .
parameters:
- name: ip_address
in: path
type: string
required: true
description: Attributes for load balance service
- name: port
in: path
type: number
required: true
description: Attributes for load balance service
- name: proto
in: path
type: string
required: true
description: Attributes for load balance service
- name: bgp
in: query
type: boolean
description: option for BGP enable
- name: block
in: query
type: number
required: false
description: block value if any
responses:
'204':
description: OK
'400':
description: Malformed arguments for API call
schema:
$ref: '#/definitions/Error'
'401':
description: Invalid authentication credentials
schema:
$ref: '#/definitions/Error'
'403':
description: Capacity insufficient
schema:
$ref: '#/definitions/Error'
'404':
description: Resource not found
schema:
$ref: '#/definitions/Error'
'409':
description: Resource Conflict. VLAN already exists OR dependency VRF/VNET not found
schema:
$ref: '#/definitions/Error'
'500':
description: Internal service error
schema:
$ref: '#/definitions/Error'
'503':
description: Maintanence mode
schema:
$ref: '#/definitions/Error'
'/config/loadbalancer/urlpath/{urlpath}/externalipaddress/{ip_address}/port/{port}/protocol/{proto}':
delete:
summary: Delete an existing Load balancer service
Expand Down

0 comments on commit af80917

Please sign in to comment.