diff --git a/api/restapi/configure_loxilb_rest_api.go b/api/restapi/configure_loxilb_rest_api.go index bd786bd8..b8547f82 100644 --- a/api/restapi/configure_loxilb_rest_api.go +++ b/api/restapi/configure_loxilb_rest_api.go @@ -138,6 +138,7 @@ func configureAPI(api *operations.LoxilbRestAPIAPI) http.Handler { // BFD api.GetConfigBfdAllHandler = operations.GetConfigBfdAllHandlerFunc(handler.ConfigGetBFDSession) api.PostConfigBfdHandler = operations.PostConfigBfdHandlerFunc(handler.ConfigPostBFDSession) + api.DeleteConfigBfdRemoteIPRemoteIPHandler = operations.DeleteConfigBfdRemoteIPRemoteIPHandlerFunc(handler.ConfigDeleteBFDSession) // Firewall api.GetConfigFirewallAllHandler = operations.GetConfigFirewallAllHandlerFunc(handler.ConfigGetFW) diff --git a/api/restapi/embedded_spec.go b/api/restapi/embedded_spec.go index 353385a2..e0d69080 100644 --- a/api/restapi/embedded_spec.go +++ b/api/restapi/embedded_spec.go @@ -141,6 +141,74 @@ func init() { } } }, + "/config/bfd/remoteIP/{remote_ip}": { + "delete": { + "description": "Delete a BFD session", + "summary": "Delete a BFD session", + "parameters": [ + { + "type": "string", + "description": "Remote IP address", + "name": "remote_ip", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Cluster instance name", + "name": "instance", + "in": "query" + } + ], + "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. BFD session already exists", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "503": { + "description": "Maintanence mode", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, "/config/bgp/global": { "post": { "description": "Adds a BGP global config", @@ -4793,6 +4861,74 @@ func init() { } } }, + "/config/bfd/remoteIP/{remote_ip}": { + "delete": { + "description": "Delete a BFD session", + "summary": "Delete a BFD session", + "parameters": [ + { + "type": "string", + "description": "Remote IP address", + "name": "remote_ip", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Cluster instance name", + "name": "instance", + "in": "query" + } + ], + "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. BFD session already exists", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "503": { + "description": "Maintanence mode", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, "/config/bgp/global": { "post": { "description": "Adds a BGP global config", diff --git a/api/restapi/handler/cluster.go b/api/restapi/handler/cluster.go index c4a8ea43..b431d701 100644 --- a/api/restapi/handler/cluster.go +++ b/api/restapi/handler/cluster.go @@ -100,7 +100,7 @@ func ConfigPostBFDSession(params operations.PostConfigBfdParams) middleware.Resp bfdMod.Interval = params.Attr.Interval bfdMod.RetryCount = params.Attr.RetryCount - tk.LogIt(tk.LogDebug, "[API] Instance %s BFD session update : %s, Interval: %d, RetryCount: %d\n", + tk.LogIt(tk.LogDebug, "[API] Instance %s BFD session add : %s, Interval: %d, RetryCount: %d\n", bfdMod.Instance, bfdMod.RemoteIP, bfdMod.Interval, bfdMod.RetryCount) _, err := ApiHooks.NetBFDAdd(&bfdMod) if err != nil { @@ -109,3 +109,25 @@ func ConfigPostBFDSession(params operations.PostConfigBfdParams) middleware.Resp } return &ResultResponse{Result: "Success"} } + +func ConfigDeleteBFDSession(params operations.DeleteConfigBfdRemoteIPRemoteIPParams) middleware.Responder { + tk.LogIt(tk.LogDebug, "[API] HA %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + + var bfdMod cmn.BFDMod + + // Delete BFD Session + if params.Instance != nil { + bfdMod.Instance = *params.Instance + } + + bfdMod.RemoteIP = net.ParseIP(params.RemoteIP) + + tk.LogIt(tk.LogDebug, "[API] Instance %s BFD session delete : %s\n", + bfdMod.Instance, bfdMod.RemoteIP) + _, err := ApiHooks.NetBFDDel(&bfdMod) + if err != nil { + tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + return &ResultResponse{Result: err.Error()} + } + return &ResultResponse{Result: "Success"} +} \ No newline at end of file diff --git a/api/restapi/operations/delete_config_bfd_remote_ip.go b/api/restapi/operations/delete_config_bfd_remote_ip.go new file mode 100644 index 00000000..00154f4e --- /dev/null +++ b/api/restapi/operations/delete_config_bfd_remote_ip.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteConfigBfdRemoteIPHandlerFunc turns a function with the right signature into a delete config bfd remote IP handler +type DeleteConfigBfdRemoteIPHandlerFunc func(DeleteConfigBfdRemoteIPParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteConfigBfdRemoteIPHandlerFunc) Handle(params DeleteConfigBfdRemoteIPParams) middleware.Responder { + return fn(params) +} + +// DeleteConfigBfdRemoteIPHandler interface for that can handle valid delete config bfd remote IP params +type DeleteConfigBfdRemoteIPHandler interface { + Handle(DeleteConfigBfdRemoteIPParams) middleware.Responder +} + +// NewDeleteConfigBfdRemoteIP creates a new http.Handler for the delete config bfd remote IP operation +func NewDeleteConfigBfdRemoteIP(ctx *middleware.Context, handler DeleteConfigBfdRemoteIPHandler) *DeleteConfigBfdRemoteIP { + return &DeleteConfigBfdRemoteIP{Context: ctx, Handler: handler} +} + +/* + DeleteConfigBfdRemoteIP swagger:route DELETE /config/bfd/{remote_ip} deleteConfigBfdRemoteIp + +# Delete a BFD session + +Delete a BFD session +*/ +type DeleteConfigBfdRemoteIP struct { + Context *middleware.Context + Handler DeleteConfigBfdRemoteIPHandler +} + +func (o *DeleteConfigBfdRemoteIP) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteConfigBfdRemoteIPParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/api/restapi/operations/delete_config_bfd_remote_ip_parameters.go b/api/restapi/operations/delete_config_bfd_remote_ip_parameters.go new file mode 100644 index 00000000..20d4bbe4 --- /dev/null +++ b/api/restapi/operations/delete_config_bfd_remote_ip_parameters.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewDeleteConfigBfdRemoteIPParams creates a new DeleteConfigBfdRemoteIPParams object +// +// There are no default values defined in the spec. +func NewDeleteConfigBfdRemoteIPParams() DeleteConfigBfdRemoteIPParams { + + return DeleteConfigBfdRemoteIPParams{} +} + +// DeleteConfigBfdRemoteIPParams contains all the bound params for the delete config bfd remote IP operation +// typically these are obtained from a http.Request +// +// swagger:parameters DeleteConfigBfdRemoteIP +type DeleteConfigBfdRemoteIPParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Cluster instance name + In: query + */ + Instance *string + /*Remote IP address + Required: true + In: path + */ + RemoteIP string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteConfigBfdRemoteIPParams() beforehand. +func (o *DeleteConfigBfdRemoteIPParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qInstance, qhkInstance, _ := qs.GetOK("instance") + if err := o.bindInstance(qInstance, qhkInstance, route.Formats); err != nil { + res = append(res, err) + } + + rRemoteIP, rhkRemoteIP, _ := route.Params.GetOK("remote_ip") + if err := o.bindRemoteIP(rRemoteIP, rhkRemoteIP, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindInstance binds and validates parameter Instance from query. +func (o *DeleteConfigBfdRemoteIPParams) bindInstance(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.Instance = &raw + + return nil +} + +// bindRemoteIP binds and validates parameter RemoteIP from path. +func (o *DeleteConfigBfdRemoteIPParams) bindRemoteIP(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.RemoteIP = raw + + return nil +} diff --git a/api/restapi/operations/delete_config_bfd_remote_ip_remote_ip.go b/api/restapi/operations/delete_config_bfd_remote_ip_remote_ip.go new file mode 100644 index 00000000..5a5e37ed --- /dev/null +++ b/api/restapi/operations/delete_config_bfd_remote_ip_remote_ip.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteConfigBfdRemoteIPRemoteIPHandlerFunc turns a function with the right signature into a delete config bfd remote IP remote IP handler +type DeleteConfigBfdRemoteIPRemoteIPHandlerFunc func(DeleteConfigBfdRemoteIPRemoteIPParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteConfigBfdRemoteIPRemoteIPHandlerFunc) Handle(params DeleteConfigBfdRemoteIPRemoteIPParams) middleware.Responder { + return fn(params) +} + +// DeleteConfigBfdRemoteIPRemoteIPHandler interface for that can handle valid delete config bfd remote IP remote IP params +type DeleteConfigBfdRemoteIPRemoteIPHandler interface { + Handle(DeleteConfigBfdRemoteIPRemoteIPParams) middleware.Responder +} + +// NewDeleteConfigBfdRemoteIPRemoteIP creates a new http.Handler for the delete config bfd remote IP remote IP operation +func NewDeleteConfigBfdRemoteIPRemoteIP(ctx *middleware.Context, handler DeleteConfigBfdRemoteIPRemoteIPHandler) *DeleteConfigBfdRemoteIPRemoteIP { + return &DeleteConfigBfdRemoteIPRemoteIP{Context: ctx, Handler: handler} +} + +/* + DeleteConfigBfdRemoteIPRemoteIP swagger:route DELETE /config/bfd/remoteIP/{remote_ip} deleteConfigBfdRemoteIpRemoteIp + +# Delete a BFD session + +Delete a BFD session +*/ +type DeleteConfigBfdRemoteIPRemoteIP struct { + Context *middleware.Context + Handler DeleteConfigBfdRemoteIPRemoteIPHandler +} + +func (o *DeleteConfigBfdRemoteIPRemoteIP) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteConfigBfdRemoteIPRemoteIPParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/api/restapi/operations/delete_config_bfd_remote_ip_remote_ip_parameters.go b/api/restapi/operations/delete_config_bfd_remote_ip_remote_ip_parameters.go new file mode 100644 index 00000000..0a95b587 --- /dev/null +++ b/api/restapi/operations/delete_config_bfd_remote_ip_remote_ip_parameters.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewDeleteConfigBfdRemoteIPRemoteIPParams creates a new DeleteConfigBfdRemoteIPRemoteIPParams object +// +// There are no default values defined in the spec. +func NewDeleteConfigBfdRemoteIPRemoteIPParams() DeleteConfigBfdRemoteIPRemoteIPParams { + + return DeleteConfigBfdRemoteIPRemoteIPParams{} +} + +// DeleteConfigBfdRemoteIPRemoteIPParams contains all the bound params for the delete config bfd remote IP remote IP operation +// typically these are obtained from a http.Request +// +// swagger:parameters DeleteConfigBfdRemoteIPRemoteIP +type DeleteConfigBfdRemoteIPRemoteIPParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Cluster instance name + In: query + */ + Instance *string + /*Remote IP address + Required: true + In: path + */ + RemoteIP string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteConfigBfdRemoteIPRemoteIPParams() beforehand. +func (o *DeleteConfigBfdRemoteIPRemoteIPParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qInstance, qhkInstance, _ := qs.GetOK("instance") + if err := o.bindInstance(qInstance, qhkInstance, route.Formats); err != nil { + res = append(res, err) + } + + rRemoteIP, rhkRemoteIP, _ := route.Params.GetOK("remote_ip") + if err := o.bindRemoteIP(rRemoteIP, rhkRemoteIP, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindInstance binds and validates parameter Instance from query. +func (o *DeleteConfigBfdRemoteIPRemoteIPParams) bindInstance(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.Instance = &raw + + return nil +} + +// bindRemoteIP binds and validates parameter RemoteIP from path. +func (o *DeleteConfigBfdRemoteIPRemoteIPParams) bindRemoteIP(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.RemoteIP = raw + + return nil +} diff --git a/api/restapi/operations/delete_config_bfd_remote_ip_remote_ip_responses.go b/api/restapi/operations/delete_config_bfd_remote_ip_remote_ip_responses.go new file mode 100644 index 00000000..60b96b32 --- /dev/null +++ b/api/restapi/operations/delete_config_bfd_remote_ip_remote_ip_responses.go @@ -0,0 +1,354 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/loxilb-io/loxilb/api/models" +) + +// DeleteConfigBfdRemoteIPRemoteIPNoContentCode is the HTTP code returned for type DeleteConfigBfdRemoteIPRemoteIPNoContent +const DeleteConfigBfdRemoteIPRemoteIPNoContentCode int = 204 + +/* +DeleteConfigBfdRemoteIPRemoteIPNoContent OK + +swagger:response deleteConfigBfdRemoteIpRemoteIpNoContent +*/ +type DeleteConfigBfdRemoteIPRemoteIPNoContent struct { +} + +// NewDeleteConfigBfdRemoteIPRemoteIPNoContent creates DeleteConfigBfdRemoteIPRemoteIPNoContent with default headers values +func NewDeleteConfigBfdRemoteIPRemoteIPNoContent() *DeleteConfigBfdRemoteIPRemoteIPNoContent { + + return &DeleteConfigBfdRemoteIPRemoteIPNoContent{} +} + +// WriteResponse to the client +func (o *DeleteConfigBfdRemoteIPRemoteIPNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteConfigBfdRemoteIPRemoteIPBadRequestCode is the HTTP code returned for type DeleteConfigBfdRemoteIPRemoteIPBadRequest +const DeleteConfigBfdRemoteIPRemoteIPBadRequestCode int = 400 + +/* +DeleteConfigBfdRemoteIPRemoteIPBadRequest Malformed arguments for API call + +swagger:response deleteConfigBfdRemoteIpRemoteIpBadRequest +*/ +type DeleteConfigBfdRemoteIPRemoteIPBadRequest struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteConfigBfdRemoteIPRemoteIPBadRequest creates DeleteConfigBfdRemoteIPRemoteIPBadRequest with default headers values +func NewDeleteConfigBfdRemoteIPRemoteIPBadRequest() *DeleteConfigBfdRemoteIPRemoteIPBadRequest { + + return &DeleteConfigBfdRemoteIPRemoteIPBadRequest{} +} + +// WithPayload adds the payload to the delete config bfd remote Ip remote Ip bad request response +func (o *DeleteConfigBfdRemoteIPRemoteIPBadRequest) WithPayload(payload *models.Error) *DeleteConfigBfdRemoteIPRemoteIPBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete config bfd remote Ip remote Ip bad request response +func (o *DeleteConfigBfdRemoteIPRemoteIPBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteConfigBfdRemoteIPRemoteIPBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteConfigBfdRemoteIPRemoteIPUnauthorizedCode is the HTTP code returned for type DeleteConfigBfdRemoteIPRemoteIPUnauthorized +const DeleteConfigBfdRemoteIPRemoteIPUnauthorizedCode int = 401 + +/* +DeleteConfigBfdRemoteIPRemoteIPUnauthorized Invalid authentication credentials + +swagger:response deleteConfigBfdRemoteIpRemoteIpUnauthorized +*/ +type DeleteConfigBfdRemoteIPRemoteIPUnauthorized struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteConfigBfdRemoteIPRemoteIPUnauthorized creates DeleteConfigBfdRemoteIPRemoteIPUnauthorized with default headers values +func NewDeleteConfigBfdRemoteIPRemoteIPUnauthorized() *DeleteConfigBfdRemoteIPRemoteIPUnauthorized { + + return &DeleteConfigBfdRemoteIPRemoteIPUnauthorized{} +} + +// WithPayload adds the payload to the delete config bfd remote Ip remote Ip unauthorized response +func (o *DeleteConfigBfdRemoteIPRemoteIPUnauthorized) WithPayload(payload *models.Error) *DeleteConfigBfdRemoteIPRemoteIPUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete config bfd remote Ip remote Ip unauthorized response +func (o *DeleteConfigBfdRemoteIPRemoteIPUnauthorized) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteConfigBfdRemoteIPRemoteIPUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteConfigBfdRemoteIPRemoteIPForbiddenCode is the HTTP code returned for type DeleteConfigBfdRemoteIPRemoteIPForbidden +const DeleteConfigBfdRemoteIPRemoteIPForbiddenCode int = 403 + +/* +DeleteConfigBfdRemoteIPRemoteIPForbidden Capacity insufficient + +swagger:response deleteConfigBfdRemoteIpRemoteIpForbidden +*/ +type DeleteConfigBfdRemoteIPRemoteIPForbidden struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteConfigBfdRemoteIPRemoteIPForbidden creates DeleteConfigBfdRemoteIPRemoteIPForbidden with default headers values +func NewDeleteConfigBfdRemoteIPRemoteIPForbidden() *DeleteConfigBfdRemoteIPRemoteIPForbidden { + + return &DeleteConfigBfdRemoteIPRemoteIPForbidden{} +} + +// WithPayload adds the payload to the delete config bfd remote Ip remote Ip forbidden response +func (o *DeleteConfigBfdRemoteIPRemoteIPForbidden) WithPayload(payload *models.Error) *DeleteConfigBfdRemoteIPRemoteIPForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete config bfd remote Ip remote Ip forbidden response +func (o *DeleteConfigBfdRemoteIPRemoteIPForbidden) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteConfigBfdRemoteIPRemoteIPForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteConfigBfdRemoteIPRemoteIPNotFoundCode is the HTTP code returned for type DeleteConfigBfdRemoteIPRemoteIPNotFound +const DeleteConfigBfdRemoteIPRemoteIPNotFoundCode int = 404 + +/* +DeleteConfigBfdRemoteIPRemoteIPNotFound Resource not found + +swagger:response deleteConfigBfdRemoteIpRemoteIpNotFound +*/ +type DeleteConfigBfdRemoteIPRemoteIPNotFound struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteConfigBfdRemoteIPRemoteIPNotFound creates DeleteConfigBfdRemoteIPRemoteIPNotFound with default headers values +func NewDeleteConfigBfdRemoteIPRemoteIPNotFound() *DeleteConfigBfdRemoteIPRemoteIPNotFound { + + return &DeleteConfigBfdRemoteIPRemoteIPNotFound{} +} + +// WithPayload adds the payload to the delete config bfd remote Ip remote Ip not found response +func (o *DeleteConfigBfdRemoteIPRemoteIPNotFound) WithPayload(payload *models.Error) *DeleteConfigBfdRemoteIPRemoteIPNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete config bfd remote Ip remote Ip not found response +func (o *DeleteConfigBfdRemoteIPRemoteIPNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteConfigBfdRemoteIPRemoteIPNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteConfigBfdRemoteIPRemoteIPConflictCode is the HTTP code returned for type DeleteConfigBfdRemoteIPRemoteIPConflict +const DeleteConfigBfdRemoteIPRemoteIPConflictCode int = 409 + +/* +DeleteConfigBfdRemoteIPRemoteIPConflict Resource Conflict. BFD session already exists + +swagger:response deleteConfigBfdRemoteIpRemoteIpConflict +*/ +type DeleteConfigBfdRemoteIPRemoteIPConflict struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteConfigBfdRemoteIPRemoteIPConflict creates DeleteConfigBfdRemoteIPRemoteIPConflict with default headers values +func NewDeleteConfigBfdRemoteIPRemoteIPConflict() *DeleteConfigBfdRemoteIPRemoteIPConflict { + + return &DeleteConfigBfdRemoteIPRemoteIPConflict{} +} + +// WithPayload adds the payload to the delete config bfd remote Ip remote Ip conflict response +func (o *DeleteConfigBfdRemoteIPRemoteIPConflict) WithPayload(payload *models.Error) *DeleteConfigBfdRemoteIPRemoteIPConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete config bfd remote Ip remote Ip conflict response +func (o *DeleteConfigBfdRemoteIPRemoteIPConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteConfigBfdRemoteIPRemoteIPConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteConfigBfdRemoteIPRemoteIPInternalServerErrorCode is the HTTP code returned for type DeleteConfigBfdRemoteIPRemoteIPInternalServerError +const DeleteConfigBfdRemoteIPRemoteIPInternalServerErrorCode int = 500 + +/* +DeleteConfigBfdRemoteIPRemoteIPInternalServerError Internal service error + +swagger:response deleteConfigBfdRemoteIpRemoteIpInternalServerError +*/ +type DeleteConfigBfdRemoteIPRemoteIPInternalServerError struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteConfigBfdRemoteIPRemoteIPInternalServerError creates DeleteConfigBfdRemoteIPRemoteIPInternalServerError with default headers values +func NewDeleteConfigBfdRemoteIPRemoteIPInternalServerError() *DeleteConfigBfdRemoteIPRemoteIPInternalServerError { + + return &DeleteConfigBfdRemoteIPRemoteIPInternalServerError{} +} + +// WithPayload adds the payload to the delete config bfd remote Ip remote Ip internal server error response +func (o *DeleteConfigBfdRemoteIPRemoteIPInternalServerError) WithPayload(payload *models.Error) *DeleteConfigBfdRemoteIPRemoteIPInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete config bfd remote Ip remote Ip internal server error response +func (o *DeleteConfigBfdRemoteIPRemoteIPInternalServerError) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteConfigBfdRemoteIPRemoteIPInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteConfigBfdRemoteIPRemoteIPServiceUnavailableCode is the HTTP code returned for type DeleteConfigBfdRemoteIPRemoteIPServiceUnavailable +const DeleteConfigBfdRemoteIPRemoteIPServiceUnavailableCode int = 503 + +/* +DeleteConfigBfdRemoteIPRemoteIPServiceUnavailable Maintanence mode + +swagger:response deleteConfigBfdRemoteIpRemoteIpServiceUnavailable +*/ +type DeleteConfigBfdRemoteIPRemoteIPServiceUnavailable struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteConfigBfdRemoteIPRemoteIPServiceUnavailable creates DeleteConfigBfdRemoteIPRemoteIPServiceUnavailable with default headers values +func NewDeleteConfigBfdRemoteIPRemoteIPServiceUnavailable() *DeleteConfigBfdRemoteIPRemoteIPServiceUnavailable { + + return &DeleteConfigBfdRemoteIPRemoteIPServiceUnavailable{} +} + +// WithPayload adds the payload to the delete config bfd remote Ip remote Ip service unavailable response +func (o *DeleteConfigBfdRemoteIPRemoteIPServiceUnavailable) WithPayload(payload *models.Error) *DeleteConfigBfdRemoteIPRemoteIPServiceUnavailable { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete config bfd remote Ip remote Ip service unavailable response +func (o *DeleteConfigBfdRemoteIPRemoteIPServiceUnavailable) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteConfigBfdRemoteIPRemoteIPServiceUnavailable) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(503) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/api/restapi/operations/delete_config_bfd_remote_ip_remote_ip_urlbuilder.go b/api/restapi/operations/delete_config_bfd_remote_ip_remote_ip_urlbuilder.go new file mode 100644 index 00000000..27565e77 --- /dev/null +++ b/api/restapi/operations/delete_config_bfd_remote_ip_remote_ip_urlbuilder.go @@ -0,0 +1,113 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// DeleteConfigBfdRemoteIPRemoteIPURL generates an URL for the delete config bfd remote IP remote IP operation +type DeleteConfigBfdRemoteIPRemoteIPURL struct { + RemoteIP string + + Instance *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteConfigBfdRemoteIPRemoteIPURL) WithBasePath(bp string) *DeleteConfigBfdRemoteIPRemoteIPURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteConfigBfdRemoteIPRemoteIPURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteConfigBfdRemoteIPRemoteIPURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/config/bfd/remoteIP/{remote_ip}" + + remoteIP := o.RemoteIP + if remoteIP != "" { + _path = strings.Replace(_path, "{remote_ip}", remoteIP, -1) + } else { + return nil, errors.New("remoteIp is required on DeleteConfigBfdRemoteIPRemoteIPURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/netlox/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var instanceQ string + if o.Instance != nil { + instanceQ = *o.Instance + } + if instanceQ != "" { + qs.Set("instance", instanceQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteConfigBfdRemoteIPRemoteIPURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteConfigBfdRemoteIPRemoteIPURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteConfigBfdRemoteIPRemoteIPURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteConfigBfdRemoteIPRemoteIPURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteConfigBfdRemoteIPRemoteIPURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteConfigBfdRemoteIPRemoteIPURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/api/restapi/operations/delete_config_bfd_remote_ip_responses.go b/api/restapi/operations/delete_config_bfd_remote_ip_responses.go new file mode 100644 index 00000000..d9ccb53f --- /dev/null +++ b/api/restapi/operations/delete_config_bfd_remote_ip_responses.go @@ -0,0 +1,354 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/loxilb-io/loxilb/api/models" +) + +// DeleteConfigBfdRemoteIPNoContentCode is the HTTP code returned for type DeleteConfigBfdRemoteIPNoContent +const DeleteConfigBfdRemoteIPNoContentCode int = 204 + +/* +DeleteConfigBfdRemoteIPNoContent OK + +swagger:response deleteConfigBfdRemoteIpNoContent +*/ +type DeleteConfigBfdRemoteIPNoContent struct { +} + +// NewDeleteConfigBfdRemoteIPNoContent creates DeleteConfigBfdRemoteIPNoContent with default headers values +func NewDeleteConfigBfdRemoteIPNoContent() *DeleteConfigBfdRemoteIPNoContent { + + return &DeleteConfigBfdRemoteIPNoContent{} +} + +// WriteResponse to the client +func (o *DeleteConfigBfdRemoteIPNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteConfigBfdRemoteIPBadRequestCode is the HTTP code returned for type DeleteConfigBfdRemoteIPBadRequest +const DeleteConfigBfdRemoteIPBadRequestCode int = 400 + +/* +DeleteConfigBfdRemoteIPBadRequest Malformed arguments for API call + +swagger:response deleteConfigBfdRemoteIpBadRequest +*/ +type DeleteConfigBfdRemoteIPBadRequest struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteConfigBfdRemoteIPBadRequest creates DeleteConfigBfdRemoteIPBadRequest with default headers values +func NewDeleteConfigBfdRemoteIPBadRequest() *DeleteConfigBfdRemoteIPBadRequest { + + return &DeleteConfigBfdRemoteIPBadRequest{} +} + +// WithPayload adds the payload to the delete config bfd remote Ip bad request response +func (o *DeleteConfigBfdRemoteIPBadRequest) WithPayload(payload *models.Error) *DeleteConfigBfdRemoteIPBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete config bfd remote Ip bad request response +func (o *DeleteConfigBfdRemoteIPBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteConfigBfdRemoteIPBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteConfigBfdRemoteIPUnauthorizedCode is the HTTP code returned for type DeleteConfigBfdRemoteIPUnauthorized +const DeleteConfigBfdRemoteIPUnauthorizedCode int = 401 + +/* +DeleteConfigBfdRemoteIPUnauthorized Invalid authentication credentials + +swagger:response deleteConfigBfdRemoteIpUnauthorized +*/ +type DeleteConfigBfdRemoteIPUnauthorized struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteConfigBfdRemoteIPUnauthorized creates DeleteConfigBfdRemoteIPUnauthorized with default headers values +func NewDeleteConfigBfdRemoteIPUnauthorized() *DeleteConfigBfdRemoteIPUnauthorized { + + return &DeleteConfigBfdRemoteIPUnauthorized{} +} + +// WithPayload adds the payload to the delete config bfd remote Ip unauthorized response +func (o *DeleteConfigBfdRemoteIPUnauthorized) WithPayload(payload *models.Error) *DeleteConfigBfdRemoteIPUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete config bfd remote Ip unauthorized response +func (o *DeleteConfigBfdRemoteIPUnauthorized) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteConfigBfdRemoteIPUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteConfigBfdRemoteIPForbiddenCode is the HTTP code returned for type DeleteConfigBfdRemoteIPForbidden +const DeleteConfigBfdRemoteIPForbiddenCode int = 403 + +/* +DeleteConfigBfdRemoteIPForbidden Capacity insufficient + +swagger:response deleteConfigBfdRemoteIpForbidden +*/ +type DeleteConfigBfdRemoteIPForbidden struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteConfigBfdRemoteIPForbidden creates DeleteConfigBfdRemoteIPForbidden with default headers values +func NewDeleteConfigBfdRemoteIPForbidden() *DeleteConfigBfdRemoteIPForbidden { + + return &DeleteConfigBfdRemoteIPForbidden{} +} + +// WithPayload adds the payload to the delete config bfd remote Ip forbidden response +func (o *DeleteConfigBfdRemoteIPForbidden) WithPayload(payload *models.Error) *DeleteConfigBfdRemoteIPForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete config bfd remote Ip forbidden response +func (o *DeleteConfigBfdRemoteIPForbidden) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteConfigBfdRemoteIPForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteConfigBfdRemoteIPNotFoundCode is the HTTP code returned for type DeleteConfigBfdRemoteIPNotFound +const DeleteConfigBfdRemoteIPNotFoundCode int = 404 + +/* +DeleteConfigBfdRemoteIPNotFound Resource not found + +swagger:response deleteConfigBfdRemoteIpNotFound +*/ +type DeleteConfigBfdRemoteIPNotFound struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteConfigBfdRemoteIPNotFound creates DeleteConfigBfdRemoteIPNotFound with default headers values +func NewDeleteConfigBfdRemoteIPNotFound() *DeleteConfigBfdRemoteIPNotFound { + + return &DeleteConfigBfdRemoteIPNotFound{} +} + +// WithPayload adds the payload to the delete config bfd remote Ip not found response +func (o *DeleteConfigBfdRemoteIPNotFound) WithPayload(payload *models.Error) *DeleteConfigBfdRemoteIPNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete config bfd remote Ip not found response +func (o *DeleteConfigBfdRemoteIPNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteConfigBfdRemoteIPNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteConfigBfdRemoteIPConflictCode is the HTTP code returned for type DeleteConfigBfdRemoteIPConflict +const DeleteConfigBfdRemoteIPConflictCode int = 409 + +/* +DeleteConfigBfdRemoteIPConflict Resource Conflict. BFD session already exists + +swagger:response deleteConfigBfdRemoteIpConflict +*/ +type DeleteConfigBfdRemoteIPConflict struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteConfigBfdRemoteIPConflict creates DeleteConfigBfdRemoteIPConflict with default headers values +func NewDeleteConfigBfdRemoteIPConflict() *DeleteConfigBfdRemoteIPConflict { + + return &DeleteConfigBfdRemoteIPConflict{} +} + +// WithPayload adds the payload to the delete config bfd remote Ip conflict response +func (o *DeleteConfigBfdRemoteIPConflict) WithPayload(payload *models.Error) *DeleteConfigBfdRemoteIPConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete config bfd remote Ip conflict response +func (o *DeleteConfigBfdRemoteIPConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteConfigBfdRemoteIPConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteConfigBfdRemoteIPInternalServerErrorCode is the HTTP code returned for type DeleteConfigBfdRemoteIPInternalServerError +const DeleteConfigBfdRemoteIPInternalServerErrorCode int = 500 + +/* +DeleteConfigBfdRemoteIPInternalServerError Internal service error + +swagger:response deleteConfigBfdRemoteIpInternalServerError +*/ +type DeleteConfigBfdRemoteIPInternalServerError struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteConfigBfdRemoteIPInternalServerError creates DeleteConfigBfdRemoteIPInternalServerError with default headers values +func NewDeleteConfigBfdRemoteIPInternalServerError() *DeleteConfigBfdRemoteIPInternalServerError { + + return &DeleteConfigBfdRemoteIPInternalServerError{} +} + +// WithPayload adds the payload to the delete config bfd remote Ip internal server error response +func (o *DeleteConfigBfdRemoteIPInternalServerError) WithPayload(payload *models.Error) *DeleteConfigBfdRemoteIPInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete config bfd remote Ip internal server error response +func (o *DeleteConfigBfdRemoteIPInternalServerError) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteConfigBfdRemoteIPInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteConfigBfdRemoteIPServiceUnavailableCode is the HTTP code returned for type DeleteConfigBfdRemoteIPServiceUnavailable +const DeleteConfigBfdRemoteIPServiceUnavailableCode int = 503 + +/* +DeleteConfigBfdRemoteIPServiceUnavailable Maintanence mode + +swagger:response deleteConfigBfdRemoteIpServiceUnavailable +*/ +type DeleteConfigBfdRemoteIPServiceUnavailable struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteConfigBfdRemoteIPServiceUnavailable creates DeleteConfigBfdRemoteIPServiceUnavailable with default headers values +func NewDeleteConfigBfdRemoteIPServiceUnavailable() *DeleteConfigBfdRemoteIPServiceUnavailable { + + return &DeleteConfigBfdRemoteIPServiceUnavailable{} +} + +// WithPayload adds the payload to the delete config bfd remote Ip service unavailable response +func (o *DeleteConfigBfdRemoteIPServiceUnavailable) WithPayload(payload *models.Error) *DeleteConfigBfdRemoteIPServiceUnavailable { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete config bfd remote Ip service unavailable response +func (o *DeleteConfigBfdRemoteIPServiceUnavailable) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteConfigBfdRemoteIPServiceUnavailable) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(503) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/api/restapi/operations/delete_config_bfd_remote_ip_urlbuilder.go b/api/restapi/operations/delete_config_bfd_remote_ip_urlbuilder.go new file mode 100644 index 00000000..68d5b492 --- /dev/null +++ b/api/restapi/operations/delete_config_bfd_remote_ip_urlbuilder.go @@ -0,0 +1,113 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// DeleteConfigBfdRemoteIPURL generates an URL for the delete config bfd remote IP operation +type DeleteConfigBfdRemoteIPURL struct { + RemoteIP string + + Instance *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteConfigBfdRemoteIPURL) WithBasePath(bp string) *DeleteConfigBfdRemoteIPURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteConfigBfdRemoteIPURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteConfigBfdRemoteIPURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/config/bfd/{remote_ip}" + + remoteIP := o.RemoteIP + if remoteIP != "" { + _path = strings.Replace(_path, "{remote_ip}", remoteIP, -1) + } else { + return nil, errors.New("remoteIp is required on DeleteConfigBfdRemoteIPURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/netlox/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var instanceQ string + if o.Instance != nil { + instanceQ = *o.Instance + } + if instanceQ != "" { + qs.Set("instance", instanceQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteConfigBfdRemoteIPURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteConfigBfdRemoteIPURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteConfigBfdRemoteIPURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteConfigBfdRemoteIPURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteConfigBfdRemoteIPURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteConfigBfdRemoteIPURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/api/restapi/operations/loxilb_rest_api_api.go b/api/restapi/operations/loxilb_rest_api_api.go index 8d90df47..86b40c15 100644 --- a/api/restapi/operations/loxilb_rest_api_api.go +++ b/api/restapi/operations/loxilb_rest_api_api.go @@ -42,6 +42,9 @@ func NewLoxilbRestAPIAPI(spec *loads.Document) *LoxilbRestAPIAPI { JSONProducer: runtime.JSONProducer(), + DeleteConfigBfdRemoteIPRemoteIPHandler: DeleteConfigBfdRemoteIPRemoteIPHandlerFunc(func(params DeleteConfigBfdRemoteIPRemoteIPParams) middleware.Responder { + return middleware.NotImplemented("operation DeleteConfigBfdRemoteIPRemoteIP has not yet been implemented") + }), DeleteConfigBgpNeighIPAddressHandler: DeleteConfigBgpNeighIPAddressHandlerFunc(func(params DeleteConfigBgpNeighIPAddressParams) middleware.Responder { return middleware.NotImplemented("operation DeleteConfigBgpNeighIPAddress has not yet been implemented") }), @@ -258,6 +261,8 @@ type LoxilbRestAPIAPI struct { // - application/json JSONProducer runtime.Producer + // DeleteConfigBfdRemoteIPRemoteIPHandler sets the operation handler for the delete config bfd remote IP remote IP operation + DeleteConfigBfdRemoteIPRemoteIPHandler DeleteConfigBfdRemoteIPRemoteIPHandler // DeleteConfigBgpNeighIPAddressHandler sets the operation handler for the delete config bgp neigh IP address operation DeleteConfigBgpNeighIPAddressHandler DeleteConfigBgpNeighIPAddressHandler // DeleteConfigEndpointEpipaddressIPAddressHandler sets the operation handler for the delete config endpoint epipaddress IP address operation @@ -455,6 +460,9 @@ func (o *LoxilbRestAPIAPI) Validate() error { unregistered = append(unregistered, "JSONProducer") } + if o.DeleteConfigBfdRemoteIPRemoteIPHandler == nil { + unregistered = append(unregistered, "DeleteConfigBfdRemoteIPRemoteIPHandler") + } if o.DeleteConfigBgpNeighIPAddressHandler == nil { unregistered = append(unregistered, "DeleteConfigBgpNeighIPAddressHandler") } @@ -723,6 +731,10 @@ func (o *LoxilbRestAPIAPI) initHandlerCache() { o.handlers = make(map[string]map[string]http.Handler) } + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/config/bfd/remoteIP/{remote_ip}"] = NewDeleteConfigBfdRemoteIPRemoteIP(o.context, o.DeleteConfigBfdRemoteIPRemoteIPHandler) if o.handlers["DELETE"] == nil { o.handlers["DELETE"] = make(map[string]http.Handler) } diff --git a/api/swagger.yml b/api/swagger.yml index c7b266d3..06a1a11e 100644 --- a/api/swagger.yml +++ b/api/swagger.yml @@ -2362,6 +2362,52 @@ paths: description: Maintanence mode schema: $ref: '#/definitions/Error' + '/config/bfd/remoteIP/{remote_ip}': + delete: + summary: Delete a BFD session + description: Delete a BFD session + parameters: + - name: remote_ip + in: path + type: string + required: true + description: Remote IP address + - name: instance + in: query + type: string + required: false + description: Cluster instance name + 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. BFD session already exists + schema: + $ref: '#/definitions/Error' + '500': + description: Internal service error + schema: + $ref: '#/definitions/Error' + '503': + description: Maintanence mode + schema: + $ref: '#/definitions/Error' #---------------------------------------------- # Schema definitions @@ -3292,8 +3338,7 @@ definitions: description: Retry Count to detect failure state: type: string - description: Current state for BFD session - + description: Current state for BFD session BfdEntry: type: object diff --git a/common/common.go b/common/common.go index 687fcf9a..96915cd6 100644 --- a/common/common.go +++ b/common/common.go @@ -863,5 +863,6 @@ type NetHookInterface interface { NetGoBGPGCAdd(gc *GoBGPGlobalConfig) (int, error) NetBFDGet() ([]BFDMod, error) NetBFDAdd(bm *BFDMod) (int, error) + NetBFDDel(bm *BFDMod) (int, error) NetHandlePanic() } diff --git a/go.sum b/go.sum index bd5663f0..e738ca63 100644 --- a/go.sum +++ b/go.sum @@ -260,8 +260,6 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/loxilb-io/ipvs v0.1.0 h1:TpTkwh5CLgJ7YW86rvWyqJPEpQFqs2TNbRG/IECeq+w= github.com/loxilb-io/ipvs v0.1.0/go.mod h1:EKjimnzyVL9AXMMNfPWeokxF1uNeuDrEGF5gPFMdmIo= -github.com/loxilb-io/loxilib v0.8.9-0.20231211082246-dc641488569f h1:q745LqB2G97bOpf6MCa34VyNJEuvVx4rTFVut3kz9oo= -github.com/loxilb-io/loxilib v0.8.9-0.20231211082246-dc641488569f/go.mod h1:LoQCxBz+N0fO9rGwRmPHrQPHol/jUf4MNpph63Cydkg= github.com/loxilb-io/loxilib v0.8.9-0.20240124072521-f37fbddfb4e8 h1:PYkgIX2fv1UluRR82SAot3O5YnwwCbcWc7VULvPv3QM= github.com/loxilb-io/loxilib v0.8.9-0.20240124072521-f37fbddfb4e8/go.mod h1:LoQCxBz+N0fO9rGwRmPHrQPHol/jUf4MNpph63Cydkg= github.com/loxilb-io/sctp v0.0.0-20230519081703-6d1baec82fd4 h1:oDc2lsbfuQEcVP3k+Pw4v6Xdm3t4M9vBc1Y9egszv6g= diff --git a/loxinet/apiclient.go b/loxinet/apiclient.go index ce1bb130..05098e6c 100644 --- a/loxinet/apiclient.go +++ b/loxinet/apiclient.go @@ -510,7 +510,7 @@ func (na *NetAPIStruct) NetBFDGet() ([]cmn.BFDMod, error) { return mh.has.CIBFDSessionGet() } -// NetCIStateMod - Modify cluster state +// NetBFDAdd - Add BFD Session func (na *NetAPIStruct) NetBFDAdd(bm *cmn.BFDMod) (int, error) { if na.BgpPeerMode { return CIErrBase, errors.New("running in bgp only mode") @@ -526,6 +526,22 @@ func (na *NetAPIStruct) NetBFDAdd(bm *cmn.BFDMod) (int, error) { return 0, nil } +// NetBFDDel - Delete BFD Session +func (na *NetAPIStruct) NetBFDDel(bm *cmn.BFDMod) (int, error) { + if na.BgpPeerMode { + return CIErrBase, errors.New("running in bgp only mode") + } + mh.mtx.Lock() + defer mh.mtx.Unlock() + + _, err := mh.has.CIBFDSessionDel(*bm) + if err != nil { + return -1, err + } + + return 0, nil +} + // NetFwRuleAdd - Add a firewall rule in loxinet func (na *NetAPIStruct) NetFwRuleAdd(fm *cmn.FwRuleMod) (int, error) { if na.BgpPeerMode { diff --git a/loxinet/cluster.go b/loxinet/cluster.go index 66b5eba3..f6de07b3 100644 --- a/loxinet/cluster.go +++ b/loxinet/cluster.go @@ -82,7 +82,7 @@ func (ci *CIStateH) BFDSessionNotify(instance string, remote string, ciState str ci.CIStateUpdate(sm) } -func (ci *CIStateH) startBFDProto() { +func (ci *CIStateH) startBFDProto(bfdSessConfigArgs bfd.ConfigArgs) { url := fmt.Sprintf("http://127.0.0.1:%d/config/params", opts.Opts.Port) for { if IsLoxiAPIActive(url) { @@ -101,21 +101,13 @@ func (ci *CIStateH) startBFDProto() { txInterval = uint32(ci.Interval) } - bfdSessConfigArgs := bfd.ConfigArgs{RemoteIP: ci.RemoteIP.String(), SourceIP: ci.SourceIP.String(), - Port: cmn.BFDPort, Interval: txInterval, Multi: cmn.BFDDefRetryCount, Instance: cmn.CIDefault} err := ci.Bs.BFDAddRemote(bfdSessConfigArgs, ci) if err != nil { - tk.LogIt(tk.LogCritical, "KA - Cant add BFD remote\n") - os.Exit(1) + tk.LogIt(tk.LogCritical, "KA - Cant add BFD remote: %s\n", err.Error()) + //os.Exit(1) + return } tk.LogIt(tk.LogInfo, "KA - Added BFD remote %s:%s:%vus\n", ci.RemoteIP.String(), ci.SourceIP.String(), txInterval) - if _, err := os.Stat("/etc/loxilb/BFDconfig.txt"); errors.Is(err, os.ErrNotExist) { - if err != nil { - tk.LogIt(tk.LogInfo, "[Init] No BFD config file : %s \n", err.Error()) - } - } else { - nlp.ApplyBFDConfig() - } } // CITicker - Periodic ticker for Cluster module @@ -127,8 +119,15 @@ func (h *CIStateH) CITicker() { func (ci *CIStateH) CISpawn() { bs := bfd.StructNew(3784) ci.Bs = bs + if _, err := os.Stat("/etc/loxilb/BFDconfig.txt"); !errors.Is(err, os.ErrNotExist) { + nlp.ApplyBFDConfig() + return + } + if ci.SpawnKa { - go ci.startBFDProto() + bfdSessConfigArgs := bfd.ConfigArgs{RemoteIP: ci.RemoteIP.String(), SourceIP: ci.SourceIP.String(), + Port: cmn.BFDPort, Interval: bfd.BFDMinSysTXIntervalUs, Multi: cmn.BFDDefRetryCount, Instance: cmn.CIDefault} + go ci.startBFDProto(bfdSessConfigArgs) } } @@ -275,9 +274,48 @@ func (h *CIStateH) ClusterNodeDelete(node cmn.ClusterNodeMod) (int, error) { return 0, nil } -// CIStateUpdate - routine to update cluster state +// CIBFDSessionAdd - routine to add BFD session func (h *CIStateH) CIBFDSessionAdd(bm cmn.BFDMod) (int, error) { + if bm.Interval != 0 && bm.Interval < bfd.BFDMinSysTXIntervalUs { + tk.LogIt(tk.LogError, "[CLUSTER] BFD session Interval value too low\n") + return -1, errors.New("bfd interval too low") + } + + _, found := h.ClusterMap[bm.Instance] + if !found { + tk.LogIt(tk.LogError, "[CLUSTER] BFD SU - Cluster Instance %s not found\n", bm.Instance) + return -1, errors.New("cluster instance not found") + } + + if !h.SpawnKa { + tk.LogIt(tk.LogInfo, "[CLUSTER] Cluster Instance %s starting BFD..\n", bm.Instance) + h.SpawnKa = true + + h.RemoteIP = bm.RemoteIP + h.SourceIP = bm.SourceIP + h.Interval = int64(bm.Interval) + bfdSessConfigArgs := bfd.ConfigArgs{RemoteIP: bm.RemoteIP.String(), SourceIP: bm.SourceIP.String(), + Port: cmn.BFDPort, Interval: uint32(bm.Interval), + Multi: bm.RetryCount, Instance: bm.Instance} + go h.startBFDProto(bfdSessConfigArgs) + } else { + bfdSessConfigArgs := bfd.ConfigArgs{RemoteIP: h.RemoteIP.String(), SourceIP: h.SourceIP.String(), + Port: cmn.BFDPort, Interval: uint32(bm.Interval), + Multi: bm.RetryCount, Instance: bm.Instance} + err := h.Bs.BFDAddRemote(bfdSessConfigArgs, h) + if err != nil { + tk.LogIt(tk.LogCritical, "KA - Cant add BFD remote: %s\n",err.Error()) + return -1, err + } + tk.LogIt(tk.LogInfo, "KA - BFD remote %s:%s:%vus Added\n", h.RemoteIP.String(), h.SourceIP.String(), bm.Interval) + } + return 0, nil +} + +// CIBFDSessionDel - routine to delete BFD session +func (h *CIStateH) CIBFDSessionDel(bm cmn.BFDMod) (int, error) { + if !h.SpawnKa { tk.LogIt(tk.LogError, "[CLUSTER] Cluster Instance %s not running BFD\n", bm.Instance) return -1, errors.New("bfd session not running") @@ -289,17 +327,18 @@ func (h *CIStateH) CIBFDSessionAdd(bm cmn.BFDMod) (int, error) { return -1, errors.New("cluster instance not found") } - bfdSessConfigArgs := bfd.ConfigArgs{RemoteIP: h.RemoteIP.String(), SourceIP: h.SourceIP.String(), Port: 3784, Interval: uint32(bm.Interval), Multi: bm.RetryCount, Instance: bm.Instance} - err := h.Bs.BFDAddRemote(bfdSessConfigArgs, h) + bfdSessConfigArgs := bfd.ConfigArgs{RemoteIP: h.RemoteIP.String()} + err := h.Bs.BFDDeleteRemote(bfdSessConfigArgs) if err != nil { - tk.LogIt(tk.LogCritical, "KA - Cant add BFD remote\n") - os.Exit(1) + tk.LogIt(tk.LogCritical, "KA - Cant delete BFD remote\n") + return -1, err } - tk.LogIt(tk.LogInfo, "KA - Updated BFD remote %s:%s:%vus\n", h.RemoteIP.String(), h.SourceIP.String(), bm.Interval) + h.SpawnKa = false + tk.LogIt(tk.LogInfo, "KA - BFD remote %s:%s:%vus deleted\n", h.RemoteIP.String(), h.SourceIP.String(), bm.Interval) return 0, nil } -// CIStateUpdate - routine to update cluster state +// CIBFDSessionGet - routine to get BFD session info func (h *CIStateH) CIBFDSessionGet() ([]cmn.BFDMod, error) { if !h.SpawnKa { tk.LogIt(tk.LogError, "[CLUSTER] BFD sessions not running\n") diff --git a/proto/bfd.go b/proto/bfd.go index 08e433b0..6b310c56 100644 --- a/proto/bfd.go +++ b/proto/bfd.go @@ -160,7 +160,8 @@ func (bs *Struct) BFDAddRemote(args ConfigArgs, cbs Notifer) error { err := sess.initialize(args.RemoteIP, args.SourceIP, args.Port, args.Interval, args.Multi) if err != nil { - return errors.New("bfd failed to init session") + return err + //return errors.New("bfd failed to init session") } bs.BFDSessMap[args.RemoteIP] = sess @@ -178,7 +179,7 @@ func (bs *Struct) BFDDeleteRemote(args ConfigArgs) error { } sess.destruct() - delete(bs.BFDSessMap, sess.RemoteName) + delete(bs.BFDSessMap, args.RemoteIP) return nil } @@ -304,7 +305,7 @@ func (b *bfdSession) RunSessionSM(raw *WireRaw) { if b.State != BFDAdminDown { tk.LogIt(tk.LogInfo, "%s: BFD State -> AdminDown\n", b.RemoteName) } - b.State = BFDAdminDown + b.State = BFDInit } else if raw.State == BFDUp { if b.State != BFDUp { tk.LogIt(tk.LogInfo, "%s: BFD State -> UP\n", b.RemoteName)