Skip to content

Commit

Permalink
feat: add network interface capability
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Sanders <marksanders194@gmail.com>
  • Loading branch information
sandersms committed Jan 8, 2025
1 parent 4918e77 commit cdd8ef2
Show file tree
Hide file tree
Showing 13 changed files with 275 additions and 164 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ go-build:

go-get:
@echo " > Checking if there are any missing dependencies..."
@CGO_ENABLED=0 go get .
@CGO_ENABLED=0 go get ./...

go-test:
@echo " > Running ginkgo test suites..."
Expand Down
4 changes: 2 additions & 2 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/spf13/cobra"
)

// NewCommand handles the cli for evpn, ipsec, invetory and storage
// NewCommand handles the cli for network, ipsec, invetory and storage
func NewCommand() *cobra.Command {
//
// This is the root command for the CLI
Expand All @@ -36,7 +36,7 @@ func NewCommand() *cobra.Command {
c.AddCommand(inventory.NewInventoryCommand())
c.AddCommand(ipsec.NewIPSecCommand())
c.AddCommand(storage.NewStorageCommand())
c.AddCommand(network.NewEvpnCommand())
c.AddCommand(network.NewNetworkCommand())

flags := c.PersistentFlags()
flags.String(common.AddrCmdLineArg, "localhost:50151", "address of OPI gRPC server")
Expand Down
54 changes: 0 additions & 54 deletions cmd/network/evpn-test.go

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// Copyright (c) 2022-2023 Dell Inc, or its subsidiaries.
// Copyright (c) 2024 Ericsson AB.

// Package network implements the network related CLI commands
package network
// Package evpn implements the evpn network related CLI commands
package evpn

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// Copyright (c) 2022-2023 Dell Inc, or its subsidiaries.
// Copyright (c) 2024 Ericsson AB.

// Package network implements the network related CLI commands
package network
// Package evpn implements the evpn network related CLI commands
package evpn

import (
"context"
Expand Down
4 changes: 2 additions & 2 deletions cmd/network/evpn-svi.go → cmd/network/evpn/evpn-svi.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// Copyright (c) 2022-2023 Dell Inc, or its subsidiaries.
// Copyright (c) 2024 Ericsson AB.

// Package network implements the network related CLI commands
package network
// Package evpn implements the evpn related CLI commands
package evpn

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Copyright (c) 2024 Ericsson AB.

// Package network implements the network related CLI commands
package network
package evpn

import (
"fmt"
Expand Down
4 changes: 2 additions & 2 deletions cmd/network/evpn-vrf.go → cmd/network/evpn/evpn-vrf.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// Copyright (c) 2022-2023 Dell Inc, or its subsidiaries.
// Copyright (c) 2024 Ericsson AB.

// Package network implements the network related CLI commands
package network
// Package evpn implements the evpn network related CLI commands
package evpn

import (
"context"
Expand Down
67 changes: 67 additions & 0 deletions cmd/network/netintf/netintf.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (c) 2025 Dell Inc, or its subsidiaries.

// Package network implements the network related CLI commands
package netintf

import (
// "log"
// "time"

// "github.com/opiproject/godpu/cmd/common"
"github.com/spf13/cobra"
)


// ListNetInterfaces lists all Network Interface details from OPI server
func ListNetInterfaces() *cobra.Command {
var pageSize int32
var pageToken string

cmd := &cobra.Command{
Use: "list-net-interfaces",
Short: "List the network interfaces",
Run: func(c *cobra.Command, _ []string) {

Check failure on line 24 in cmd/network/netintf/netintf.go

View workflow job for this annotation

GitHub Actions / call / golangci

unused-parameter: parameter 'c' seems to be unused, consider removing or renaming it as _ (revive)
// TODO: Add processing for Network Interface List
// ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)

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

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

// evpnClient, err := network.NewLogicalBridge(addr, tlsFiles)
// if err != nil {
// log.Fatalf("could not create gRPC client: %v", err)
// }
// defer cancel()

// for {
// resp, err := evpnClient.ListLogicalBridges(ctx, pageSize, pageToken)
// if err != nil {
// log.Fatalf("Failed to get items: %v", err)
// }
// Process the server response
// log.Println("List Network Interfaces:")
// for _, lb := range resp.NetInterfaces {
// log.Println("Interface with: ")
// PrintLB(lb)
// }

// Check if there are more pages to retrieve
// if resp.NextPageToken == "" {
// No more pages, break the loop
// break
// }
// Update the page token for the next request
// pageToken = resp.NextPageToken
// }
},
}

cmd.Flags().Int32VarP(&pageSize, "pagesize", "s", 0, "Specify page size")
cmd.Flags().StringVarP(&pageToken, "pagetoken", "t", "", "Specify the token")

return cmd
}
105 changes: 105 additions & 0 deletions cmd/network/network.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (c) 2022-2023 Intel Corporation, or its subsidiaries.
// Copyright (c) 2024 Dell Inc, or its subsidiaries.

// Package network implements the network related CLI commands
package network

import (
"log"
"time"

"github.com/opiproject/godpu/cmd/common"
"github.com/opiproject/godpu/cmd/network/netintf"
"github.com/opiproject/godpu/cmd/network/evpn"
"github.com/spf13/cobra"
)

// NewNetworkCommand tests the Network functionality command
func NewNetworkCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "network",
Aliases: []string{"g"},
Short: "Tests DPU networking functionality",
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, _ []string) {
err := cmd.Help()
if err != nil {
log.Fatalf("[ERROR] %s", err.Error())
}
},
}

flags := cmd.PersistentFlags()
flags.Duration(common.TimeoutCmdLineArg, 10*time.Second, "timeout for a cmd")

cmd.AddCommand(NewEvpnCommand())
cmd.AddCommand(NewNetIntfCommand())

return cmd
}

// NewNetworkCommand tests the Network functionality command
func NewNetIntfCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "intf",
Aliases: []string{"g"},
Short: "Tests DPU network interface functionality",
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, _ []string) {
err := cmd.Help()
if err != nil {
log.Fatalf("[ERROR] %s", err.Error())
}
},
}

flags := cmd.PersistentFlags()
flags.Duration(common.TimeoutCmdLineArg, 10*time.Second, "timeout for a cmd")

cmd.AddCommand(netintf.ListNetInterfaces())

return cmd
}

// NewEvpnCommand tests the EVPN functionality command
func NewEvpnCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "evpn",
Aliases: []string{"g"},
Short: "Tests DPU evpn functionality",
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, _ []string) {
err := cmd.Help()
if err != nil {
log.Fatalf("[ERROR] %s", err.Error())
}
},
}
// Bridge cli's
cmd.AddCommand(evpn.CreateLogicalBridge())
cmd.AddCommand(evpn.DeleteLogicalBridge())
cmd.AddCommand(evpn.GetLogicalBridge())
cmd.AddCommand(evpn.ListLogicalBridges())
cmd.AddCommand(evpn.UpdateLogicalBridge())
// Port cli's
cmd.AddCommand(evpn.CreateBridgePort())
cmd.AddCommand(evpn.DeleteBridgePort())
cmd.AddCommand(evpn.GetBridgePort())
cmd.AddCommand(evpn.ListBridgePorts())
cmd.AddCommand(evpn.UpdateBridgePort())
// VRF cli's
cmd.AddCommand(evpn.CreateVRF())
cmd.AddCommand(evpn.DeleteVRF())
cmd.AddCommand(evpn.GetVRF())
cmd.AddCommand(evpn.ListVRFs())
cmd.AddCommand(evpn.UpdateVRF())
// SVI cli's
cmd.AddCommand(evpn.CreateSVI())
cmd.AddCommand(evpn.DeleteSVI())
cmd.AddCommand(evpn.GetSVI())
cmd.AddCommand(evpn.ListSVIs())
cmd.AddCommand(evpn.UpdateSVI())

return cmd
}
52 changes: 26 additions & 26 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
module github.com/opiproject/godpu

go 1.19
go 1.22.0

toolchain go1.23.4

require (
github.com/PraserX/ipconv v1.2.0
github.com/go-chi/chi v1.5.5
github.com/go-ping/ping v1.1.0
github.com/google/uuid v1.5.0
github.com/go-chi/chi/v5 v5.2.0
github.com/go-ping/ping v1.2.0
github.com/google/uuid v1.6.0
github.com/lithammer/fuzzysearch v1.1.8
github.com/onsi/ginkgo/v2 v2.14.0
github.com/onsi/gomega v1.30.0
github.com/opiproject/opi-api v0.0.0-20240304222410-5dba226aaa9e
github.com/spf13/cobra v1.8.0
github.com/stretchr/testify v1.8.4
go.einride.tech/aip v0.66.0
golang.org/x/net v0.20.0
golang.org/x/text v0.14.0
google.golang.org/grpc v1.60.1
google.golang.org/protobuf v1.32.0
github.com/onsi/ginkgo/v2 v2.22.2
github.com/onsi/gomega v1.36.2
github.com/opiproject/opi-api v0.0.0-20241209203403-595a3a1a838b
github.com/spf13/cobra v1.8.1
github.com/stretchr/testify v1.10.0
go.einride.tech/aip v0.68.1
golang.org/x/net v0.33.0
golang.org/x/text v0.21.0
google.golang.org/grpc v1.69.2
google.golang.org/protobuf v1.36.1
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-logr/logr v1.3.0 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 // indirect
github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.25.1 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/objx v0.5.0 // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/tools v0.16.1 // indirect
google.golang.org/genproto v0.0.0-20231012201019-e917dd12ba7a // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b // indirect
github.com/stretchr/objx v0.5.2 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/tools v0.28.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250102185135-69823020774d // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250102185135-69823020774d // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit cdd8ef2

Please sign in to comment.