Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add network interface capability #457

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2022-2023 Dell Inc, or its subsidiaries.
FROM docker.io/library/golang:1.21.5-alpine3.17 as builder
FROM docker.io/library/golang:1.23.4-alpine3.21 as builder

Check warning

Code scanning / Scorecard

Pinned-Dependencies Medium

score is 0: containerImage not pinned by hash
Click Remediation section below to solve this issue

WORKDIR /app

Expand All @@ -15,7 +15,7 @@
COPY . .
RUN go build -v -o /dpu .

FROM alpine:3.19
FROM alpine:3.21

Check warning

Code scanning / Scorecard

Pinned-Dependencies Medium

score is 0: containerImage not pinned by hash
Remediation tip: pin your Docker image by updating alpine:3.21 to alpine:3.21@sha256:56fa17d2a7e7f168a043a2712e63aed1f8543aeafdcee47c58dcffe38ed51099
Click Remediation section below for further remediation help

WORKDIR /

Expand Down
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) {
// 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
}
10 changes: 5 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) 2022-2023 Dell Inc, or its subsidiaries.
# Copyright (C) 2023 Intel Corporation
---
version: "3.7"
# version: "3.7" - version is obsolete and can be removed/commented out
services:
spdk:
image: docker.io/opiproject/spdk:v24.01
Expand Down Expand Up @@ -96,7 +96,7 @@ services:
sleep infinity'

redis:
image: redis:7.2.3-alpine3.18
image: redis:7.2.7-alpine3.21
networks:
- opi
healthcheck:
Expand Down Expand Up @@ -161,7 +161,7 @@ services:
depends_on:
opi-evpn-server:
condition: service_healthy
command: evpn create-vrf --name blue --vni 100 --vtep 10.0.0.100/24 --loopback 10.100.0.1/24 --addr opi-evpn-server:50151
command: network evpn create-vrf --name blue --vni 100 --vtep 10.0.0.100/24 --loopback 10.100.0.1/24 --addr opi-evpn-server:50151

opi-smbios-test:
build:
Expand Down Expand Up @@ -198,7 +198,7 @@ services:
/dpu storage delete backend nvme controller --addr=opi-spdk-server:50051 --name "$$nvmf0" && \

opi-test:
image: docker.io/library/alpine:3.19
image: docker.io/library/alpine:3.21
networks:
- opi
depends_on:
Expand All @@ -209,7 +209,7 @@ services:
opi-storage-test:
condition: service_completed_successfully
command: |
sh -c 'exit 0'
sh -c 'sleep 60 && exit 0'

networks:
opi:
Loading
Loading