Skip to content

Commit 43ca77f

Browse files
authored
Merge pull request #23 from loxilb-io/fw-count
PR: support for fw-counters
2 parents 79712bf + 7cd57e5 commit 43ca77f

File tree

14 files changed

+37
-36
lines changed

14 files changed

+37
-36
lines changed

cmd/create/create_bfd.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ package create
1717

1818
import (
1919
"context"
20+
"errors"
2021
"fmt"
2122
"loxicmd/pkg/api"
2223
"net"
2324
"net/http"
2425
"os"
2526
"time"
26-
"errors"
2727

2828
"github.com/spf13/cobra"
2929
)
@@ -45,7 +45,7 @@ ex) loxicmd create bfd 32.32.32.2 --instance=default --sourceIP=32.32.32.1 --int
4545
}
4646
},
4747
Run: func(cmd *cobra.Command, args []string) {
48-
48+
4949
// Make EndPointMod
5050
if len(args) <= 0 {
5151
fmt.Printf("create bfd needs remoteIP args\n")
@@ -62,7 +62,6 @@ ex) loxicmd create bfd 32.32.32.2 --instance=default --sourceIP=32.32.32.1 --int
6262
fmt.Printf("Error: %s\n", err.Error())
6363
return
6464
}
65-
6665

6766
//fmt.Printf("Debug: response.StatusCode: %d\n", resp.StatusCode)
6867
if resp.StatusCode == http.StatusOK {

cmd/create/create_file.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,4 +203,4 @@ func BFDCreateWithFile(restOptions *api.RESTOptions, byteBuf []byte) error {
203203
return err
204204
}
205205
return nil
206-
}
206+
}

cmd/delete/delete_bfd.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ ex) loxicmd delete bfd 32.32.32.2 --instance=default"
7272
return
7373
}
7474
defer resp.Body.Close()
75-
75+
7676
fmt.Printf("Debug: response.StatusCode: %d\n", resp.StatusCode)
7777
if resp.StatusCode == http.StatusOK {
7878
PrintDeleteResult(resp, *restOptions)
@@ -81,6 +81,6 @@ ex) loxicmd delete bfd 32.32.32.2 --instance=default"
8181
},
8282
}
8383
deleteBFDCmd.Flags().StringVarP(&o.Instance, "instance", "", "default", "Specify the cluster instance name")
84-
84+
8585
return deleteBFDCmd
8686
}

cmd/dump/apply.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,4 +710,4 @@ func ApplyBFDConfig(file string, restOptions *api.RESTOptions) {
710710
}
711711
defer resp.Body.Close()
712712
}
713-
}
713+
}

cmd/dump/save.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ func SaveCmd(saveOpts *SaveOptions, restOptions *api.RESTOptions) *cobra.Command
4646
_ = cmd
4747
_ = args
4848
dpath := "/etc/loxilb/"
49-
if (!saveOpts.SaveIpConfig && !saveOpts.SaveAllConfig &&
49+
if !saveOpts.SaveIpConfig && !saveOpts.SaveAllConfig &&
5050
!saveOpts.SaveLBConfig && !saveOpts.SaveSessionConfig &&
51-
!saveOpts.SaveUlClConfig && !saveOpts.SaveFWConfig &&
52-
!saveOpts.SaveEPConfig && !saveOpts.SaveBFDConfig) {
53-
fmt.Println("Provide valid options")
54-
cmd.Help()
55-
return
56-
}
51+
!saveOpts.SaveUlClConfig && !saveOpts.SaveFWConfig &&
52+
!saveOpts.SaveEPConfig && !saveOpts.SaveBFDConfig {
53+
fmt.Println("Provide valid options")
54+
cmd.Help()
55+
return
56+
}
5757
if _, err := os.Stat(dpath); errors.Is(err, os.ErrNotExist) {
5858
err := os.Mkdir(dpath, os.ModePerm)
5959
if err != nil {

cmd/get/get_bfd.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,24 @@ package get
1818
import (
1919
"context"
2020
"encoding/json"
21+
"errors"
2122
"fmt"
2223
"io"
2324
"loxicmd/pkg/api"
2425
"net/http"
25-
"time"
26-
"strings"
2726
"os"
2827
"os/exec"
29-
"errors"
28+
"strings"
29+
"time"
3030

3131
"github.com/spf13/cobra"
3232
)
3333

3434
func NewGetBFDCmd(restOptions *api.RESTOptions) *cobra.Command {
3535
var GetBFDCmd = &cobra.Command{
36-
Use: "bfd",
37-
Short: "Get all BFD sessions",
38-
Long: `It shows BFD Sessions in the LoxiLB`,
36+
Use: "bfd",
37+
Short: "Get all BFD sessions",
38+
Long: `It shows BFD Sessions in the LoxiLB`,
3939

4040
Run: func(cmd *cobra.Command, args []string) {
4141
client := api.NewLoxiClient(restOptions)
@@ -90,7 +90,7 @@ func PrintGetBFDResult(resp *http.Response, o api.RESTOptions) {
9090
if o.PrintOption == "wide" {
9191
table.SetHeader(BFD_WIDE_TITLE)
9292
data = append(data, []string{bfd.Instance, bfd.RemoteIP, bfd.SourceIP,
93-
fmt.Sprintf("%d",bfd.Port), fmt.Sprintf("%d us",bfd.Interval), fmt.Sprintf("%d",bfd.RetryCount), bfd.State})
93+
fmt.Sprintf("%d", bfd.Port), fmt.Sprintf("%d us", bfd.Interval), fmt.Sprintf("%d", bfd.RetryCount), bfd.State})
9494
} else {
9595
table.SetHeader(BFD_TITLE)
9696
data = append(data, []string{bfd.Instance, bfd.RemoteIP, bfd.State})
@@ -138,10 +138,10 @@ func BFDdump(restOptions *api.RESTOptions, path string) (string, error) {
138138
fmt.Printf("Error: Failed to unmarshal HTTP response: (%s)\n", err.Error())
139139
return "", err
140140
}
141-
141+
142142
bfds := api.BFDSessionGet{}
143143
bfds.BFDSessionAttr = BFDresp.BFDSessionAttr
144-
144+
145145
cfgResultByte, err := json.Marshal(bfds)
146146
if err != nil {
147147
fmt.Printf("Error: Failed to marshal BFD Cfg: (%s)\n", err.Error())

cmd/get/get_firewall.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func PrintGetFWResult(resp *http.Response, o api.RESTOptions) {
9494
table.SetHeader(FIREWALL_TITLE)
9595
data = append(data, []string{fwrule.Rule.SrcIP, fwrule.Rule.DstIP, fmt.Sprintf("%d", fwrule.Rule.SrcPortMin), fmt.Sprintf("%d", fwrule.Rule.SrcPortMax),
9696
fmt.Sprintf("%d", fwrule.Rule.DstPortMin), fmt.Sprintf("%d", fwrule.Rule.DstPortMax), fmt.Sprintf("%d", fwrule.Rule.Proto),
97-
fwrule.Rule.InPort, fmt.Sprintf("%d", fwrule.Rule.Pref), MakeFirewallOptionToString(fwrule.Opts)})
97+
fwrule.Rule.InPort, fmt.Sprintf("%d", fwrule.Rule.Pref), MakeFirewallOptionToString(fwrule.Opts), fmt.Sprintf("%s", fwrule.Opts.Counter)})
9898

9999
}
100100

cmd/get/get_hastate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,4 @@ func PrintGetHAStateResult(resp *http.Response, o api.RESTOptions) {
8888
}
8989
// Rendering the load balance data to table
9090
TableShow(data, table)
91-
}
91+
}

cmd/get/type.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ var (
4040
FILESYSTEM_TITLE = []string{"fileSystem", "type", "size", "used", "avail", "usePercent", "mountedOn"}
4141
MIRROR_TITLE = []string{"Mirror Name", "Mirror info", "Target\nAttachment", "target\nName"}
4242
MIRROR_WIDE_TITLE = []string{"Mirror Name", "Mirror info", "Target\nAttachment", "target\nName", "Sync"}
43-
FIREWALL_TITLE = []string{"Source IP", "destination IP", "min SPort", "max SPort", "min DPort", "max DPort", "protocol", "port Name", "preference", "Option"}
43+
FIREWALL_TITLE = []string{"Source IP", "destination IP", "min SPort", "max SPort", "min DPort", "max DPort", "protocol", "port Name", "preference", "Option", "Counters"}
4444
ENDPOINT_TITLE = []string{"Host", "Name", "ptype", "port", "duration", "retries", "minDelay", "avgDelay", "maxDelay", "State"}
4545
PARAM_TITLE = []string{"Param Name", "Value"}
4646
BGPNEIGHBOR_TITLE = []string{"Peer", "AS", "UP/Down", "State"}
4747
HASTATE_TITLE = []string{"Instance", "HAState"}
4848
BFD_TITLE = []string{"Instance", "RemoteIP", "State"}
49-
BFD_WIDE_TITLE = []string{"Instance", "RemoteIP", "SourceIP", "Port", "Interval","Retry Count", "State"}
49+
BFD_WIDE_TITLE = []string{"Instance", "RemoteIP", "SourceIP", "Port", "Interval", "Retry Count", "State"}
5050
)

cmd/set/set_bfd.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ import (
2020
"errors"
2121
"fmt"
2222
"loxicmd/pkg/api"
23+
"net"
2324
"net/http"
2425
"time"
25-
"net"
2626

2727
"github.com/spf13/cobra"
2828
)
@@ -31,9 +31,9 @@ import (
3131
func NewSetBFDCmd(restOptions *api.RESTOptions) *cobra.Command {
3232
o := api.BFDSessionInfo{}
3333
SetBFDCmd := &cobra.Command{
34-
Use: "bfd remoteIP [--instance=<instance>] [--interval=<interval>] [--retryCount=<count>]",
35-
Short: "bfd session configuration",
36-
Long: `bfd session congfigration
34+
Use: "bfd remoteIP [--instance=<instance>] [--interval=<interval>] [--retryCount=<count>]",
35+
Short: "bfd session configuration",
36+
Long: `bfd session congfigration
3737
--instance - Cluster Instance name
3838
--interval - BFD packet Tx interval value in microseconds
3939
--retryCount - Maximum number of retry to detect failure`,

0 commit comments

Comments
 (0)