VOL-3121 - Replaced usage of LogicalDevice.Ports with ListLogicalDevicePorts().
Also removed usage of LogicalDevice.Ports in tests.
Change-Id: Ic81ea409c8d60158ba7fecd6efec8481a96993c1
diff --git a/internal/pkg/mock/voltha_client_mock.go b/internal/pkg/mock/voltha_client_mock.go
index 9b583ae..d19a9ff 100644
--- a/internal/pkg/mock/voltha_client_mock.go
+++ b/internal/pkg/mock/voltha_client_mock.go
@@ -18,6 +18,7 @@
import (
"context"
+
. "github.com/golang/protobuf/ptypes/empty"
"github.com/opencord/voltha-protos/v3/go/common"
"github.com/opencord/voltha-protos/v3/go/omci"
@@ -29,7 +30,6 @@
type MockVolthaClient struct {
LogicalDeviceFlows openflow_13.Flows
LogicalPorts LogicalPorts
- LogicalDevice LogicalDevice
}
func (c MockVolthaClient) GetMembership(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*Membership, error) {
@@ -61,7 +61,7 @@
}
func (c MockVolthaClient) GetLogicalDevice(ctx context.Context, in *common.ID, opts ...grpc.CallOption) (*LogicalDevice, error) {
- return &c.LogicalDevice, nil
+ return &LogicalDevice{}, nil
}
func (c MockVolthaClient) ListLogicalDevicePorts(ctx context.Context, in *common.ID, opts ...grpc.CallOption) (*LogicalPorts, error) {
diff --git a/internal/pkg/openflow/stats.go b/internal/pkg/openflow/stats.go
index 9cd217e..0a0c8c8 100644
--- a/internal/pkg/openflow/stats.go
+++ b/internal/pkg/openflow/stats.go
@@ -19,12 +19,13 @@
import (
"context"
"encoding/json"
+ "net"
+
"github.com/opencord/goloxi"
ofp "github.com/opencord/goloxi/of13"
"github.com/opencord/voltha-lib-go/v3/pkg/log"
"github.com/opencord/voltha-protos/v3/go/common"
"github.com/opencord/voltha-protos/v3/go/openflow_13"
- "net"
)
func (ofc *OFConnection) handleStatsRequest(request ofp.IHeader, statType uint16) error {
@@ -619,13 +620,12 @@
return nil, NoVolthaConnectionError
}
- logicalDevice, err := volthaClient.GetLogicalDevice(context.Background(),
- &common.ID{Id: ofc.DeviceID})
+ ports, err := volthaClient.ListLogicalDevicePorts(context.Background(), &common.ID{Id: ofc.DeviceID})
if err != nil {
return nil, err
}
var entries []*ofp.PortDesc
- for _, port := range logicalDevice.GetPorts() {
+ for _, port := range ports.Items {
ofpPort := port.GetOfpPort()
var entry ofp.PortDesc
entry.SetPortNo(ofp.Port(ofpPort.GetPortNo()))
diff --git a/internal/pkg/openflow/stats_test.go b/internal/pkg/openflow/stats_test.go
index 1c82946..05273bf 100644
--- a/internal/pkg/openflow/stats_test.go
+++ b/internal/pkg/openflow/stats_test.go
@@ -18,6 +18,9 @@
import (
"fmt"
+ "math"
+ "testing"
+
"github.com/opencord/goloxi"
"github.com/opencord/goloxi/of13"
"github.com/opencord/ofagent-go/internal/pkg/holder"
@@ -25,8 +28,6 @@
"github.com/opencord/voltha-protos/v3/go/openflow_13"
"github.com/opencord/voltha-protos/v3/go/voltha"
"github.com/stretchr/testify/assert"
- "math"
- "testing"
)
var msgSizeLimit = 64000
@@ -167,14 +168,9 @@
Items: createRandomPorts(portsCount),
}
- logicalDevice := voltha.LogicalDevice{
- Ports: createRandomPorts(portsCount),
- }
-
volthaClient := mock.MockVolthaClient{
LogicalDeviceFlows: flows,
LogicalPorts: ports,
- LogicalDevice: logicalDevice,
}
volthaClientHolder := &holder.VolthaServiceClientHolder{}