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

Build support for arm and use latest evpn opi-api #442

Closed
wants to merge 2 commits into from
Closed
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
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ MAKEFLAGS += --silent

go-compile: go-get go-build

go-compile-arm: go-get go-build-arm
tools:

go get golang.org/x/tools/cmd/goimports
Expand All @@ -27,6 +28,10 @@ go-build:
@echo " > Building binaries..."
@CGO_ENABLED=0 go build -o ${PROJECTNAME} .

go-build-arm:
@echo " > Building binaries..."
@CGO_ENABLED=0 env GOOS=linux GOARCH=arm64 go build -o ${PROJECTNAME} .

go-get:
@echo " > Checking if there are any missing dependencies..."
@CGO_ENABLED=0 go get .
Expand Down
24 changes: 15 additions & 9 deletions cmd/network/evpn-bridge-port.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (c) 2022-2023 Intel Corporation, or its subsidiaries.
// Copyright (c) 2022-2023 Dell Inc, or its subsidiaries.
// Copyright (c) 2024 Ericsson AB.

// Package network implements the network related CLI commands
package network
Expand All @@ -11,6 +12,7 @@
"time"

"github.com/opiproject/godpu/network"
pb "github.com/opiproject/opi-api/network/evpn-gw/v1alpha1/gen/go"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -38,8 +40,9 @@
if err != nil {
log.Fatalf("could not create Bridge Port: %v", err)
}
log.Printf("Created Bridge Port:\n status: %s\n type: %s\n name: %s\n bridges: %s\n mac: %s\n", bridgePort.GetStatus().GetOperStatus(), bridgePort.GetSpec().GetPtype(),
bridgePort.GetName(), bridgePort.GetSpec().GetLogicalBridges(), bridgePort.GetSpec().GetMacAddress())
log.Printf("Created Bridge Port:\nname: %s \nstatus: %s\nptype: %s\nmac: %s\nbridges: %s\nComponent Status:\n%s\n", bridgePort.GetName(),
pb.BPOperStatus_name[int32(bridgePort.GetStatus().GetOperStatus())], bridgePort.GetSpec().GetPtype(),
bridgePort.GetSpec().GetMacAddress(), bridgePort.GetSpec().GetLogicalBridges(), PrintComponents(bridgePort.GetStatus().GetComponents()))

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

View check run for this annotation

Codecov / codecov/patch

cmd/network/evpn-bridge-port.go#L43-L45

Added lines #L43 - L45 were not covered by tests
},
}

Expand Down Expand Up @@ -89,7 +92,7 @@
if err != nil {
log.Fatalf("DeleteBridgePort: Error occurred while deleting Bridge Port: %q", err)
}
log.Printf("Deleted BridgePort ")
log.Printf("Deleting BridgePort in process\n")

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L95 was not covered by tests
},
}

Expand Down Expand Up @@ -122,8 +125,9 @@
if err != nil {
log.Fatalf("GetBridgePort: Error occurred while creating Bridge Port: %q", err)
}
log.Printf("Bridge Port:\n status: %s\n type: %s\n name: %s\n bridges: %s\n mac: %s\n", bridgePort.GetStatus().GetOperStatus(), bridgePort.GetSpec().GetPtype(),
bridgePort.GetName(), bridgePort.GetSpec().GetLogicalBridges(), bridgePort.GetSpec().GetMacAddress())
log.Printf("Get Bridge Port:\nname: %s \nstatus: %s\nptype: %s\nmac: %s\nbridges: %s\nComponent Status:\n%s\n", bridgePort.GetName(),
pb.BPOperStatus_name[int32(bridgePort.GetStatus().GetOperStatus())], bridgePort.GetSpec().GetPtype(), bridgePort.GetSpec().GetMacAddress(),
bridgePort.GetSpec().GetLogicalBridges(), PrintComponents(bridgePort.GetStatus().GetComponents()))

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

View check run for this annotation

Codecov / codecov/patch

cmd/network/evpn-bridge-port.go#L128-L130

Added lines #L128 - L130 were not covered by tests
},
}

Expand Down Expand Up @@ -159,8 +163,9 @@
}
// Process the server response
for _, bridgePort := range resp.BridgePorts {
log.Printf("Bridge Port:\n status: %s\n type: %s\n name: %s\n bridges: %s\n mac: %s\n", bridgePort.GetStatus().GetOperStatus(), bridgePort.GetSpec().GetPtype(),
bridgePort.GetName(), bridgePort.GetSpec().GetLogicalBridges(), bridgePort.GetSpec().GetMacAddress())
log.Printf(" Bridge Port :\nname: %s \nstatus: %s\nptype: %s\nmac: %s\nbridges: %s\nComponent Status:\n%s\n", bridgePort.GetName(),
pb.BPOperStatus_name[int32(bridgePort.GetStatus().GetOperStatus())], bridgePort.GetSpec().GetPtype(), bridgePort.GetSpec().GetMacAddress(),
bridgePort.GetSpec().GetLogicalBridges(), PrintComponents(bridgePort.GetStatus().GetComponents()))

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

View check run for this annotation

Codecov / codecov/patch

cmd/network/evpn-bridge-port.go#L166-L168

Added lines #L166 - L168 were not covered by tests
}

// Check if there are more pages to retrieve
Expand Down Expand Up @@ -203,8 +208,9 @@
if err != nil {
log.Fatalf("UpdateBridgePort: Error occurred while creating Bridge Port: %q", err)
}
log.Printf("Bridge Port:\n status: %s\n type: %s\n name: %s\n bridges: %s\n mac: %s\n", bridgePort.GetStatus().GetOperStatus(), bridgePort.GetSpec().GetPtype(),
bridgePort.GetName(), bridgePort.GetSpec().GetLogicalBridges(), bridgePort.GetSpec().GetMacAddress())
log.Printf(" Bridge Port:\nname: %s \nstatus: %s\nptype: %s\nmac: %s\nbridges: %s\nComponent Status:\n%s\n", bridgePort.GetName(),
pb.BPOperStatus_name[int32(bridgePort.GetStatus().GetOperStatus())], bridgePort.GetSpec().GetPtype(), bridgePort.GetSpec().GetMacAddress(),
bridgePort.GetSpec().GetLogicalBridges(), PrintComponents(bridgePort.GetStatus().GetComponents()))

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

View check run for this annotation

Codecov / codecov/patch

cmd/network/evpn-bridge-port.go#L211-L213

Added lines #L211 - L213 were not covered by tests
},
}
cmd.Flags().StringVar(&name, "name", "", "name of the Bridge Port")
Expand Down
29 changes: 17 additions & 12 deletions cmd/network/evpn-logical-brige.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (c) 2022-2023 Intel Corporation, or its subsidiaries.
// Copyright (c) 2022-2023 Dell Inc, or its subsidiaries.
// Copyright (c) 2024 Ericsson AB.

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

import (
"context"
"fmt"
"log"
"time"

"github.com/PraserX/ipconv"
"github.com/opiproject/godpu/network"
pb "github.com/opiproject/opi-api/network/evpn-gw/v1alpha1/gen/go"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -38,9 +42,9 @@
if err != nil {
log.Fatalf("failed to create logical bridge: %v", err)
}

log.Printf(" Created Logical Bridge \n name: %s\n vlan: %d\n vni: %d\n status: %s\n VtepIpPrefix:%s", resp.GetName(), resp.GetSpec().GetVlanId(),
resp.GetSpec().GetVni(), resp.GetStatus(), resp.GetSpec().GetVtepIpPrefix())
Vteip := fmt.Sprintf("%+v/%v", ipconv.IntToIPv4(resp.GetSpec().GetVtepIpPrefix().GetAddr().GetV4Addr()), resp.GetSpec().GetVtepIpPrefix().GetLen())
log.Printf(" Created Logical Bridge \nname: %s\nstatus: %s\nvlan: %d\nvni: %d\nVtepIpPrefix:%s\nComponent Status:\n%s\n", resp.GetName(),
pb.LBOperStatus_name[int32(resp.GetStatus().GetOperStatus())], resp.GetSpec().GetVlanId(), resp.GetSpec().GetVni(), Vteip, PrintComponents(resp.GetStatus().GetComponents()))

Check warning on line 47 in cmd/network/evpn-logical-brige.go

View check run for this annotation

Codecov / codecov/patch

cmd/network/evpn-logical-brige.go#L45-L47

Added lines #L45 - L47 were not covered by tests
},
}
cmd.Flags().StringVar(&addr, "addr", "localhost:50151", "address of OPI gRPC server")
Expand Down Expand Up @@ -88,7 +92,7 @@
log.Fatalf("failed to delete logical bridge: %v", err)
}

log.Printf("Deleted Logical Bridge: %s\n", resp)
log.Printf("Deleting Logical Bridge in process: %s\n", resp)

Check warning on line 95 in cmd/network/evpn-logical-brige.go

View check run for this annotation

Codecov / codecov/patch

cmd/network/evpn-logical-brige.go#L95

Added line #L95 was not covered by tests
},
}

Expand Down Expand Up @@ -123,9 +127,9 @@
if err != nil {
log.Fatalf("failed to get logical bridge: %v", err)
}

log.Printf(" Created Logical Bridge \n name: %s\n vlan: %d\n vni: %d\n status: %s\n VtepIpPrefix:%s", resp.GetName(), resp.GetSpec().GetVlanId(),
resp.GetSpec().GetVni(), resp.GetStatus(), resp.GetSpec().GetVtepIpPrefix())
Vteip := fmt.Sprintf("%+v/%v", ipconv.IntToIPv4(resp.GetSpec().GetVtepIpPrefix().GetAddr().GetV4Addr()), resp.GetSpec().GetVtepIpPrefix().GetLen())
log.Printf(" Get Logical Bridge \nname: %s\nstatus: %s\nvlan: %d\nvni: %d\nVtepIpPrefix:%s\nComponent Status:\n%s\n", resp.GetName(),
pb.LBOperStatus_name[int32(resp.GetStatus().GetOperStatus())], resp.GetSpec().GetVlanId(), resp.GetSpec().GetVni(), Vteip, PrintComponents(resp.GetStatus().GetComponents()))

Check warning on line 132 in cmd/network/evpn-logical-brige.go

View check run for this annotation

Codecov / codecov/patch

cmd/network/evpn-logical-brige.go#L130-L132

Added lines #L130 - L132 were not covered by tests
},
}

Expand Down Expand Up @@ -161,8 +165,9 @@
}
// Process the server response
for _, item := range resp.LogicalBridges {
log.Printf(" Created Logical Bridge \n name: %s\n vlan: %d\n vni: %d\n status: %s\n VtepIpPrefix:%s", item.GetName(), item.GetSpec().GetVlanId(),
item.GetSpec().GetVni(), item.GetStatus(), item.GetSpec().GetVtepIpPrefix())
Vteip := fmt.Sprintf("%+v/%v", ipconv.IntToIPv4(item.GetSpec().GetVtepIpPrefix().GetAddr().GetV4Addr()), item.GetSpec().GetVtepIpPrefix().GetLen())
log.Printf("Logical Bridge with \nname: %s\nstatus: %s\nvlan: %d\nvni: %d\nVtepIpPrefix:%s\nComponent Status:\n%s\n", item.GetName(),
pb.LBOperStatus_name[int32(item.GetStatus().GetOperStatus())], item.GetSpec().GetVlanId(), item.GetSpec().GetVni(), Vteip, PrintComponents(item.GetStatus().GetComponents()))

Check warning on line 170 in cmd/network/evpn-logical-brige.go

View check run for this annotation

Codecov / codecov/patch

cmd/network/evpn-logical-brige.go#L168-L170

Added lines #L168 - L170 were not covered by tests
}

// Check if there are more pages to retrieve
Expand Down Expand Up @@ -202,9 +207,9 @@
if err != nil {
log.Fatalf("failed to update logical bridge: %v", err)
}

log.Printf(" Updated Logical Bridge \n name: %s\n vlan: %d\n vni: %d\n status: %s\n VtepIpPrefix:%s", resp.GetName(), resp.GetSpec().GetVlanId(),
resp.GetSpec().GetVni(), resp.GetStatus(), resp.GetSpec().GetVtepIpPrefix())
Vteip := fmt.Sprintf("%+v/%v", ipconv.IntToIPv4(resp.GetSpec().GetVtepIpPrefix().GetAddr().GetV4Addr()), resp.GetSpec().GetVtepIpPrefix().GetLen())
log.Printf(" Updated Logical Bridge with \nname: %s\nstatus: %s\nvlan: %d\nvni: %d\nVtepIpPrefix:%s\nComponent Status:\n%s\n", resp.GetName(),
pb.LBOperStatus_name[int32(resp.GetStatus().GetOperStatus())], resp.GetSpec().GetVlanId(), resp.GetSpec().GetVni(), Vteip, PrintComponents(resp.GetStatus().GetComponents()))

Check warning on line 212 in cmd/network/evpn-logical-brige.go

View check run for this annotation

Codecov / codecov/patch

cmd/network/evpn-logical-brige.go#L210-L212

Added lines #L210 - L212 were not covered by tests
},
}
cmd.Flags().StringVar(&name, "name", "", "name of the logical bridge")
Expand Down
27 changes: 15 additions & 12 deletions cmd/network/evpn-svi.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (c) 2022-2023 Intel Corporation, or its subsidiaries.
// Copyright (c) 2022-2023 Dell Inc, or its subsidiaries.
// Copyright (c) 2024 Ericsson AB.

// Package network implements the network related CLI commands
package network
Expand All @@ -11,6 +12,7 @@
"time"

"github.com/opiproject/godpu/network"
pb "github.com/opiproject/opi-api/network/evpn-gw/v1alpha1/gen/go"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -42,11 +44,12 @@
log.Fatalf("failed to create logical bridge: %v", err)
}

log.Printf("CreateSVI: Created SVI \n name: %s\n status: %d\n Vrf: %s\n LogicalBridge: %s\n MacAddress: %s\n EnableBgp: %t\n GwIPs: %s\nremoteAS: %d\n",
svi.GetName(), svi.GetStatus().GetOperStatus(), svi.GetSpec().GetVrf(), svi.GetSpec().GetLogicalBridge(), svi.GetSpec().GetMacAddress(),
svi.GetSpec().GetEnableBgp(), svi.GetSpec().GetGwIpPrefix(), svi.GetSpec().GetRemoteAs())
log.Printf("Created SVI \nname: %s\nstatus: %s\nVrf: %s\nLogicalBridge: %s\nMacAddress: %s\nEnableBgp: %t\nGwIPs: %s\nremoteAS: %d\nComponent Status:\n%s\n",
svi.GetName(), pb.SVIOperStatus_name[int32(svi.GetStatus().GetOperStatus())], svi.GetSpec().GetVrf(), svi.GetSpec().GetLogicalBridge(), svi.GetSpec().GetMacAddress(),
svi.GetSpec().GetEnableBgp(), PrintGWIPs(svi.GetSpec().GetGwIpPrefix()), svi.GetSpec().GetRemoteAs(), PrintComponents(svi.GetStatus().GetComponents()))

Check warning on line 49 in cmd/network/evpn-svi.go

View check run for this annotation

Codecov / codecov/patch

cmd/network/evpn-svi.go#L47-L49

Added lines #L47 - L49 were not covered by tests
},
}
cmd.Flags().StringVar(&name, "name", "", "SVI Name")

Check warning on line 52 in cmd/network/evpn-svi.go

View check run for this annotation

Codecov / codecov/patch

cmd/network/evpn-svi.go#L52

Added line #L52 was not covered by tests
cmd.Flags().StringVar(&vrf, "vrf", "", "Must be unique")
cmd.Flags().StringVar(&logicalBridge, "logicalBridge", "", "Pair of vni and vlan_id must be unique")
cmd.Flags().StringVar(&mac, "mac", "", "GW MAC address, random MAC assigned if not specified")
Expand Down Expand Up @@ -129,9 +132,9 @@
if err != nil {
log.Fatalf("GetSVI: Error occurred while creating Bridge Port: %q", err)
}
log.Printf("GetSVI: Created SVI \n name: %s\n status: %d\n Vrf: %s\n LogicalBridge: %s\n MacAddress: %s\n EnableBgp: %t\n GwIPs: %s\nremoteAS: %d\n",
svi.GetName(), svi.GetStatus().GetOperStatus(), svi.GetSpec().GetVrf(), svi.GetSpec().GetLogicalBridge(), svi.GetSpec().GetMacAddress(),
svi.GetSpec().GetEnableBgp(), svi.GetSpec().GetGwIpPrefix(), svi.GetSpec().GetRemoteAs())
log.Printf("Get SVI \nname: %s\nstatus: %s\nVrf: %s\nLogicalBridge: %s\nMacAddress: %s\nEnableBgp: %t\nGwIPs: %s\nremoteAS: %d\nComponent Status:\n%s\n",
svi.GetName(), pb.SVIOperStatus_name[int32(svi.GetStatus().GetOperStatus())], svi.GetSpec().GetVrf(), svi.GetSpec().GetLogicalBridge(), svi.GetSpec().GetMacAddress(),
svi.GetSpec().GetEnableBgp(), PrintGWIPs(svi.GetSpec().GetGwIpPrefix()), svi.GetSpec().GetRemoteAs(), PrintComponents(svi.GetStatus().GetComponents()))

Check warning on line 137 in cmd/network/evpn-svi.go

View check run for this annotation

Codecov / codecov/patch

cmd/network/evpn-svi.go#L135-L137

Added lines #L135 - L137 were not covered by tests
},
}

Expand Down Expand Up @@ -167,9 +170,9 @@
}
// Process the server response
for _, svi := range resp.Svis {
log.Printf("ListSVIs: SVI \n name: %s\n status: %d\n Vrf: %s\n LogicalBridge: %s\n MacAddress: %s\n EnableBgp: %t\n GwIPs: %s\nremoteAS: %d\n",
svi.GetName(), svi.GetStatus().GetOperStatus(), svi.GetSpec().GetVrf(), svi.GetSpec().GetLogicalBridge(), svi.GetSpec().GetMacAddress(),
svi.GetSpec().GetEnableBgp(), svi.GetSpec().GetGwIpPrefix(), svi.GetSpec().GetRemoteAs())
log.Printf("SVI with \nname: %s\nstatus: %s\nVrf: %s\nLogicalBridge: %s\nMacAddress: %s\nEnableBgp: %t\nGwIPs: %s\nremoteAS: %d\nComponent Status:\n%s\n",
svi.GetName(), pb.SVIOperStatus_name[int32(svi.GetStatus().GetOperStatus())], svi.GetSpec().GetVrf(), svi.GetSpec().GetLogicalBridge(), svi.GetSpec().GetMacAddress(),
svi.GetSpec().GetEnableBgp(), PrintGWIPs(svi.GetSpec().GetGwIpPrefix()), svi.GetSpec().GetRemoteAs(), PrintComponents(svi.GetStatus().GetComponents()))

Check warning on line 175 in cmd/network/evpn-svi.go

View check run for this annotation

Codecov / codecov/patch

cmd/network/evpn-svi.go#L173-L175

Added lines #L173 - L175 were not covered by tests
}

// Check if there are more pages to retrieve
Expand Down Expand Up @@ -212,9 +215,9 @@
if err != nil {
log.Fatalf("GetBridgePort: Error occurred while creating Bridge Port: %q", err)
}
log.Printf("UpdateSVI: SVI \n name: %s\n status: %d\n Vrf: %s\n LogicalBridge: %s\n MacAddress: %s\n EnableBgp: %t\n GwIPs: %s\nremoteAS: %d\n",
svi.GetName(), svi.GetStatus().GetOperStatus(), svi.GetSpec().GetVrf(), svi.GetSpec().GetLogicalBridge(), svi.GetSpec().GetMacAddress(),
svi.GetSpec().GetEnableBgp(), svi.GetSpec().GetGwIpPrefix(), svi.GetSpec().GetRemoteAs())
log.Printf("Updated SVI with \nname: %s\nstatus: %s\nVrf: %s\nLogicalBridge: %s\nMacAddress: %s\nEnableBgp: %t\nGwIPs: %s\nremoteAS: %d\nComponent Status:\n%s\n",
svi.GetName(), pb.SVIOperStatus_name[int32(svi.GetStatus().GetOperStatus())], svi.GetSpec().GetVrf(), svi.GetSpec().GetLogicalBridge(), svi.GetSpec().GetMacAddress(),
svi.GetSpec().GetEnableBgp(), PrintGWIPs(svi.GetSpec().GetGwIpPrefix()), svi.GetSpec().GetRemoteAs(), PrintComponents(svi.GetStatus().GetComponents()))

Check warning on line 220 in cmd/network/evpn-svi.go

View check run for this annotation

Codecov / codecov/patch

cmd/network/evpn-svi.go#L218-L220

Added lines #L218 - L220 were not covered by tests
},
}
cmd.Flags().StringVar(&addr, "addr", "localhost:50151", "address of OPI gRPC server")
Expand Down
35 changes: 35 additions & 0 deletions cmd/network/evpn-utils.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (c) 2022-2023 Intel Corporation, or its subsidiaries.
// Copyright (c) 2022-2023 Dell Inc, or its subsidiaries.
// Copyright (c) 2024 Ericsson AB.

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

import (
"fmt"

"github.com/PraserX/ipconv"
pb "github.com/opiproject/opi-api/network/evpn-gw/v1alpha1/gen/go"
pc "github.com/opiproject/opi-api/network/opinetcommon/v1alpha1/gen/go"
)

// PrintComponents prints the components with their details
func PrintComponents(comp []*pb.Component) string {
var status string
for i := 0; i < len(comp); i++ {
str := fmt.Sprintf(" %+v\n", comp[i])
status += str
}
return status

Check warning on line 24 in cmd/network/evpn-utils.go

View check run for this annotation

Codecov / codecov/patch

cmd/network/evpn-utils.go#L18-L24

Added lines #L18 - L24 were not covered by tests
}

// PrintGWIPs prints the gw ips
func PrintGWIPs(comp []*pc.IPPrefix) string {
var status string
for i := 0; i < len(comp); i++ {
str := fmt.Sprintf("%+v/%v ", ipconv.IntToIPv4(comp[i].GetAddr().GetV4Addr()), comp[i].GetLen())
status += str
}
return status

Check warning on line 34 in cmd/network/evpn-utils.go

View check run for this annotation

Codecov / codecov/patch

cmd/network/evpn-utils.go#L28-L34

Added lines #L28 - L34 were not covered by tests
}
25 changes: 17 additions & 8 deletions cmd/network/evpn-vrf.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (c) 2022-2023 Intel Corporation, or its subsidiaries.
// Copyright (c) 2022-2023 Dell Inc, or its subsidiaries.
// Copyright (c) 2024 Ericsson AB.

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

import (
"context"
"fmt"
"log"
"time"

"github.com/PraserX/ipconv"
"github.com/opiproject/godpu/network"
pb "github.com/opiproject/opi-api/network/evpn-gw/v1alpha1/gen/go"
"github.com/spf13/cobra"
)

Expand All @@ -37,8 +41,10 @@
if err != nil {
log.Fatalf("failed to create vrf: %v", err)
}
log.Printf("Created VRF with \n name: %s\n operation status: %d\n vni : %d\n vtep ip : %s\n loopback ip: %s\n", vrf.GetName(), vrf.GetStatus().GetOperStatus(),
vrf.GetSpec().GetVni(), vrf.GetSpec().GetVtepIpPrefix(), vrf.GetSpec().GetLoopbackIpPrefix())
Vteip := fmt.Sprintf("%+v/%v", ipconv.IntToIPv4(vrf.GetSpec().GetVtepIpPrefix().GetAddr().GetV4Addr()), vrf.GetSpec().GetVtepIpPrefix().GetLen())
Loopback := fmt.Sprintf("%+v/%+v", ipconv.IntToIPv4(vrf.GetSpec().GetLoopbackIpPrefix().GetAddr().GetV4Addr()), vrf.GetSpec().GetLoopbackIpPrefix().GetLen())
log.Printf("Created VRF with \nname: %s\noperation status: %s\nvni : %d\nvtep ip : %s\nloopback ip : %s\nComponent Status:\n%s\n",
vrf.GetName(), pb.VRFOperStatus_name[int32(vrf.GetStatus().GetOperStatus())], vrf.GetSpec().GetVni(), Vteip, Loopback, PrintComponents(vrf.GetStatus().GetComponents()))

Check warning on line 47 in cmd/network/evpn-vrf.go

View check run for this annotation

Codecov / codecov/patch

cmd/network/evpn-vrf.go#L44-L47

Added lines #L44 - L47 were not covered by tests
},
}

Expand Down Expand Up @@ -80,7 +86,7 @@
if err != nil {
log.Fatalf("DeleteVRF: Error occurred while creating Bridge Port: %q", err)
}
log.Printf("Deleted VRF with VPort ID: %s\n", name)
log.Printf("Deleting VRF in process with VPort ID: %s\n", name)

Check warning on line 89 in cmd/network/evpn-vrf.go

View check run for this annotation

Codecov / codecov/patch

cmd/network/evpn-vrf.go#L89

Added line #L89 was not covered by tests
},
}

Expand Down Expand Up @@ -112,8 +118,10 @@
if err != nil {
log.Fatalf("DeleteVRF: Error occurred while creating Bridge Port: %q", err)
}
log.Printf("VRF with \n name: %s\n operation status: %d\n vni : %d\n vtep ip : %s\n loopback ip: %s\n", vrf.GetName(), vrf.GetStatus().GetOperStatus(),
vrf.GetSpec().GetVni(), vrf.GetSpec().GetVtepIpPrefix(), vrf.GetSpec().GetLoopbackIpPrefix())
Vteip := fmt.Sprintf("%+v/%v", ipconv.IntToIPv4(vrf.GetSpec().GetVtepIpPrefix().GetAddr().GetV4Addr()), vrf.GetSpec().GetVtepIpPrefix().GetLen())
Loopback := fmt.Sprintf("%+v/%+v", ipconv.IntToIPv4(vrf.GetSpec().GetLoopbackIpPrefix().GetAddr().GetV4Addr()), vrf.GetSpec().GetLoopbackIpPrefix().GetLen())

log.Printf("VRF with \nname: %s\noperation status: %s\nvni : %d\nvtep ip : %s\nloopback ip: %s\nComponent Status:\n%s\n", vrf.GetName(), pb.VRFOperStatus_name[int32(vrf.GetStatus().GetOperStatus())], vrf.GetSpec().GetVni(), Vteip, Loopback, PrintComponents(vrf.GetStatus().GetComponents()))

Check warning on line 124 in cmd/network/evpn-vrf.go

View check run for this annotation

Codecov / codecov/patch

cmd/network/evpn-vrf.go#L121-L124

Added lines #L121 - L124 were not covered by tests
},
}

Expand Down Expand Up @@ -149,8 +157,9 @@
}
// Process the server response
for _, vrf := range resp.Vrfs {
log.Printf("VRF with \n name: %s\n operation status: %d\n vni : %d\n vtep ip : %s\n loopback ip: %s\n", vrf.GetName(), vrf.GetStatus().GetOperStatus(),
vrf.GetSpec().GetVni(), vrf.GetSpec().GetVtepIpPrefix(), vrf.GetSpec().GetLoopbackIpPrefix())
Vteip := fmt.Sprintf("%+v/%v", ipconv.IntToIPv4(vrf.GetSpec().GetVtepIpPrefix().GetAddr().GetV4Addr()), vrf.GetSpec().GetVtepIpPrefix().GetLen())
Loopback := fmt.Sprintf("%+v/%+v", ipconv.IntToIPv4(vrf.GetSpec().GetLoopbackIpPrefix().GetAddr().GetV4Addr()), vrf.GetSpec().GetLoopbackIpPrefix().GetLen())
log.Printf("VRF with \nname: %s\noperation status: %d\nvni : %d\nvtep ip : %s\nloopback ip: %s\n", vrf.GetName(), vrf.GetStatus().GetOperStatus(), vrf.GetSpec().GetVni(), Vteip, Loopback)

Check warning on line 162 in cmd/network/evpn-vrf.go

View check run for this annotation

Codecov / codecov/patch

cmd/network/evpn-vrf.go#L160-L162

Added lines #L160 - L162 were not covered by tests
}

// Check if there are more pages to retrieve
Expand Down Expand Up @@ -192,7 +201,7 @@
if err != nil {
log.Fatalf("GetBridgePort: Error occurred while creating Bridge Port: %q", err)
}
log.Printf("Updated VRF with \n name: %s\n operation status: %d\n vni : %d\n vtep ip : %s\n loopback ip: %s\n", vrf.GetName(), vrf.GetStatus().GetOperStatus(),
log.Printf("Updated VRF with \nname: %s\noperation status: %d\nvni : %d\nvtep ip : %s\nloopback ip: %s\n", vrf.GetName(), vrf.GetStatus().GetOperStatus(),

Check warning on line 204 in cmd/network/evpn-vrf.go

View check run for this annotation

Codecov / codecov/patch

cmd/network/evpn-vrf.go#L204

Added line #L204 was not covered by tests
vrf.GetSpec().GetVni(), vrf.GetSpec().GetVtepIpPrefix(), vrf.GetSpec().GetLoopbackIpPrefix())
},
}
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ module github.com/opiproject/godpu
go 1.19

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/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-20240118183513-e44db269fba4
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
Expand Down
Loading
Loading