diff --git a/Makefile b/Makefile index 980ea47..67b0268 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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 . diff --git a/cmd/network/evpn-bridge-port.go b/cmd/network/evpn-bridge-port.go index 7866123..1589224 100644 --- a/cmd/network/evpn-bridge-port.go +++ b/cmd/network/evpn-bridge-port.go @@ -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 @@ -11,6 +12,7 @@ import ( "time" "github.com/opiproject/godpu/network" + pb "github.com/opiproject/opi-api/network/evpn-gw/v1alpha1/gen/go" "github.com/spf13/cobra" ) @@ -38,8 +40,9 @@ func CreateBridgePort() *cobra.Command { 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())) }, } @@ -89,7 +92,7 @@ func DeleteBridgePort() *cobra.Command { 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") }, } @@ -122,8 +125,9 @@ func GetBridgePort() *cobra.Command { 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())) }, } @@ -159,8 +163,9 @@ func ListBridgePorts() *cobra.Command { } // 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 if there are more pages to retrieve @@ -203,8 +208,9 @@ func UpdateBridgePort() *cobra.Command { 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())) }, } cmd.Flags().StringVar(&name, "name", "", "name of the Bridge Port") diff --git a/cmd/network/evpn-logical-brige.go b/cmd/network/evpn-logical-brige.go index d76f32e..3aa0546 100644 --- a/cmd/network/evpn-logical-brige.go +++ b/cmd/network/evpn-logical-brige.go @@ -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" ) @@ -38,9 +42,9 @@ func CreateLogicalBridge() *cobra.Command { 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())) }, } cmd.Flags().StringVar(&addr, "addr", "localhost:50151", "address of OPI gRPC server") @@ -88,7 +92,7 @@ func DeleteLogicalBridge() *cobra.Command { 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) }, } @@ -123,9 +127,9 @@ func GetLogicalBridge() *cobra.Command { 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())) }, } @@ -161,8 +165,9 @@ func ListLogicalBridges() *cobra.Command { } // 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 if there are more pages to retrieve @@ -202,9 +207,9 @@ func UpdateLogicalBridge() *cobra.Command { 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())) }, } cmd.Flags().StringVar(&name, "name", "", "name of the logical bridge") diff --git a/cmd/network/evpn-svi.go b/cmd/network/evpn-svi.go index b7ffa65..e87149a 100644 --- a/cmd/network/evpn-svi.go +++ b/cmd/network/evpn-svi.go @@ -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 @@ -11,6 +12,7 @@ import ( "time" "github.com/opiproject/godpu/network" + pb "github.com/opiproject/opi-api/network/evpn-gw/v1alpha1/gen/go" "github.com/spf13/cobra" ) @@ -42,11 +44,12 @@ func CreateSVI() *cobra.Command { 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())) }, } + cmd.Flags().StringVar(&name, "name", "", "SVI Name") 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") @@ -129,9 +132,9 @@ func GetSVI() *cobra.Command { 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())) }, } @@ -167,9 +170,9 @@ func ListSVIs() *cobra.Command { } // 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 if there are more pages to retrieve @@ -212,9 +215,9 @@ func UpdateSVI() *cobra.Command { 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())) }, } cmd.Flags().StringVar(&addr, "addr", "localhost:50151", "address of OPI gRPC server") diff --git a/cmd/network/evpn-utils.go b/cmd/network/evpn-utils.go new file mode 100644 index 0000000..f56d21f --- /dev/null +++ b/cmd/network/evpn-utils.go @@ -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 +} + +// 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 +} diff --git a/cmd/network/evpn-vrf.go b/cmd/network/evpn-vrf.go index 98569e3..0d7f36f 100644 --- a/cmd/network/evpn-vrf.go +++ b/cmd/network/evpn-vrf.go @@ -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" ) @@ -37,8 +41,10 @@ func CreateVRF() *cobra.Command { 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())) }, } @@ -80,7 +86,7 @@ func DeleteVRF() *cobra.Command { 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) }, } @@ -112,8 +118,10 @@ func GetVRF() *cobra.Command { 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())) }, } @@ -149,8 +157,9 @@ func ListVRFs() *cobra.Command { } // 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 if there are more pages to retrieve @@ -192,7 +201,7 @@ func UpdateVRF() *cobra.Command { 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(), vrf.GetSpec().GetVni(), vrf.GetSpec().GetVtepIpPrefix(), vrf.GetSpec().GetLoopbackIpPrefix()) }, } diff --git a/go.mod b/go.mod index 278ab08..3de127c 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index e761345..ebaa5fd 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +github.com/PraserX/ipconv v1.2.0 h1:3bboP9EDfsuMF5C3qM25OmZA4+cCfk1Ahpx8zn5G2tM= +github.com/PraserX/ipconv v1.2.0/go.mod h1:aBiLM1bDAjp1++Q0Sp3IrGbPd49b74IUgoRWod6EtPY= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= @@ -42,6 +44,8 @@ github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8= github.com/onsi/gomega v1.30.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= github.com/opiproject/opi-api v0.0.0-20240118183513-e44db269fba4 h1:YBjvYWQQAbNIGsAXvB6FwL9Encr1nzo3/w+bB/tXltM= github.com/opiproject/opi-api v0.0.0-20240118183513-e44db269fba4/go.mod h1:92pv4ulvvPMuxCJ9ND3aYbmBfEMLx0VCjpkiR7ZTqPY= +github.com/opiproject/opi-api v0.0.0-20240304222410-5dba226aaa9e h1:jUa7DmVLjzLKg051y7rYyCD0NAbEHZQMimM1451D74I= +github.com/opiproject/opi-api v0.0.0-20240304222410-5dba226aaa9e/go.mod h1:92pv4ulvvPMuxCJ9ND3aYbmBfEMLx0VCjpkiR7ZTqPY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=