diff --git a/nwgate/Makefile b/nwgate/Makefile new file mode 100644 index 0000000..a433201 --- /dev/null +++ b/nwgate/Makefile @@ -0,0 +1,36 @@ +# Copyright (c) 2024 Widgets. + +ROOT_DIR='.' +PROJECTNAME=$(shell basename "$(PWD)") + +compile: get build + +build: + @echo " > Building binaries..." + go build -o ${PROJECTNAME} ./cmd/... + +get: + @echo " > Checking if there are any missing dependencies..." + go get -u ./cmd + go mod tidy + +tools: + go get golang.org/x/tools/cmd/goimports + go get github.com/kisielk/errcheck + go get github.com/axw/gocov/gocov + go get github.com/matm/gocov-html + go get github.com/tools/godep + go get github.com/mitchellh/gox + go get github.com/golang/lint/golint + +vet: + @CGO_ENABLED=0 go vet -v ./... + +lint: + golint ./... + +imports: + goimports -l -w . + +fmt: + @CGO_ENABLED=0 go fmt ./... diff --git a/nwgate/cmd/main.go b/nwgate/cmd/main.go index f080a58..58f3359 100644 --- a/nwgate/cmd/main.go +++ b/nwgate/cmd/main.go @@ -36,7 +36,7 @@ func main() { inv.RegisterInventoryServiceServer(grpcServer, opiServ) reflection.Register(grpcServer) - //Initialize the Network Device Information + // Initialize the Network Device Information dpudev.InitNetworkData() log.Printf("Server listening at %v", lis.Addr()) diff --git a/nwgate/go.mod b/nwgate/go.mod index 2d8a308..4f044b8 100644 --- a/nwgate/go.mod +++ b/nwgate/go.mod @@ -5,7 +5,7 @@ go 1.20 require ( github.com/jaypipes/ghw v0.12.0 github.com/opiproject/opi-api v0.0.0-20240304222410-5dba226aaa9e - github.com/sandersms/Protos v0.0.0-20240313190718-cd89a7361a93 + github.com/sandersms/Protos v0.0.0-20240313191539-e9516759f329 github.com/vishvananda/netlink v1.1.0 google.golang.org/grpc v1.62.1 ) @@ -22,9 +22,11 @@ require ( github.com/pkg/errors v0.9.1 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect github.com/vishvananda/netns v0.0.4 // indirect + golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect golang.org/x/net v0.22.0 // indirect golang.org/x/sys v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect + golang.org/x/tools v0.19.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240311173647-c811ad7063a7 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240311173647-c811ad7063a7 // indirect google.golang.org/protobuf v1.33.0 // indirect diff --git a/nwgate/go.sum b/nwgate/go.sum index d025e1d..ac5a53a 100644 --- a/nwgate/go.sum +++ b/nwgate/go.sum @@ -27,22 +27,37 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= -github.com/sandersms/Protos v0.0.0-20240313190718-cd89a7361a93 h1:joDgj5CW7N7YSPJbAkj08SDOZbCO63hKZe7HY8Ddhic= -github.com/sandersms/Protos v0.0.0-20240313190718-cd89a7361a93/go.mod h1:4ZjAC2TCW1y+u1C2D+TN5mn5DgMIk7uPtusn7LlOwTk= +github.com/sandersms/Protos v0.0.0-20240313191539-e9516759f329 h1:D51DeuOzzc3qWuJ9XvpNxt/+hp/zsm+3jLwxe7MqYe8= +github.com/sandersms/Protos v0.0.0-20240313191539-e9516759f329/go.mod h1:4ZjAC2TCW1y+u1C2D+TN5mn5DgMIk7uPtusn7LlOwTk= github.com/vishvananda/netlink v1.1.0 h1:1iyaYNBLmP6L0220aDnYQpo1QEV4t4hJ+xEEhhJH8j0= github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE= github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU= github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1YX8= github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug= +golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.19.0 h1:tfGCXNR1OsFG+sVdLAitlpjAvD/I6dHDKnYrpEZUHkw= +golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/genproto/googleapis/api v0.0.0-20240311173647-c811ad7063a7 h1:oqta3O3AnlWbmIE3bFnWbu4bRxZjfbWCp0cKSuZh01E= google.golang.org/genproto/googleapis/api v0.0.0-20240311173647-c811ad7063a7/go.mod h1:VQW3tUculP/D4B+xVCo+VgSq8As6wA9ZjHl//pmk+6s= google.golang.org/genproto/googleapis/rpc v0.0.0-20240311173647-c811ad7063a7 h1:8EeVk1VKMD+GD/neyEHGmz7pFblqPjHoi+PGQIlLx2s= diff --git a/nwgate/pkg/dpudev/Interface.go b/nwgate/pkg/dpudev/Interface.go index 5c4c123..a4ee51c 100644 --- a/nwgate/pkg/dpudev/Interface.go +++ b/nwgate/pkg/dpudev/Interface.go @@ -13,16 +13,16 @@ import ( ipb "github.com/sandersms/Protos/Experiment/network/opencfg/v1alpha1/gen/go" ) -// Initialize the network device information +// InitNetworkData initialize the network device information func InitNetworkData() { // Get the list of links on the device - n_ifs, err := netlink.LinkList() + nifs, err := netlink.LinkList() if err != nil { panic(err) } // Output the parameters retrieved for the list of links - for _, intf := range n_ifs { + for _, intf := range nifs { fmt.Println("Name", intf.Attrs().Name) } } diff --git a/nwgate/pkg/dpudev/dpudev.go b/nwgate/pkg/dpudev/dpudev.go index 0d01408..0075e6b 100644 --- a/nwgate/pkg/dpudev/dpudev.go +++ b/nwgate/pkg/dpudev/dpudev.go @@ -15,7 +15,7 @@ type Server struct { Dpus map[string]*pb.Inventory } -// Create initialized instance of the Dpu Device server +// NewServer creates the initialized instance of the Dpu Device server func NewServer() *Server { fmt.Println("Creating DPU Device Server") return &Server{