Skip to content

Commit

Permalink
feat(evpn): enable tls on godpu
Browse files Browse the repository at this point in the history
Signed-off-by: Atul Patel <[email protected]>
  • Loading branch information
atulpatel261194 committed May 16, 2024
1 parent e4af793 commit fdb2b35
Show file tree
Hide file tree
Showing 30 changed files with 451 additions and 150 deletions.
6 changes: 4 additions & 2 deletions cmd/inventory/inventory-get.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@ import (
// NewGetCommand returns the inventory get command
func NewGetCommand() *cobra.Command {
var (
addr string
addr string
tlsFiles string

Check warning on line 20 in cmd/inventory/inventory-get.go

View check run for this annotation

Codecov / codecov/patch

cmd/inventory/inventory-get.go#L19-L20

Added lines #L19 - L20 were not covered by tests
)
cmd := &cobra.Command{
Use: "get",
Aliases: []string{"g"},
Short: "Gets DPU inventory information",
Args: cobra.NoArgs,
Run: func(_ *cobra.Command, _ []string) {
invClient, err := inventory.New(addr)
invClient, err := inventory.New(addr, tlsFiles)

Check warning on line 28 in cmd/inventory/inventory-get.go

View check run for this annotation

Codecov / codecov/patch

cmd/inventory/inventory-get.go#L28

Added line #L28 was not covered by tests
if err != nil {
log.Fatalf("could create gRPC client: %v", err)
}
Expand All @@ -41,6 +42,7 @@ func NewGetCommand() *cobra.Command {
}
flags := cmd.Flags()
flags.StringVar(&addr, "addr", "localhost:50151", "address of OPI gRPC server")
flags.StringVar(&tlsFiles, "tlsfiles", "", "TLS files in client_cert:client_key:ca_cert format.")

Check warning on line 45 in cmd/inventory/inventory-get.go

View check run for this annotation

Codecov / codecov/patch

cmd/inventory/inventory-get.go#L45

Added line #L45 was not covered by tests
return cmd
}

Expand Down
4 changes: 3 additions & 1 deletion cmd/ipsec/ipsec-stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import (
// NewStatsCommand returns the ipsec stats command
func NewStatsCommand() *cobra.Command {
var (
addr string
addr string
tlsFiles string

Check warning on line 19 in cmd/ipsec/ipsec-stats.go

View check run for this annotation

Codecov / codecov/patch

cmd/ipsec/ipsec-stats.go#L18-L19

Added lines #L18 - L19 were not covered by tests
)
cmd := &cobra.Command{
Use: "stats",
Expand All @@ -29,6 +30,7 @@ func NewStatsCommand() *cobra.Command {
}
flags := cmd.Flags()
flags.StringVar(&addr, "addr", "localhost:50151", "address or OPI gRPC server")
flags.StringVar(&tlsFiles, "tls", "", "TLS files in client_cert:client_key:ca_cert format.")

Check warning on line 33 in cmd/ipsec/ipsec-stats.go

View check run for this annotation

Codecov / codecov/patch

cmd/ipsec/ipsec-stats.go#L33

Added line #L33 was not covered by tests
return cmd
}

Expand Down
2 changes: 2 additions & 0 deletions cmd/ipsec/ipsec-test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ func NewTestCommand() *cobra.Command {
var (
addr string
pingaddr string
tlsFiles string

Check warning on line 19 in cmd/ipsec/ipsec-test.go

View check run for this annotation

Codecov / codecov/patch

cmd/ipsec/ipsec-test.go#L19

Added line #L19 was not covered by tests
)
cmd := &cobra.Command{
Use: "test",
Expand All @@ -30,5 +31,6 @@ func NewTestCommand() *cobra.Command {
flags := cmd.Flags()
flags.StringVar(&addr, "addr", "localhost:50151", "address or OPI gRPC server")
flags.StringVar(&pingaddr, "pingaddr", "localhost", "address of other tunnel end to Ping")
flags.StringVar(&tlsFiles, "tls", "", "TLS files in client_cert:client_key:ca_cert format.")

Check warning on line 34 in cmd/ipsec/ipsec-test.go

View check run for this annotation

Codecov / codecov/patch

cmd/ipsec/ipsec-test.go#L34

Added line #L34 was not covered by tests
return cmd
}
66 changes: 46 additions & 20 deletions cmd/network/evpn-bridge-port.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (

// CreateBridgePort creates an Bridge Port an OPI server
func CreateBridgePort() *cobra.Command {
var addr string
var name string
var mac string
var bridgePortType string
Expand All @@ -27,9 +26,15 @@ func CreateBridgePort() *cobra.Command {
Use: "create-bp",
Short: "Create a bridge port",
Long: "Create a BridgePort with the specified name, MAC address, type, and VLAN IDs",
Run: func(_ *cobra.Command, _ []string) {
Run: func(c *cobra.Command, _ []string) {

Check warning on line 29 in cmd/network/evpn-bridge-port.go

View check run for this annotation

Codecov / codecov/patch

cmd/network/evpn-bridge-port.go#L29

Added line #L29 was not covered by tests
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
evpnClient, err := network.NewBridgePort(addr)

tlsFiles, err := c.Flags().GetString(TLSFiles)
cobra.CheckErr(err)

addr, err := c.Flags().GetString(AddrCmdLineArg)
cobra.CheckErr(err)
evpnClient, err := network.NewBridgePort(addr, tlsFiles)

Check warning on line 37 in cmd/network/evpn-bridge-port.go

View check run for this annotation

Codecov / codecov/patch

cmd/network/evpn-bridge-port.go#L31-L37

Added lines #L31 - L37 were not covered by tests
if err != nil {
log.Fatalf("could not create gRPC client: %v", err)
}
Expand All @@ -49,7 +54,6 @@ func CreateBridgePort() *cobra.Command {
cmd.Flags().StringVar(&mac, "mac", "", "Specify the MAC address")
cmd.Flags().StringVarP(&bridgePortType, "type", "t", "", "Specify the type (access or trunk)")
cmd.Flags().StringSliceVar(&logicalBridges, "logicalBridges", []string{}, "Specify VLAN IDs (multiple values supported)")
cmd.Flags().StringVar(&addr, "addr", "localhost:50151", "address of OPI gRPC server")

if err := cmd.MarkFlagRequired("mac"); err != nil {
log.Fatalf("Error marking flag as required: %v", err)
Expand All @@ -70,17 +74,23 @@ func CreateBridgePort() *cobra.Command {

// DeleteBridgePort delete an Bridge Port an OPI server
func DeleteBridgePort() *cobra.Command {
var addr string
var name string
var allowMissing bool

cmd := &cobra.Command{
Use: "delete-bp",
Short: "Delete a bridge port",
Long: "Delete a BridgePort with the specified name",
Run: func(_ *cobra.Command, _ []string) {
Run: func(c *cobra.Command, _ []string) {

Check warning on line 84 in cmd/network/evpn-bridge-port.go

View check run for this annotation

Codecov / codecov/patch

cmd/network/evpn-bridge-port.go#L84

Added line #L84 was not covered by tests
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
evpnClient, err := network.NewBridgePort(addr)

tlsFiles, err := c.Flags().GetString(TLSFiles)
cobra.CheckErr(err)

addr, err := c.Flags().GetString(AddrCmdLineArg)
cobra.CheckErr(err)

evpnClient, err := network.NewBridgePort(addr, tlsFiles)

Check warning on line 93 in cmd/network/evpn-bridge-port.go

View check run for this annotation

Codecov / codecov/patch

cmd/network/evpn-bridge-port.go#L86-L93

Added lines #L86 - L93 were not covered by tests
if err != nil {
log.Fatalf("could not create gRPC client: %v", err)
}
Expand All @@ -97,23 +107,28 @@ func DeleteBridgePort() *cobra.Command {

cmd.Flags().StringVarP(&name, "name", "n", "", "Specify the name of the BridgePort")
cmd.Flags().BoolVarP(&allowMissing, "allowMissing", "a", false, "Specify if missing allowed")
cmd.Flags().StringVar(&addr, "addr", "localhost:50151", "address of OPI gRPC server")

return cmd
}

// GetBridgePort Get Bridge Port details
func GetBridgePort() *cobra.Command {
var addr string
var name string

cmd := &cobra.Command{
Use: "get-bp",
Short: "Show details of a bridge port",
Long: "Show details of a BridgePort with the specified name",
Run: func(_ *cobra.Command, _ []string) {
Run: func(c *cobra.Command, _ []string) {

Check warning on line 122 in cmd/network/evpn-bridge-port.go

View check run for this annotation

Codecov / codecov/patch

cmd/network/evpn-bridge-port.go#L122

Added line #L122 was not covered by tests
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
evpnClient, err := network.NewBridgePort(addr)

tlsFiles, err := c.Flags().GetString(TLSFiles)
cobra.CheckErr(err)

addr, err := c.Flags().GetString(AddrCmdLineArg)
cobra.CheckErr(err)

evpnClient, err := network.NewBridgePort(addr, tlsFiles)

Check warning on line 131 in cmd/network/evpn-bridge-port.go

View check run for this annotation

Codecov / codecov/patch

cmd/network/evpn-bridge-port.go#L124-L131

Added lines #L124 - L131 were not covered by tests
if err != nil {
log.Fatalf("could not create gRPC client: %v", err)
}
Expand All @@ -130,7 +145,6 @@ func GetBridgePort() *cobra.Command {
}

cmd.Flags().StringVarP(&name, "name", "n", "", "Specify the name of the BridgePort")
cmd.Flags().StringVar(&addr, "addr", "localhost:50151", "address of OPI gRPC server")

if err := cmd.MarkFlagRequired("name"); err != nil {
log.Fatalf("Error marking flag as required: %v", err)
Expand All @@ -140,16 +154,22 @@ func GetBridgePort() *cobra.Command {

// ListBridgePorts list all the Bridge Port an OPI server
func ListBridgePorts() *cobra.Command {
var addr string
var pageSize int32
var pageToken string

cmd := &cobra.Command{
Use: "list-bps",
Short: "Show details of all bridge ports",
Run: func(_ *cobra.Command, _ []string) {
Run: func(c *cobra.Command, _ []string) {

Check warning on line 163 in cmd/network/evpn-bridge-port.go

View check run for this annotation

Codecov / codecov/patch

cmd/network/evpn-bridge-port.go#L163

Added line #L163 was not covered by tests
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
evpnClient, err := network.NewBridgePort(addr)

tlsFiles, err := c.Flags().GetString(TLSFiles)
cobra.CheckErr(err)

addr, err := c.Flags().GetString(AddrCmdLineArg)
cobra.CheckErr(err)

evpnClient, err := network.NewBridgePort(addr, tlsFiles)

Check warning on line 172 in cmd/network/evpn-bridge-port.go

View check run for this annotation

Codecov / codecov/patch

cmd/network/evpn-bridge-port.go#L165-L172

Added lines #L165 - L172 were not covered by tests
if err != nil {
log.Fatalf("could not create gRPC client: %v", err)
}
Expand Down Expand Up @@ -178,13 +198,12 @@ func ListBridgePorts() *cobra.Command {
}
cmd.Flags().Int32VarP(&pageSize, "pagesize", "s", 0, "Specify page size")
cmd.Flags().StringVarP(&pageToken, "pagetoken", "t", "", "Specify the token")
cmd.Flags().StringVar(&addr, "addr", "localhost:50151", "address of OPI gRPC server")

Check warning on line 201 in cmd/network/evpn-bridge-port.go

View check run for this annotation

Codecov / codecov/patch

cmd/network/evpn-bridge-port.go#L201

Added line #L201 was not covered by tests
return cmd
}

// UpdateBridgePort update the Bridge Port on OPI server
func UpdateBridgePort() *cobra.Command {
var addr string
var name string
var updateMask []string
var allowMissing bool
Expand All @@ -193,9 +212,16 @@ func UpdateBridgePort() *cobra.Command {
Use: "update-bp",
Short: "Update the bridge port",
Long: "updates the Bridge Port with updated mask",
Run: func(_ *cobra.Command, _ []string) {
Run: func(c *cobra.Command, _ []string) {

Check warning on line 215 in cmd/network/evpn-bridge-port.go

View check run for this annotation

Codecov / codecov/patch

cmd/network/evpn-bridge-port.go#L215

Added line #L215 was not covered by tests
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
evpnClient, err := network.NewBridgePort(addr)

tlsFiles, err := c.Flags().GetString(TLSFiles)
cobra.CheckErr(err)

addr, err := c.Flags().GetString(AddrCmdLineArg)
cobra.CheckErr(err)

evpnClient, err := network.NewBridgePort(addr, tlsFiles)

Check warning on line 224 in cmd/network/evpn-bridge-port.go

View check run for this annotation

Codecov / codecov/patch

cmd/network/evpn-bridge-port.go#L217-L224

Added lines #L217 - L224 were not covered by tests
if err != nil {
log.Fatalf("could not create gRPC client: %v", err)
}
Expand All @@ -214,6 +240,6 @@ func UpdateBridgePort() *cobra.Command {
cmd.Flags().StringVar(&name, "name", "", "name of the Bridge Port")
cmd.Flags().StringSliceVar(&updateMask, "update-mask", nil, "update mask")
cmd.Flags().BoolVarP(&allowMissing, "allowMissing", "a", false, "allow the missing")
cmd.Flags().StringVar(&addr, "addr", "localhost:50151", "address of OPI gRPC server")

Check warning on line 243 in cmd/network/evpn-bridge-port.go

View check run for this annotation

Codecov / codecov/patch

cmd/network/evpn-bridge-port.go#L243

Added line #L243 was not covered by tests
return cmd
}
Loading

0 comments on commit fdb2b35

Please sign in to comment.