[VOL-5567] Upgrade protos and remove deprecated dependencies
Change-Id: I27bd979c5a3bfa10fad5aadecaed6aa34c4ddb74
Signed-off-by: bseeniva <balaji.seenivasan@radisys.com>
diff --git a/rw_core/core/adapter/endpoint_manager.go b/rw_core/core/adapter/endpoint_manager.go
index f209f93..91e1d17 100644
--- a/rw_core/core/adapter/endpoint_manager.go
+++ b/rw_core/core/adapter/endpoint_manager.go
@@ -23,12 +23,12 @@
"github.com/buraksezer/consistent"
"github.com/cespare/xxhash"
- "github.com/golang/protobuf/proto"
"github.com/opencord/voltha-lib-go/v7/pkg/db"
"github.com/opencord/voltha-lib-go/v7/pkg/log"
"github.com/opencord/voltha-protos/v5/go/voltha"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
+ "google.golang.org/protobuf/proto"
)
const (
diff --git a/rw_core/core/adapter/endpoint_manager_test.go b/rw_core/core/adapter/endpoint_manager_test.go
index 5fc6023..0d2eac2 100644
--- a/rw_core/core/adapter/endpoint_manager_test.go
+++ b/rw_core/core/adapter/endpoint_manager_test.go
@@ -23,7 +23,6 @@
"testing"
"time"
- "github.com/golang/protobuf/proto"
"github.com/google/uuid"
"github.com/opencord/voltha-lib-go/v7/pkg/db"
"github.com/opencord/voltha-lib-go/v7/pkg/log"
@@ -33,6 +32,7 @@
"github.com/stretchr/testify/assert"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
+ "google.golang.org/protobuf/proto"
)
type EPTest struct {
diff --git a/rw_core/core/adapter/manager.go b/rw_core/core/adapter/manager.go
index 6ff216d..d81fff9 100644
--- a/rw_core/core/adapter/manager.go
+++ b/rw_core/core/adapter/manager.go
@@ -29,14 +29,14 @@
"github.com/opencord/voltha-protos/v5/go/common"
"github.com/opencord/voltha-protos/v5/go/core_adapter"
- "github.com/gogo/protobuf/proto"
- "github.com/golang/protobuf/ptypes/empty"
"github.com/opencord/voltha-go/db/model"
"github.com/opencord/voltha-lib-go/v7/pkg/log"
"github.com/opencord/voltha-lib-go/v7/pkg/probe"
"github.com/opencord/voltha-protos/v5/go/voltha"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
+ "google.golang.org/protobuf/proto"
+ "google.golang.org/protobuf/types/known/emptypb"
)
// Manager represents adapter manager attributes
@@ -333,7 +333,7 @@
return nil
}
-func (aMgr *Manager) RegisterAdapter(ctx context.Context, registration *core_adapter.AdapterRegistration) (*empty.Empty, error) {
+func (aMgr *Manager) RegisterAdapter(ctx context.Context, registration *core_adapter.AdapterRegistration) (*emptypb.Empty, error) {
adapter := registration.Adapter
deviceTypes := registration.DTypes
logger.Infow(ctx, "RegisterAdapter", log.Fields{"adapter": adapter, "deviceTypes": deviceTypes.Items})
@@ -375,7 +375,7 @@
logger.Errorw(ctx, "unable-to-restart-adapter", log.Fields{"error": err})
}
- return &empty.Empty{}, nil
+ return &emptypb.Empty{}, nil
}
// Save the adapter and the device types
if err := aMgr.addAdapter(ctx, adapter, true); err != nil {
@@ -406,7 +406,7 @@
logger.Fatalw(ctx, "adapter-absent", log.Fields{"error": err, "adapter": adapter.Id})
}
- return &empty.Empty{}, nil
+ return &emptypb.Empty{}, nil
}
func (aMgr *Manager) StartAdapterWithEndPoint(ctx context.Context, endpoint string) error {
@@ -452,7 +452,7 @@
}
// ListDeviceTypes returns all the device types known to the system
-func (aMgr *Manager) ListDeviceTypes(ctx context.Context, _ *empty.Empty) (*voltha.DeviceTypes, error) {
+func (aMgr *Manager) ListDeviceTypes(ctx context.Context, _ *emptypb.Empty) (*voltha.DeviceTypes, error) {
logger.Debug(ctx, "ListDeviceTypes")
aMgr.lockDeviceTypesMap.Lock()
defer aMgr.lockDeviceTypesMap.Unlock()
@@ -478,7 +478,7 @@
}
// ListAdapters returns the contents of all adapters known to the system
-func (aMgr *Manager) ListAdapters(ctx context.Context, _ *empty.Empty) (*voltha.Adapters, error) {
+func (aMgr *Manager) ListAdapters(ctx context.Context, _ *emptypb.Empty) (*voltha.Adapters, error) {
logger.Debug(ctx, "Listing adapters")
result := &voltha.Adapters{Items: []*voltha.Adapter{}}
aMgr.lockAdapterAgentsMap.RLock()
diff --git a/rw_core/core/api/delegations.go b/rw_core/core/api/delegations.go
new file mode 100644
index 0000000..e732c17
--- /dev/null
+++ b/rw_core/core/api/delegations.go
@@ -0,0 +1,373 @@
+/*
+ * Copyright 2018-2023 Open Networking Foundation (ONF) and the ONF Contributors
+ * Licensed under the Apache License, Version 2.0 (the "License")
+ */
+
+package api
+
+//go:generate go run generate_delegations.go
+
+// This file contains delegation methods to resolve ambiguities between
+// embedded UnimplementedVolthaServiceServer/UnimplementedCoreServiceServer
+// and the device.Manager that has the actual implementations.
+//
+// When a method exists in both the Unimplemented stub and the Manager,
+// Go cannot determine which one to use, so we explicitly delegate to Manager.
+//
+// To regenerate this file after proto updates, run: go generate ./rw_core/core/api
+
+import (
+ "context"
+
+ "github.com/opencord/voltha-protos/v5/go/common"
+ ca "github.com/opencord/voltha-protos/v5/go/core_adapter"
+ "github.com/opencord/voltha-protos/v5/go/core_service"
+ "github.com/opencord/voltha-protos/v5/go/extension"
+ "github.com/opencord/voltha-protos/v5/go/omci"
+ "github.com/opencord/voltha-protos/v5/go/openflow_13"
+ voip_system_profile "github.com/opencord/voltha-protos/v5/go/voip_system_profile"
+ voip_user_profile "github.com/opencord/voltha-protos/v5/go/voip_user_profile"
+ "github.com/opencord/voltha-protos/v5/go/voltha"
+ "google.golang.org/protobuf/types/known/emptypb"
+)
+
+// All methods below delegate to handler.Manager, handler.LogicalManager, or handler.adapterManager
+// to resolve ambiguity with embedded UnimplementedVolthaServiceServer/UnimplementedCoreServiceServer
+
+func (handler *APIHandler) AbortImageUpgradeToDevice(ctx context.Context, request *voltha.DeviceImageRequest) (*voltha.DeviceImageResponse, error) {
+ return handler.Manager.AbortImageUpgradeToDevice(ctx, request)
+}
+
+func (handler *APIHandler) ActivateImage(ctx context.Context, request *voltha.DeviceImageRequest) (*voltha.DeviceImageResponse, error) {
+ return handler.Manager.ActivateImage(ctx, request)
+}
+
+func (handler *APIHandler) ActivateImageUpdate(ctx context.Context, img *voltha.ImageDownload) (*common.OperationResp, error) {
+ return handler.Manager.ActivateImageUpdate(ctx, img)
+}
+
+func (handler *APIHandler) CancelImageDownload(ctx context.Context, img *voltha.ImageDownload) (*common.OperationResp, error) {
+ return handler.Manager.CancelImageDownload(ctx, img)
+}
+
+func (handler *APIHandler) ChildDeviceDetected(ctx context.Context, dd *ca.DeviceDiscovery) (*voltha.Device, error) {
+ return handler.Manager.ChildDeviceDetected(ctx, dd)
+}
+
+func (handler *APIHandler) ChildDevicesDetected(ctx context.Context, parentDeviceID *common.ID) (*emptypb.Empty, error) {
+ return handler.Manager.ChildDevicesDetected(ctx, parentDeviceID)
+}
+
+func (handler *APIHandler) ChildDevicesLost(ctx context.Context, parentID *common.ID) (*emptypb.Empty, error) {
+ return handler.Manager.ChildDevicesLost(ctx, parentID)
+}
+
+func (handler *APIHandler) ChildrenStateUpdate(ctx context.Context, ds *ca.DeviceStateFilter) (*emptypb.Empty, error) {
+ return handler.Manager.ChildrenStateUpdate(ctx, ds)
+}
+
+func (handler *APIHandler) CommitImage(ctx context.Context, request *voltha.DeviceImageRequest) (*voltha.DeviceImageResponse, error) {
+ return handler.Manager.CommitImage(ctx, request)
+}
+
+func (handler *APIHandler) CreateDevice(ctx context.Context, device *voltha.Device) (*voltha.Device, error) {
+ return handler.Manager.CreateDevice(ctx, device)
+}
+
+func (handler *APIHandler) DeleteAllPorts(ctx context.Context, deviceID *common.ID) (*emptypb.Empty, error) {
+ return handler.Manager.DeleteAllPorts(ctx, deviceID)
+}
+
+func (handler *APIHandler) DeleteDevice(ctx context.Context, id *voltha.ID) (*emptypb.Empty, error) {
+ return handler.Manager.DeleteDevice(ctx, id)
+}
+
+func (handler *APIHandler) DeleteVoipSystemProfile(ctx context.Context, key *common.Key) (*emptypb.Empty, error) {
+ return handler.Manager.DeleteVoipSystemProfile(ctx, key)
+}
+
+func (handler *APIHandler) DeleteVoipUserProfile(ctx context.Context, key *common.Key) (*emptypb.Empty, error) {
+ return handler.Manager.DeleteVoipUserProfile(ctx, key)
+}
+
+func (handler *APIHandler) DevicePMConfigUpdate(ctx context.Context, pc *voltha.PmConfigs) (*emptypb.Empty, error) {
+ return handler.Manager.DevicePMConfigUpdate(ctx, pc)
+}
+
+func (handler *APIHandler) DeviceReasonUpdate(ctx context.Context, dr *ca.DeviceReason) (*emptypb.Empty, error) {
+ return handler.Manager.DeviceReasonUpdate(ctx, dr)
+}
+
+func (handler *APIHandler) DeviceStateUpdate(ctx context.Context, ds *ca.DeviceStateFilter) (*emptypb.Empty, error) {
+ return handler.Manager.DeviceStateUpdate(ctx, ds)
+}
+
+func (handler *APIHandler) DeviceUpdate(ctx context.Context, device *voltha.Device) (*emptypb.Empty, error) {
+ return handler.Manager.DeviceUpdate(ctx, device)
+}
+
+func (handler *APIHandler) DisableDevice(ctx context.Context, id *voltha.ID) (*emptypb.Empty, error) {
+ return handler.Manager.DisableDevice(ctx, id)
+}
+
+func (handler *APIHandler) DisableOnuDevice(ctx context.Context, id *voltha.ID) (*emptypb.Empty, error) {
+ return handler.Manager.DisableOnuDevice(ctx, id)
+}
+
+func (handler *APIHandler) DisableOnuSerialNumber(ctx context.Context, device *voltha.OnuSerialNumberOnOLTPon) (*emptypb.Empty, error) {
+ return handler.Manager.DisableOnuSerialNumber(ctx, device)
+}
+
+func (handler *APIHandler) DisablePort(ctx context.Context, port *voltha.Port) (*emptypb.Empty, error) {
+ return handler.Manager.DisablePort(ctx, port)
+}
+
+func (handler *APIHandler) DownloadImage(ctx context.Context, img *voltha.ImageDownload) (*common.OperationResp, error) {
+ return handler.Manager.DownloadImage(ctx, img)
+}
+
+func (handler *APIHandler) DownloadImageToDevice(ctx context.Context, request *voltha.DeviceImageDownloadRequest) (*voltha.DeviceImageResponse, error) {
+ return handler.Manager.DownloadImageToDevice(ctx, request)
+}
+
+func (handler *APIHandler) EnableDevice(ctx context.Context, id *voltha.ID) (*emptypb.Empty, error) {
+ return handler.Manager.EnableDevice(ctx, id)
+}
+
+func (handler *APIHandler) EnableOnuDevice(ctx context.Context, id *voltha.ID) (*emptypb.Empty, error) {
+ return handler.Manager.EnableOnuDevice(ctx, id)
+}
+
+func (handler *APIHandler) EnableOnuSerialNumber(ctx context.Context, device *voltha.OnuSerialNumberOnOLTPon) (*emptypb.Empty, error) {
+ return handler.Manager.EnableOnuSerialNumber(ctx, device)
+}
+
+func (handler *APIHandler) EnablePort(ctx context.Context, port *voltha.Port) (*emptypb.Empty, error) {
+ return handler.Manager.EnablePort(ctx, port)
+}
+
+func (handler *APIHandler) ForceDeleteDevice(ctx context.Context, id *voltha.ID) (*emptypb.Empty, error) {
+ return handler.Manager.ForceDeleteDevice(ctx, id)
+}
+
+func (handler *APIHandler) GetChildDevice(ctx context.Context, df *ca.ChildDeviceFilter) (*voltha.Device, error) {
+ return handler.Manager.GetChildDevice(ctx, df)
+}
+
+func (handler *APIHandler) GetChildDeviceWithProxyAddress(ctx context.Context, proxyAddress *voltha.Device_ProxyAddress) (*voltha.Device, error) {
+ return handler.Manager.GetChildDeviceWithProxyAddress(ctx, proxyAddress)
+}
+
+func (handler *APIHandler) GetChildDevices(ctx context.Context, parentDeviceID *common.ID) (*voltha.Devices, error) {
+ return handler.Manager.GetChildDevices(ctx, parentDeviceID)
+}
+
+func (handler *APIHandler) GetDevice(ctx context.Context, id *voltha.ID) (*voltha.Device, error) {
+ return handler.Manager.GetDevice(ctx, id)
+}
+
+func (handler *APIHandler) GetDevicePort(ctx context.Context, pf *ca.PortFilter) (*voltha.Port, error) {
+ return handler.Manager.GetDevicePort(ctx, pf)
+}
+
+func (handler *APIHandler) GetExtValue(ctx context.Context, value *extension.ValueSpecifier) (*extension.ReturnValues, error) {
+ return handler.Manager.GetExtValue(ctx, value)
+}
+
+func (handler *APIHandler) GetHealthStatus(stream core_service.CoreService_GetHealthStatusServer) error {
+ return handler.Manager.GetHealthStatus(stream)
+}
+
+func (handler *APIHandler) GetImageDownload(ctx context.Context, img *voltha.ImageDownload) (*voltha.ImageDownload, error) {
+ return handler.Manager.GetImageDownload(ctx, img)
+}
+
+func (handler *APIHandler) GetImageDownloadStatus(ctx context.Context, img *voltha.ImageDownload) (*voltha.ImageDownload, error) {
+ return handler.Manager.GetImageDownloadStatus(ctx, img)
+}
+
+func (handler *APIHandler) GetImageStatus(ctx context.Context, request *voltha.DeviceImageRequest) (*voltha.DeviceImageResponse, error) {
+ return handler.Manager.GetImageStatus(ctx, request)
+}
+
+func (handler *APIHandler) GetImages(ctx context.Context, id *voltha.ID) (*voltha.Images, error) {
+ return handler.Manager.GetImages(ctx, id)
+}
+
+func (handler *APIHandler) GetOnuImages(ctx context.Context, id *common.ID) (*voltha.OnuImages, error) {
+ return handler.Manager.GetOnuImages(ctx, id)
+}
+
+func (handler *APIHandler) GetPorts(ctx context.Context, pf *ca.PortFilter) (*voltha.Ports, error) {
+ return handler.Manager.GetPorts(ctx, pf)
+}
+
+func (handler *APIHandler) ListDeviceFlowGroups(ctx context.Context, id *voltha.ID) (*openflow_13.FlowGroups, error) {
+ return handler.Manager.ListDeviceFlowGroups(ctx, id)
+}
+
+func (handler *APIHandler) ListDeviceFlows(ctx context.Context, id *voltha.ID) (*openflow_13.Flows, error) {
+ return handler.Manager.ListDeviceFlows(ctx, id)
+}
+
+func (handler *APIHandler) ListDeviceIds(ctx context.Context, arg1 *emptypb.Empty) (*voltha.IDs, error) {
+ return handler.Manager.ListDeviceIds(ctx, arg1)
+}
+
+func (handler *APIHandler) ListDevicePmConfigs(ctx context.Context, id *voltha.ID) (*voltha.PmConfigs, error) {
+ return handler.Manager.ListDevicePmConfigs(ctx, id)
+}
+
+func (handler *APIHandler) ListDevicePorts(ctx context.Context, id *voltha.ID) (*voltha.Ports, error) {
+ return handler.Manager.ListDevicePorts(ctx, id)
+}
+
+func (handler *APIHandler) ListDevices(ctx context.Context, arg1 *emptypb.Empty) (*voltha.Devices, error) {
+ return handler.Manager.ListDevices(ctx, arg1)
+}
+
+func (handler *APIHandler) ListImageDownloads(ctx context.Context, id *voltha.ID) (*voltha.ImageDownloads, error) {
+ return handler.Manager.ListImageDownloads(ctx, id)
+}
+
+func (handler *APIHandler) PortCreated(ctx context.Context, port *voltha.Port) (*emptypb.Empty, error) {
+ return handler.Manager.PortCreated(ctx, port)
+}
+
+func (handler *APIHandler) PortStateUpdate(ctx context.Context, ps *ca.PortState) (*emptypb.Empty, error) {
+ return handler.Manager.PortStateUpdate(ctx, ps)
+}
+
+func (handler *APIHandler) PortsStateUpdate(ctx context.Context, ps *ca.PortStateFilter) (*emptypb.Empty, error) {
+ return handler.Manager.PortsStateUpdate(ctx, ps)
+}
+
+func (handler *APIHandler) PutVoipSystemProfile(ctx context.Context, voipSystemProfileRequest *voip_system_profile.VoipSystemProfileRequest) (*emptypb.Empty, error) {
+ return handler.Manager.PutVoipSystemProfile(ctx, voipSystemProfileRequest)
+}
+
+func (handler *APIHandler) PutVoipUserProfile(ctx context.Context, voipUserProfileRequest *voip_user_profile.VoipUserProfileRequest) (*emptypb.Empty, error) {
+ return handler.Manager.PutVoipUserProfile(ctx, voipUserProfileRequest)
+}
+
+func (handler *APIHandler) RebootDevice(ctx context.Context, id *voltha.ID) (*emptypb.Empty, error) {
+ return handler.Manager.RebootDevice(ctx, id)
+}
+
+func (handler *APIHandler) ReconcileChildDevices(ctx context.Context, parentDeviceID *common.ID) (*emptypb.Empty, error) {
+ return handler.Manager.ReconcileChildDevices(ctx, parentDeviceID)
+}
+
+func (handler *APIHandler) ReconcileDevices(ctx context.Context, ids *voltha.IDs) (*emptypb.Empty, error) {
+ return handler.Manager.ReconcileDevices(ctx, ids)
+}
+
+func (handler *APIHandler) RevertImageUpdate(ctx context.Context, img *voltha.ImageDownload) (*common.OperationResp, error) {
+ return handler.Manager.RevertImageUpdate(ctx, img)
+}
+
+func (handler *APIHandler) SendPacketIn(ctx context.Context, pi *ca.PacketIn) (*emptypb.Empty, error) {
+ return handler.Manager.SendPacketIn(ctx, pi)
+}
+
+func (handler *APIHandler) SetExtValue(ctx context.Context, value *extension.ValueSet) (*emptypb.Empty, error) {
+ return handler.Manager.SetExtValue(ctx, value)
+}
+
+func (handler *APIHandler) SimulateAlarm(ctx context.Context, simulateReq *voltha.SimulateAlarmRequest) (*common.OperationResp, error) {
+ return handler.Manager.SimulateAlarm(ctx, simulateReq)
+}
+
+func (handler *APIHandler) StartOmciTestAction(ctx context.Context, request *omci.OmciTestRequest) (*omci.TestResponse, error) {
+ return handler.Manager.StartOmciTestAction(ctx, request)
+}
+
+func (handler *APIHandler) UpdateDevice(ctx context.Context, config *voltha.UpdateDevice) (*emptypb.Empty, error) {
+ return handler.Manager.UpdateDevice(ctx, config)
+}
+
+func (handler *APIHandler) UpdateDevicePmConfigs(ctx context.Context, configs *voltha.PmConfigs) (*emptypb.Empty, error) {
+ return handler.Manager.UpdateDevicePmConfigs(ctx, configs)
+}
+
+func (handler *APIHandler) UpdateImageDownload(ctx context.Context, img *voltha.ImageDownload) (*emptypb.Empty, error) {
+ return handler.Manager.UpdateImageDownload(ctx, img)
+}
+
+// LogicalManager delegations to resolve ambiguity
+func (handler *APIHandler) DisableLogicalDevicePort(ctx context.Context, id *voltha.LogicalPortId) (*emptypb.Empty, error) {
+ return handler.LogicalManager.DisableLogicalDevicePort(ctx, id)
+}
+
+func (handler *APIHandler) EnableLogicalDevicePort(ctx context.Context, id *voltha.LogicalPortId) (*emptypb.Empty, error) {
+ return handler.LogicalManager.EnableLogicalDevicePort(ctx, id)
+}
+
+func (handler *APIHandler) GetLogicalDevice(ctx context.Context, id *voltha.ID) (*voltha.LogicalDevice, error) {
+ return handler.LogicalManager.GetLogicalDevice(ctx, id)
+}
+
+func (handler *APIHandler) GetLogicalDevicePort(ctx context.Context, lPortID *voltha.LogicalPortId) (*voltha.LogicalPort, error) {
+ return handler.LogicalManager.GetLogicalDevicePort(ctx, lPortID)
+}
+
+func (handler *APIHandler) ListLogicalDeviceFlowGroups(ctx context.Context, id *voltha.ID) (*openflow_13.FlowGroups, error) {
+ return handler.LogicalManager.ListLogicalDeviceFlowGroups(ctx, id)
+}
+
+func (handler *APIHandler) ListLogicalDeviceFlows(ctx context.Context, id *voltha.ID) (*openflow_13.Flows, error) {
+ return handler.LogicalManager.ListLogicalDeviceFlows(ctx, id)
+}
+
+func (handler *APIHandler) ListLogicalDeviceMeters(ctx context.Context, id *voltha.ID) (*openflow_13.Meters, error) {
+ return handler.LogicalManager.ListLogicalDeviceMeters(ctx, id)
+}
+
+func (handler *APIHandler) ListLogicalDevicePorts(ctx context.Context, id *voltha.ID) (*voltha.LogicalPorts, error) {
+ return handler.LogicalManager.ListLogicalDevicePorts(ctx, id)
+}
+
+func (handler *APIHandler) ListLogicalDevices(ctx context.Context, arg1 *emptypb.Empty) (*voltha.LogicalDevices, error) {
+ return handler.LogicalManager.ListLogicalDevices(ctx, arg1)
+}
+
+func (handler *APIHandler) ReceiveChangeEvents(e *emptypb.Empty, s voltha.VolthaService_ReceiveChangeEventsServer) error {
+ return handler.LogicalManager.ReceiveChangeEvents(e, s)
+}
+
+func (handler *APIHandler) ReceivePacketsIn(e *emptypb.Empty, s voltha.VolthaService_ReceivePacketsInServer) error {
+ return handler.LogicalManager.ReceivePacketsIn(e, s)
+}
+
+func (handler *APIHandler) StreamPacketsOut(packets voltha.VolthaService_StreamPacketsOutServer) error {
+ return handler.LogicalManager.StreamPacketsOut(packets)
+}
+
+func (handler *APIHandler) UpdateLogicalDeviceFlowGroupTable(ctx context.Context, flow *openflow_13.FlowGroupTableUpdate) (*emptypb.Empty, error) {
+ return handler.LogicalManager.UpdateLogicalDeviceFlowGroupTable(ctx, flow)
+}
+
+func (handler *APIHandler) UpdateLogicalDeviceFlowTable(ctx context.Context, flow *openflow_13.FlowTableUpdate) (*emptypb.Empty, error) {
+ return handler.LogicalManager.UpdateLogicalDeviceFlowTable(ctx, flow)
+}
+
+func (handler *APIHandler) UpdateLogicalDeviceMeterTable(ctx context.Context, meter *openflow_13.MeterModUpdate) (*emptypb.Empty, error) {
+ return handler.LogicalManager.UpdateLogicalDeviceMeterTable(ctx, meter)
+}
+
+// adapter.Manager delegations to resolve ambiguity
+func (handler *APIHandler) GetDeviceType(ctx context.Context, deviceType *common.ID) (*voltha.DeviceType, error) {
+ return handler.adapterManager.GetDeviceType(ctx, deviceType)
+}
+
+func (handler *APIHandler) ListAdapters(ctx context.Context, arg1 *emptypb.Empty) (*voltha.Adapters, error) {
+ return handler.adapterManager.ListAdapters(ctx, arg1)
+}
+
+func (handler *APIHandler) ListDeviceTypes(ctx context.Context, arg1 *emptypb.Empty) (*voltha.DeviceTypes, error) {
+ return handler.adapterManager.ListDeviceTypes(ctx, arg1)
+}
+
+func (handler *APIHandler) RegisterAdapter(ctx context.Context, registration *ca.AdapterRegistration) (*emptypb.Empty, error) {
+ return handler.adapterManager.RegisterAdapter(ctx, registration)
+}
diff --git a/rw_core/core/api/generate_delegations.go b/rw_core/core/api/generate_delegations.go
new file mode 100644
index 0000000..021ffde
--- /dev/null
+++ b/rw_core/core/api/generate_delegations.go
@@ -0,0 +1,560 @@
+//go:build ignore
+// +build ignore
+
+// Copyright 2018-2025 Open Networking Foundation (ONF) and the ONF Contributors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// Generator tool to create delegation methods for APIHandler
+// Run with: go run generate_delegations.go
+//
+// LIMITATIONS & KNOWN ISSUES:
+// 1. Complex types: Cannot handle function types, channels, or complex interfaces in signatures
+// 2. Package aliases: Hardcoded mapping (ofp -> openflow_13) - add new mappings as needed
+// 3. Manager categorization: Uses hardcoded lists - update when methods move between Managers
+// 4. Proto evolution: Assumes stable interface names (VolthaServiceServer, CoreServiceServer)
+//
+// MAINTENANCE REQUIRED WHEN:
+// - New proto packages introduced with custom aliases
+// - Methods move between Manager/LogicalManager/AdapterManager
+// - Proto generator changes file structure or naming
+// - New method signatures use unsupported Go types
+//
+// The generator will FAIL EXPLICITLY if it encounters unsupported patterns.
+// Manual review of delegations.go is recommended after regeneration.
+
+package main
+
+import (
+ "fmt"
+ "go/ast"
+ "go/format"
+ "go/parser"
+ "go/token"
+ "os"
+ "path/filepath"
+ "sort"
+ "strings"
+)
+
+type MethodInfo struct {
+ Name string
+ Params []string
+ Results []string
+ ParamNames []string
+}
+
+var warnings []string
+var errors []string
+
+func addWarning(msg string) {
+ warnings = append(warnings, "WARNING: "+msg)
+}
+
+func addError(msg string) {
+ errors = append(errors, "ERROR: "+msg)
+}
+
+func main() {
+ // Find vendor directory
+ vendorDir := filepath.Join("..", "..", "..", "vendor", "github.com", "opencord", "voltha-protos", "v5", "go")
+
+ // Parse proto interfaces
+ protoMethods := make(map[string]bool)
+ parseProtoInterface(filepath.Join(vendorDir, "voltha", "voltha_grpc.pb.go"), "VolthaServiceServer", protoMethods)
+ parseProtoInterface(filepath.Join(vendorDir, "core_service", "core_services_grpc.pb.go"), "CoreServiceServer", protoMethods)
+
+ // Parse Manager interfaces
+ deviceDir := filepath.Join("..", "device")
+ managerMethods := parseManagerMethods(deviceDir)
+
+ // Parse adapter.Manager methods
+ adapterDir := filepath.Join("..", "adapter")
+ adapterMethods := parseAdapterManagerMethods(adapterDir)
+
+ // Merge adapter methods into managerMethods
+ for name, info := range adapterMethods {
+ managerMethods[name] = info
+ }
+
+ // Find overlapping methods
+ var overlapping []string
+ for method := range protoMethods {
+ if managerMethods[method] != nil {
+ overlapping = append(overlapping, method)
+ }
+ }
+ sort.Strings(overlapping)
+
+ fmt.Printf("Found %d overlapping methods requiring delegation\n", len(overlapping))
+ fmt.Println("Generating delegations.go...")
+
+ // Generate the delegations.go file
+ if err := generateDelegationsFile(overlapping, managerMethods); err != nil {
+ fmt.Fprintf(os.Stderr, "Error generating delegations.go: %v\n", err)
+ os.Exit(1)
+ }
+
+ // Format the generated file
+ if err := formatFile("delegations.go"); err != nil {
+ fmt.Fprintf(os.Stderr, "Warning: Could not format delegations.go: %v\n", err)
+ }
+
+ // Report warnings and errors
+ if len(warnings) > 0 {
+ fmt.Println("\nWarnings:")
+ for _, w := range warnings {
+ fmt.Println(" " + w)
+ }
+ }
+
+ if len(errors) > 0 {
+ fmt.Println("\nErrors:")
+ for _, e := range errors {
+ fmt.Println(" " + e)
+ }
+ fmt.Println("\nGenerated code may be incomplete or incorrect!")
+ fmt.Println("Manual review and fixes may be required.")
+ os.Exit(1)
+ }
+
+ fmt.Println("Successfully generated delegations.go")
+}
+
+func generateDelegationsFile(methods []string, methodInfo map[string]*MethodInfo) error {
+ f, err := os.Create("delegations.go")
+ if err != nil {
+ return err
+ }
+ defer f.Close()
+
+ // Write header
+ fmt.Fprint(f, `/*
+ * Copyright 2018-2023 Open Networking Foundation (ONF) and the ONF Contributors
+ * Licensed under the Apache License, Version 2.0 (the "License")
+ */
+
+package api
+
+//go:generate go run generate_delegations.go
+
+// This file contains delegation methods to resolve ambiguities between
+// embedded UnimplementedVolthaServiceServer/UnimplementedCoreServiceServer
+// and the device.Manager that has the actual implementations.
+//
+// When a method exists in both the Unimplemented stub and the Manager,
+// Go cannot determine which one to use, so we explicitly delegate to Manager.
+//
+// To regenerate this file after proto updates, run: go generate ./rw_core/core/api
+
+import (
+ "context"
+
+ "github.com/opencord/voltha-protos/v5/go/common"
+ ca "github.com/opencord/voltha-protos/v5/go/core_adapter"
+ "github.com/opencord/voltha-protos/v5/go/core_service"
+ "github.com/opencord/voltha-protos/v5/go/extension"
+ "github.com/opencord/voltha-protos/v5/go/omci"
+ "github.com/opencord/voltha-protos/v5/go/openflow_13"
+ voip_system_profile "github.com/opencord/voltha-protos/v5/go/voip_system_profile"
+ voip_user_profile "github.com/opencord/voltha-protos/v5/go/voip_user_profile"
+ "github.com/opencord/voltha-protos/v5/go/voltha"
+ "google.golang.org/protobuf/types/known/emptypb"
+)
+
+// All methods below delegate to handler.Manager, handler.LogicalManager, or handler.adapterManager
+// to resolve ambiguity with embedded UnimplementedVolthaServiceServer/UnimplementedCoreServiceServer
+
+`)
+
+ // Group methods by receiver (determine which Manager they belong to)
+ deviceMethods := []string{}
+ logicalMethods := []string{}
+ adapterMethods := []string{}
+
+ // Known logical device methods
+ logicalMethodNames := map[string]bool{
+ "DisableLogicalDevicePort": true, "EnableLogicalDevicePort": true,
+ "GetLogicalDevice": true, "GetLogicalDevicePort": true,
+ "ListLogicalDeviceFlowGroups": true, "ListLogicalDeviceFlows": true,
+ "ListLogicalDeviceMeters": true, "ListLogicalDevicePorts": true,
+ "ListLogicalDevices": true, "StreamPacketsOut": true,
+ "UpdateLogicalDeviceFlowGroupTable": true, "UpdateLogicalDeviceFlowTable": true,
+ "UpdateLogicalDeviceMeterTable": true,
+ }
+
+ // Known adapter methods
+ adapterMethodNames := map[string]bool{
+ "GetDeviceType": true, "ListAdapters": true,
+ "ListDeviceTypes": true, "RegisterAdapter": true,
+ }
+
+ for _, method := range methods {
+ if logicalMethodNames[method] {
+ logicalMethods = append(logicalMethods, method)
+ } else if adapterMethodNames[method] {
+ adapterMethods = append(adapterMethods, method)
+ } else {
+ deviceMethods = append(deviceMethods, method)
+ }
+ }
+
+ // Warn if method categorization might be wrong
+ if len(deviceMethods) > 60 {
+ addWarning(fmt.Sprintf("Large number of device methods (%d) - verify Manager categorization", len(deviceMethods)))
+ }
+
+ // Write device.Manager delegations
+ for _, method := range deviceMethods {
+ info := methodInfo[method]
+ if info != nil {
+ writeDelegation(f, method, info, "Manager")
+ }
+ }
+
+ // Write LogicalManager delegations
+ if len(logicalMethods) > 0 {
+ fmt.Fprintln(f, "\n// LogicalManager delegations to resolve ambiguity")
+ for _, method := range logicalMethods {
+ info := methodInfo[method]
+ if info != nil {
+ writeDelegation(f, method, info, "LogicalManager")
+ }
+ }
+ }
+
+ // Write adapter.Manager delegations
+ if len(adapterMethods) > 0 {
+ fmt.Fprintln(f, "\n// adapter.Manager delegations to resolve ambiguity")
+ for _, method := range adapterMethods {
+ info := methodInfo[method]
+ if info != nil {
+ writeDelegation(f, method, info, "adapterManager")
+ }
+ }
+ }
+
+ return nil
+}
+
+func writeDelegation(f *os.File, methodName string, info *MethodInfo, receiver string) {
+ // Build parameter list
+ params := []string{}
+ for i := range info.ParamNames {
+ paramName := info.ParamNames[i]
+ // Replace _ with a valid parameter name
+ if paramName == "_" {
+ paramName = fmt.Sprintf("arg%d", i)
+ }
+ params = append(params, fmt.Sprintf("%s %s", paramName, info.Params[i]))
+ }
+
+ // Build result list
+ results := ""
+ if len(info.Results) == 1 {
+ results = " " + info.Results[0]
+ } else if len(info.Results) > 1 {
+ results = " (" + strings.Join(info.Results, ", ") + ")"
+ }
+
+ // Build call arguments (use original param names for the call)
+ callArgs := []string{}
+ for i, paramName := range info.ParamNames {
+ if paramName == "_" {
+ callArgs = append(callArgs, fmt.Sprintf("arg%d", i))
+ } else {
+ callArgs = append(callArgs, paramName)
+ }
+ }
+
+ fmt.Fprintf(f, "func (handler *APIHandler) %s(%s)%s {\n", methodName, strings.Join(params, ", "), results)
+ if len(info.Results) > 0 {
+ fmt.Fprintf(f, "\treturn handler.%s.%s(%s)\n", receiver, methodName, strings.Join(callArgs, ", "))
+ } else {
+ fmt.Fprintf(f, "\thandler.%s.%s(%s)\n", receiver, methodName, strings.Join(callArgs, ", "))
+ }
+ fmt.Fprintln(f, "}")
+ fmt.Fprintln(f)
+}
+
+func parseProtoInterface(filePath, interfaceName string, methods map[string]bool) {
+ fset := token.NewFileSet()
+ f, err := parser.ParseFile(fset, filePath, nil, 0)
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "Warning: Could not parse %s: %v\n", filePath, err)
+ return
+ }
+
+ ast.Inspect(f, func(n ast.Node) bool {
+ typeSpec, ok := n.(*ast.TypeSpec)
+ if !ok || typeSpec.Name.Name != interfaceName {
+ return true
+ }
+
+ iface, ok := typeSpec.Type.(*ast.InterfaceType)
+ if !ok {
+ return false
+ }
+
+ for _, method := range iface.Methods.List {
+ if len(method.Names) > 0 {
+ methodName := method.Names[0].Name
+ if !strings.HasPrefix(methodName, "mustEmbed") {
+ methods[methodName] = true
+ }
+ }
+ }
+ return false
+ })
+}
+
+func parseManagerMethods(deviceDir string) map[string]*MethodInfo {
+ methods := make(map[string]*MethodInfo)
+
+ // Parse all .go files in the device directory
+ dirEntries, err := os.ReadDir(deviceDir)
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "Warning: Could not read device directory: %v\n", err)
+ return methods
+ }
+
+ for _, entry := range dirEntries {
+ if entry.IsDir() || !strings.HasSuffix(entry.Name(), ".go") || strings.HasSuffix(entry.Name(), "_test.go") {
+ continue
+ }
+ filePath := filepath.Join(deviceDir, entry.Name())
+ fset := token.NewFileSet()
+ f, err := parser.ParseFile(fset, filePath, nil, 0)
+ if err != nil {
+ continue
+ }
+
+ ast.Inspect(f, func(n ast.Node) bool {
+ funcDecl, ok := n.(*ast.FuncDecl)
+ if !ok || funcDecl.Recv == nil || len(funcDecl.Recv.List) == 0 {
+ return true
+ }
+
+ // Check if it's a Manager or LogicalManager method
+ recvType := getReceiverType(funcDecl.Recv.List[0].Type)
+ if recvType != "Manager" && recvType != "LogicalManager" {
+ return true
+ }
+
+ methodName := funcDecl.Name.Name
+ if !ast.IsExported(methodName) {
+ return true
+ }
+
+ info := &MethodInfo{
+ Name: methodName,
+ Params: []string{},
+ Results: []string{},
+ ParamNames: []string{},
+ }
+
+ // Extract parameter types and names
+ if funcDecl.Type.Params != nil {
+ for i, field := range funcDecl.Type.Params.List {
+ typeStr := getTypeString(field.Type)
+ if len(field.Names) > 0 {
+ for _, name := range field.Names {
+ info.Params = append(info.Params, typeStr)
+ info.ParamNames = append(info.ParamNames, name.Name)
+ }
+ } else {
+ // Unnamed parameter, generate a name
+ paramName := fmt.Sprintf("arg%d", i)
+ info.Params = append(info.Params, typeStr)
+ info.ParamNames = append(info.ParamNames, paramName)
+ }
+ }
+ }
+
+ // Extract result types
+ if funcDecl.Type.Results != nil {
+ for _, field := range funcDecl.Type.Results.List {
+ typeStr := getTypeString(field.Type)
+ // Replace common package aliases with full package names
+ typeStr = strings.ReplaceAll(typeStr, "ofp.", "openflow_13.")
+ // Warn about potential unknown package aliases
+ if strings.Contains(typeStr, "unknown") {
+ addWarning(fmt.Sprintf("Method %s has unknown type in results", methodName))
+ }
+ info.Results = append(info.Results, typeStr)
+ }
+ }
+
+ methods[methodName] = info
+ return true
+ })
+ }
+
+ return methods
+}
+
+func parseAdapterManagerMethods(adapterDir string) map[string]*MethodInfo {
+ methods := make(map[string]*MethodInfo)
+
+ // Parse all .go files in the adapter directory
+ dirEntries, err := os.ReadDir(adapterDir)
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "Warning: Could not read adapter directory: %v\n", err)
+ return methods
+ }
+
+ for _, entry := range dirEntries {
+ if entry.IsDir() || !strings.HasSuffix(entry.Name(), ".go") || strings.HasSuffix(entry.Name(), "_test.go") {
+ continue
+ }
+ filePath := filepath.Join(adapterDir, entry.Name())
+ fset := token.NewFileSet()
+ f, err := parser.ParseFile(fset, filePath, nil, 0)
+ if err != nil {
+ continue
+ }
+
+ ast.Inspect(f, func(n ast.Node) bool {
+ funcDecl, ok := n.(*ast.FuncDecl)
+ if !ok || funcDecl.Recv == nil || len(funcDecl.Recv.List) == 0 {
+ return true
+ }
+
+ // Check if it's an adapter.Manager method
+ recvType := getReceiverType(funcDecl.Recv.List[0].Type)
+ if recvType != "Manager" {
+ return true
+ }
+
+ methodName := funcDecl.Name.Name
+ if !ast.IsExported(methodName) {
+ return true
+ }
+
+ info := &MethodInfo{
+ Name: methodName,
+ Params: []string{},
+ Results: []string{},
+ ParamNames: []string{},
+ }
+
+ // Extract parameter types and names
+ if funcDecl.Type.Params != nil {
+ for i, field := range funcDecl.Type.Params.List {
+ typeStr := getTypeString(field.Type)
+ // Replace common package aliases with full package names
+ typeStr = strings.ReplaceAll(typeStr, "core_adapter.", "ca.")
+ if len(field.Names) > 0 {
+ for _, name := range field.Names {
+ info.Params = append(info.Params, typeStr)
+ info.ParamNames = append(info.ParamNames, name.Name)
+ }
+ } else {
+ // Unnamed parameter, generate a name
+ paramName := fmt.Sprintf("arg%d", i)
+ info.Params = append(info.Params, typeStr)
+ info.ParamNames = append(info.ParamNames, paramName)
+ }
+ }
+ }
+
+ // Extract result types
+ if funcDecl.Type.Results != nil {
+ for _, field := range funcDecl.Type.Results.List {
+ typeStr := getTypeString(field.Type)
+ // Replace common package aliases with full package names
+ typeStr = strings.ReplaceAll(typeStr, "ofp.", "openflow_13.")
+ typeStr = strings.ReplaceAll(typeStr, "core_adapter.", "ca.")
+ // Warn about potential unknown package aliases
+ if strings.Contains(typeStr, "unknown") {
+ addWarning(fmt.Sprintf("Method %s has unknown type in results", methodName))
+ }
+ info.Results = append(info.Results, typeStr)
+ }
+ }
+
+ methods[methodName] = info
+ return true
+ })
+ }
+
+ return methods
+}
+
+func getReceiverType(expr ast.Expr) string {
+ switch t := expr.(type) {
+ case *ast.StarExpr:
+ if ident, ok := t.X.(*ast.Ident); ok {
+ return ident.Name
+ }
+ case *ast.Ident:
+ return t.Name
+ }
+ return ""
+}
+
+func getTypeString(expr ast.Expr) string {
+ switch t := expr.(type) {
+ case *ast.Ident:
+ return t.Name
+ case *ast.StarExpr:
+ return "*" + getTypeString(t.X)
+ case *ast.SelectorExpr:
+ return getTypeString(t.X) + "." + t.Sel.Name
+ case *ast.ArrayType:
+ return "[]" + getTypeString(t.Elt)
+ case *ast.MapType:
+ return "map[" + getTypeString(t.Key) + "]" + getTypeString(t.Value)
+ case *ast.InterfaceType:
+ if t.Methods == nil || len(t.Methods.List) == 0 {
+ return "interface{}"
+ }
+ addWarning("Complex interface type detected - may need manual review")
+ return "interface{}"
+ case *ast.Ellipsis:
+ return "..." + getTypeString(t.Elt)
+ case *ast.FuncType:
+ addError("Function type parameter detected - not supported by generator")
+ return "func(...) ..."
+ case *ast.ChanType:
+ addError("Channel type parameter detected - not supported by generator")
+ return "chan ..."
+ default:
+ addError(fmt.Sprintf("Unknown type expression: %T", expr))
+ return "unknown"
+ }
+}
+
+func formatFile(filename string) error {
+ // Read the file
+ content, err := os.ReadFile(filename)
+ if err != nil {
+ return err
+ }
+
+ // Parse and format
+ fset := token.NewFileSet()
+ node, err := parser.ParseFile(fset, filename, content, parser.ParseComments)
+ if err != nil {
+ return err
+ }
+
+ // Write formatted output
+ f, err := os.Create(filename)
+ if err != nil {
+ return err
+ }
+ defer f.Close()
+
+ return format.Node(f, fset, node)
+}
diff --git a/rw_core/core/api/grpc_nbi_handler.go b/rw_core/core/api/grpc_nbi_handler.go
index a9713e2..39fa671 100755
--- a/rw_core/core/api/grpc_nbi_handler.go
+++ b/rw_core/core/api/grpc_nbi_handler.go
@@ -21,17 +21,20 @@
"encoding/json"
"errors"
- "github.com/golang/protobuf/ptypes/empty"
"github.com/opencord/voltha-go/rw_core/core/adapter"
"github.com/opencord/voltha-go/rw_core/core/device"
"github.com/opencord/voltha-lib-go/v7/pkg/version"
"github.com/opencord/voltha-protos/v5/go/common"
+ "github.com/opencord/voltha-protos/v5/go/core_service"
"github.com/opencord/voltha-protos/v5/go/omci"
"github.com/opencord/voltha-protos/v5/go/voltha"
+ "google.golang.org/protobuf/types/known/emptypb"
)
// APIHandler combines the partial API implementations in various components into a complete voltha implementation
type APIHandler struct {
+ voltha.UnimplementedVolthaServiceServer
+ core_service.UnimplementedCoreServiceServer
*device.Manager
*device.LogicalManager
adapterManager // *adapter.Manager
@@ -50,7 +53,7 @@
}
// GetVoltha currently just returns version information
-func (handler *APIHandler) GetVoltha(ctx context.Context, _ *empty.Empty) (*voltha.Voltha, error) {
+func (handler *APIHandler) GetVoltha(ctx context.Context, _ *emptypb.Empty) (*voltha.Voltha, error) {
logger.Debug(ctx, "GetVoltha")
/*
* For now, encode all the version information into a JSON object and
@@ -68,7 +71,7 @@
var errUnimplemented = errors.New("unimplemented")
-func (handler *APIHandler) ListCoreInstances(context.Context, *empty.Empty) (*voltha.CoreInstances, error) {
+func (handler *APIHandler) ListCoreInstances(context.Context, *emptypb.Empty) (*voltha.CoreInstances, error) {
return nil, errUnimplemented
}
func (handler *APIHandler) GetCoreInstance(context.Context, *voltha.ID) (*voltha.CoreInstance, error) {
@@ -80,13 +83,13 @@
func (handler *APIHandler) UpdateEventFilter(context.Context, *voltha.EventFilter) (*voltha.EventFilter, error) {
return nil, errUnimplemented
}
-func (handler *APIHandler) DeleteEventFilter(context.Context, *voltha.EventFilter) (*empty.Empty, error) {
+func (handler *APIHandler) DeleteEventFilter(context.Context, *voltha.EventFilter) (*emptypb.Empty, error) {
return nil, errUnimplemented
}
func (handler *APIHandler) GetEventFilter(context.Context, *voltha.ID) (*voltha.EventFilters, error) {
return nil, errUnimplemented
}
-func (handler *APIHandler) ListEventFilters(context.Context, *empty.Empty) (*voltha.EventFilters, error) {
+func (handler *APIHandler) ListEventFilters(context.Context, *emptypb.Empty) (*voltha.EventFilters, error) {
return nil, errUnimplemented
}
func (handler *APIHandler) SelfTest(context.Context, *voltha.ID) (*voltha.SelfTestResponse, error) {
diff --git a/rw_core/core/device/agent.go b/rw_core/core/device/agent.go
index 9631fee..3ef4905 100755
--- a/rw_core/core/device/agent.go
+++ b/rw_core/core/device/agent.go
@@ -31,8 +31,9 @@
"github.com/opencord/voltha-protos/v5/go/omci"
"github.com/cenkalti/backoff/v3"
- "github.com/gogo/protobuf/proto"
- "github.com/golang/protobuf/ptypes/empty"
+ "google.golang.org/protobuf/proto"
+ "google.golang.org/protobuf/types/known/emptypb"
+
"github.com/opencord/voltha-go/rw_core/config"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
@@ -1167,9 +1168,9 @@
updatedPeers = append(updatedPeers, peerPort)
}
}
- newPort := *oldPort
+ newPort := proto.Clone(oldPort).(*voltha.Port)
newPort.Peers = updatedPeers
- if err = portHandle.Update(ctx, &newPort); err != nil {
+ if err = portHandle.Update(ctx, newPort); err != nil {
portHandle.Unlock()
return nil
}
@@ -1290,7 +1291,7 @@
return retVal, err
}
-func (agent *Agent) setExtValue(ctx context.Context, device *voltha.Device, value *extension.ValueSet) (*empty.Empty, error) {
+func (agent *Agent) setExtValue(ctx context.Context, device *voltha.Device, value *extension.ValueSet) (*emptypb.Empty, error) {
logger.Debugw(ctx, "set-ext-value", log.Fields{"device-id": value.Id})
var err error
diff --git a/rw_core/core/device/agent_flow.go b/rw_core/core/device/agent_flow.go
index 2f7a3a9..0a323f3 100644
--- a/rw_core/core/device/agent_flow.go
+++ b/rw_core/core/device/agent_flow.go
@@ -22,7 +22,6 @@
ca "github.com/opencord/voltha-protos/v5/go/core_adapter"
- "github.com/gogo/protobuf/proto"
coreutils "github.com/opencord/voltha-go/rw_core/utils"
fu "github.com/opencord/voltha-lib-go/v7/pkg/flows"
"github.com/opencord/voltha-lib-go/v7/pkg/log"
@@ -31,6 +30,7 @@
"github.com/opencord/voltha-protos/v5/go/voltha"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
+ "google.golang.org/protobuf/proto"
)
// listDeviceFlows returns device flows
diff --git a/rw_core/core/device/agent_group.go b/rw_core/core/device/agent_group.go
index 72e9bd7..bdd8b5a 100644
--- a/rw_core/core/device/agent_group.go
+++ b/rw_core/core/device/agent_group.go
@@ -19,7 +19,6 @@
import (
"context"
- "github.com/gogo/protobuf/proto"
coreutils "github.com/opencord/voltha-go/rw_core/utils"
"github.com/opencord/voltha-lib-go/v7/pkg/log"
"github.com/opencord/voltha-protos/v5/go/common"
@@ -27,6 +26,7 @@
"github.com/opencord/voltha-protos/v5/go/voltha"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
+ "google.golang.org/protobuf/proto"
)
// listDeviceGroups returns logical device flow groups
diff --git a/rw_core/core/device/agent_image.go b/rw_core/core/device/agent_image.go
index e71ea07..7ba24d4 100644
--- a/rw_core/core/device/agent_image.go
+++ b/rw_core/core/device/agent_image.go
@@ -25,12 +25,12 @@
"github.com/opencord/voltha-protos/v5/go/common"
ca "github.com/opencord/voltha-protos/v5/go/core_adapter"
- "github.com/gogo/protobuf/proto"
coreutils "github.com/opencord/voltha-go/rw_core/utils"
"github.com/opencord/voltha-lib-go/v7/pkg/log"
"github.com/opencord/voltha-protos/v5/go/voltha"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
+ "google.golang.org/protobuf/proto"
)
func (agent *Agent) downloadImage(ctx context.Context, img *voltha.ImageDownload) (*common.OperationResp, error) {
diff --git a/rw_core/core/device/agent_pm_config.go b/rw_core/core/device/agent_pm_config.go
index a63bb01..96d7021 100644
--- a/rw_core/core/device/agent_pm_config.go
+++ b/rw_core/core/device/agent_pm_config.go
@@ -20,12 +20,12 @@
"context"
"time"
- "github.com/gogo/protobuf/proto"
"github.com/opencord/voltha-lib-go/v7/pkg/log"
ca "github.com/opencord/voltha-protos/v5/go/core_adapter"
"github.com/opencord/voltha-protos/v5/go/voltha"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
+ "google.golang.org/protobuf/proto"
)
func (agent *Agent) updatePmConfigs(ctx context.Context, pmConfigs *voltha.PmConfigs) error {
diff --git a/rw_core/core/device/agent_port.go b/rw_core/core/device/agent_port.go
index 61bb451..7015240 100644
--- a/rw_core/core/device/agent_port.go
+++ b/rw_core/core/device/agent_port.go
@@ -23,13 +23,13 @@
"github.com/opencord/voltha-protos/v5/go/adapter_service"
"github.com/opencord/voltha-protos/v5/go/common"
- "github.com/gogo/protobuf/proto"
"github.com/opencord/voltha-go/rw_core/core/device/port"
coreutils "github.com/opencord/voltha-go/rw_core/utils"
"github.com/opencord/voltha-lib-go/v7/pkg/log"
"github.com/opencord/voltha-protos/v5/go/voltha"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
+ "google.golang.org/protobuf/proto"
)
// listDevicePorts returns device ports
@@ -73,9 +73,9 @@
if portHandle, have := agent.portLoader.Lock(portID); have {
if oldPort := portHandle.GetReadOnly(); (1<<oldPort.Type)&portTypeFilter == 0 { // only update port types not included in the mask
// clone top-level port struct
- newPort := *oldPort
+ newPort := proto.Clone(oldPort).(*voltha.Port)
newPort.OperStatus = operStatus
- if err := portHandle.Update(ctx, &newPort); err != nil {
+ if err := portHandle.Update(ctx, newPort); err != nil {
portHandle.Unlock()
return err
}
@@ -113,9 +113,9 @@
return nil
}
- newPort := *port // clone top-level port struct
+ newPort := proto.Clone(port).(*voltha.Port) // clone top-level port struct
newPort.OperStatus = operStatus
- return portHandle.Update(ctx, &newPort)
+ return portHandle.Update(ctx, newPort)
}
func (agent *Agent) deleteAllPorts(ctx context.Context) error {
@@ -177,11 +177,11 @@
// Creation of OLT PON port is being processed after a default PON port was created. Just update it.
logger.Infow(ctx, "update-pon-port-created-by-default", log.Fields{"default-port": oldPort, "port-to-add": port})
- newPort := *oldPort // clone top-level port struct
+ newPort := proto.Clone(oldPort).(*voltha.Port) // clone top-level port struct
newPort.Label = port.Label
newPort.OperStatus = port.OperStatus
- err = portHandle.Update(ctx, &newPort)
+ err = portHandle.Update(ctx, newPort)
if err != nil {
desc = err.Error()
return err
@@ -257,9 +257,9 @@
return err
}
- newPort := *oldPort
+ newPort := proto.Clone(oldPort).(*voltha.Port) // clone top-level port struct
newPort.AdminState = voltha.AdminState_DISABLED
- if err = portHandle.Update(ctx, &newPort); err != nil {
+ if err = portHandle.Update(ctx, newPort); err != nil {
return err
}
@@ -287,7 +287,7 @@
operStatus.Code = common.OperationResp_OPERATION_IN_PROGRESS
go func() {
defer cancel()
- _, err = client.DisablePort(subCtx, &newPort)
+ _, err = client.DisablePort(subCtx, newPort)
if err == nil {
agent.onSuccess(subCtx, nil, nil, true)
} else {
@@ -319,9 +319,9 @@
return err
}
- newPort := *oldPort
+ newPort := proto.Clone(oldPort).(*voltha.Port) // clone top-level port struct
newPort.AdminState = voltha.AdminState_ENABLED
- if err = portHandle.Update(ctx, &newPort); err != nil {
+ if err = portHandle.Update(ctx, newPort); err != nil {
return err
}
@@ -346,7 +346,7 @@
operStatus.Code = common.OperationResp_OPERATION_IN_PROGRESS
go func() {
defer cancel()
- _, err := client.EnablePort(subCtx, &newPort)
+ _, err := client.EnablePort(subCtx, newPort)
if err == nil {
agent.onSuccess(subCtx, nil, nil, true)
} else {
diff --git a/rw_core/core/device/agent_test.go b/rw_core/core/device/agent_test.go
index c0a6a0e..a00becd 100755
--- a/rw_core/core/device/agent_test.go
+++ b/rw_core/core/device/agent_test.go
@@ -29,7 +29,6 @@
ver "github.com/opencord/voltha-lib-go/v7/pkg/version"
ca "github.com/opencord/voltha-protos/v5/go/core_adapter"
- "github.com/gogo/protobuf/proto"
"github.com/opencord/voltha-go/db/model"
"github.com/opencord/voltha-go/rw_core/config"
"github.com/opencord/voltha-go/rw_core/core/adapter"
@@ -45,6 +44,7 @@
"github.com/opencord/voltha-protos/v5/go/voltha"
"github.com/phayes/freeport"
"github.com/stretchr/testify/assert"
+ "google.golang.org/protobuf/proto"
)
type DATest struct {
diff --git a/rw_core/core/device/event/event.go b/rw_core/core/device/event/event.go
index e07990c..09e3238 100644
--- a/rw_core/core/device/event/event.go
+++ b/rw_core/core/device/event/event.go
@@ -24,7 +24,6 @@
"sync"
"time"
- "github.com/golang/protobuf/ptypes/empty"
"github.com/opencord/voltha-go/rw_core/utils"
ev "github.com/opencord/voltha-lib-go/v7/pkg/events"
"github.com/opencord/voltha-lib-go/v7/pkg/events/eventif"
@@ -34,12 +33,13 @@
"github.com/opencord/voltha-protos/v5/go/voltha"
"github.com/opentracing/opentracing-go"
jtracing "github.com/uber/jaeger-client-go"
+ "google.golang.org/protobuf/types/known/emptypb"
)
type Manager struct {
- packetInQueue chan openflow_13.PacketIn
+ packetInQueue chan *openflow_13.PacketIn
packetInQueueDone chan bool
- changeEventQueue chan openflow_13.ChangeEvent
+ changeEventQueue chan *openflow_13.ChangeEvent
changeEventQueueDone chan bool
Agent *Agent
}
@@ -52,9 +52,9 @@
func NewManager(proxyForEvents eventif.EventProxy, instanceID string, stackID string) *Manager {
return &Manager{
- packetInQueue: make(chan openflow_13.PacketIn, 100),
+ packetInQueue: make(chan *openflow_13.PacketIn, 100),
packetInQueueDone: make(chan bool, 1),
- changeEventQueue: make(chan openflow_13.ChangeEvent, 100),
+ changeEventQueue: make(chan *openflow_13.ChangeEvent, 100),
changeEventQueueDone: make(chan bool, 1),
Agent: NewAgent(proxyForEvents, instanceID, stackID),
}
@@ -69,7 +69,7 @@
}
func (q *Manager) SendPacketIn(ctx context.Context, deviceID string, packet *openflow_13.OfpPacketIn) {
// TODO: Augment the OF PacketIn to include the transactionId
- packetIn := openflow_13.PacketIn{Id: deviceID, PacketIn: packet}
+ packetIn := &openflow_13.PacketIn{Id: deviceID, PacketIn: packet}
logger.Debugw(ctx, "send-packet-in", log.Fields{"packet-in": packetIn})
q.packetInQueue <- packetIn
}
@@ -101,10 +101,10 @@
func (q *Manager) flushFailedPackets(ctx context.Context, tracker *callTracker) {
if tracker.failedPacket != nil {
switch failedPacket := tracker.failedPacket.(type) {
- case openflow_13.PacketIn:
+ case *openflow_13.PacketIn:
logger.Debug(ctx, "enqueueing-last-failed-packet-in")
q.packetInQueue <- failedPacket
- case openflow_13.ChangeEvent:
+ case *openflow_13.ChangeEvent:
logger.Debug(ctx, "enqueueing-last-failed-change-event")
q.changeEventQueue <- failedPacket
}
@@ -112,7 +112,7 @@
}
// ReceivePacketsIn receives packets from adapter
-func (q *Manager) ReceivePacketsIn(_ *empty.Empty, packetsIn voltha.VolthaService_ReceivePacketsInServer) error {
+func (q *Manager) ReceivePacketsIn(_ *emptypb.Empty, packetsIn voltha.VolthaService_ReceivePacketsInServer) error {
ctx := context.Background()
ctx = utils.WithRPCMetadataContext(ctx, "ReceivePacketsIn")
var streamingTracker = q.getStreamingTracker(ctx, "ReceivePacketsIn", q.packetInQueueDone)
@@ -127,7 +127,7 @@
logger.Debugw(ctx, "sending-packet-in", log.Fields{
"packet": hex.EncodeToString(packet.PacketIn.Data),
})
- if err := packetsIn.Send(&packet); err != nil {
+ if err := packetsIn.Send(packet); err != nil {
logger.Errorw(ctx, "failed-to-send-packet", log.Fields{"error": err})
go q.Agent.GetAndSendRPCEvent(ctx, packet.Id, err.Error(),
nil, "RPC_ERROR_RAISE_EVENT", voltha.EventCategory_COMMUNICATION,
@@ -150,7 +150,7 @@
func (q *Manager) SendChangeEvent(ctx context.Context, deviceID string, reason openflow_13.OfpPortReason, desc *openflow_13.OfpPort) {
logger.Debugw(ctx, "send-change-event", log.Fields{"device-id": deviceID, "reason": reason, "desc": desc})
- q.changeEventQueue <- openflow_13.ChangeEvent{
+ q.changeEventQueue <- &openflow_13.ChangeEvent{
Id: deviceID,
Event: &openflow_13.ChangeEvent_PortStatus{
PortStatus: &openflow_13.OfpPortStatus{
@@ -181,7 +181,7 @@
cookie := make([]byte, 52)
binary.BigEndian.PutUint64(cookie, flowCookie)
bs = append(bs, cookie...)
- q.changeEventQueue <- openflow_13.ChangeEvent{
+ q.changeEventQueue <- &openflow_13.ChangeEvent{
Id: deviceID,
Event: &openflow_13.ChangeEvent_Error{
Error: &openflow_13.OfpErrorMsg{
@@ -200,7 +200,7 @@
// SendDeviceDeletionEvent notifies the ofAgent that the logical device was removed.
func (q *Manager) SendDeviceDeletionEvent(ctx context.Context, logicalDeviceID string) {
logger.Infow(ctx, "send-change-event-for-device-deletion", log.Fields{"logical-device-id": logicalDeviceID})
- q.changeEventQueue <- openflow_13.ChangeEvent{
+ q.changeEventQueue <- &openflow_13.ChangeEvent{
Id: logicalDeviceID,
Event: &openflow_13.ChangeEvent_DeviceStatus{
DeviceStatus: &openflow_13.OfpDeviceStatus{
@@ -211,7 +211,7 @@
}
// ReceiveChangeEvents receives change in events
-func (q *Manager) ReceiveChangeEvents(_ *empty.Empty, changeEvents voltha.VolthaService_ReceiveChangeEventsServer) error {
+func (q *Manager) ReceiveChangeEvents(_ *emptypb.Empty, changeEvents voltha.VolthaService_ReceiveChangeEventsServer) error {
ctx := context.Background()
ctx = utils.WithRPCMetadataContext(ctx, "ReceiveChangeEvents")
var streamingTracker = q.getStreamingTracker(ctx, "ReceiveChangeEvents", q.changeEventQueueDone)
@@ -225,7 +225,7 @@
// Dequeue a change event
case event := <-q.changeEventQueue:
logger.Debugw(ctx, "sending-change-event", log.Fields{"event": event})
- if err := changeEvents.Send(&event); err != nil {
+ if err := changeEvents.Send(event); err != nil {
logger.Errorw(ctx, "failed-to-send-change-event", log.Fields{"error": err})
go q.Agent.GetAndSendRPCEvent(ctx, event.Id, err.Error(),
nil, "RPC_ERROR_RAISE_EVENT", voltha.EventCategory_COMMUNICATION, nil,
@@ -245,7 +245,7 @@
return nil
}
-func (q *Manager) GetChangeEventsQueueForTest() <-chan openflow_13.ChangeEvent {
+func (q *Manager) GetChangeEventsQueueForTest() <-chan *openflow_13.ChangeEvent {
return q.changeEventQueue
}
@@ -311,7 +311,7 @@
logger.Errorw(ctx, "error-sending-device-event", log.Fields{"id": device.Id, "err": err})
return err
}
- logger.Debugw(ctx, "device-state-change-sent", log.Fields{"event": *de})
+ logger.Debugw(ctx, "device-state-change-sent", log.Fields{"event": de})
return nil
}
@@ -335,6 +335,6 @@
logger.Errorw(ctx, "error-sending-device-deleted-event", log.Fields{"id": device.Id, "err": err})
return err
}
- logger.Debugw(ctx, "device-deleted-event-sent", log.Fields{"event": *de})
+ logger.Debugw(ctx, "device-deleted-event-sent", log.Fields{"event": de})
return nil
}
diff --git a/rw_core/core/device/extension_manager.go b/rw_core/core/device/extension_manager.go
index 858656a..171b094 100644
--- a/rw_core/core/device/extension_manager.go
+++ b/rw_core/core/device/extension_manager.go
@@ -27,6 +27,7 @@
)
type ExtensionManager struct {
+ extension.UnimplementedExtensionServer
DeviceManager *Manager
}
diff --git a/rw_core/core/device/logical_agent.go b/rw_core/core/device/logical_agent.go
index 904fa91..03c50ad 100644
--- a/rw_core/core/device/logical_agent.go
+++ b/rw_core/core/device/logical_agent.go
@@ -22,7 +22,6 @@
"sync"
"time"
- "github.com/gogo/protobuf/proto"
"github.com/opencord/voltha-go/db/model"
"github.com/opencord/voltha-go/rw_core/core/device/flow"
"github.com/opencord/voltha-go/rw_core/core/device/group"
@@ -38,6 +37,7 @@
"github.com/opencord/voltha-protos/v5/go/voltha"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
+ "google.golang.org/protobuf/proto"
)
// LogicalAgent represent attributes of logical device agent
diff --git a/rw_core/core/device/logical_agent_flow.go b/rw_core/core/device/logical_agent_flow.go
index 9357597..c197503 100644
--- a/rw_core/core/device/logical_agent_flow.go
+++ b/rw_core/core/device/logical_agent_flow.go
@@ -23,7 +23,6 @@
"strconv"
"time"
- "github.com/gogo/protobuf/proto"
"github.com/opencord/voltha-go/rw_core/core/device/flow"
"github.com/opencord/voltha-go/rw_core/route"
coreutils "github.com/opencord/voltha-go/rw_core/utils"
@@ -33,6 +32,7 @@
"github.com/opencord/voltha-protos/v5/go/voltha"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
+ "google.golang.org/protobuf/proto"
)
// listLogicalDeviceFlows returns logical device flows
diff --git a/rw_core/core/device/logical_agent_meter.go b/rw_core/core/device/logical_agent_meter.go
index 69e6a86..f09e398 100644
--- a/rw_core/core/device/logical_agent_meter.go
+++ b/rw_core/core/device/logical_agent_meter.go
@@ -84,7 +84,7 @@
logger.Errorw(ctx, "failed-meterAdd-meterMod-is-nil", log.Fields{"logical-device-id": agent.logicalDeviceID})
return nil
}
- logger.Debugw(ctx, "meterAdd", log.Fields{"metermod": *meterMod, "logical-device-id": agent.logicalDeviceID})
+ logger.Debugw(ctx, "meterAdd", log.Fields{"metermod": meterMod, "logical-device-id": agent.logicalDeviceID})
meterEntry := fu.MeterEntryFromMeterMod(ctx, meterMod)
@@ -97,7 +97,7 @@
if created {
logger.Debugw(ctx, "Meter-added-successfully", log.Fields{"Added-meter": meterEntry, "logical-device-id": agent.logicalDeviceID})
} else {
- logger.Infow(ctx, "Meter-already-exists", log.Fields{"meter": *meterMod, "logical-device-id": agent.logicalDeviceID})
+ logger.Infow(ctx, "Meter-already-exists", log.Fields{"meter": meterMod, "logical-device-id": agent.logicalDeviceID})
}
return nil
}
@@ -107,7 +107,7 @@
logger.Errorw(ctx, "failed-meterDelete-meterMod-is-nil", log.Fields{"logical-device-id": agent.logicalDeviceID})
return nil
}
- logger.Debug(ctx, "meterDelete", log.Fields{"meterMod": *meterMod, "logical-device-id": agent.logicalDeviceID})
+ logger.Debug(ctx, "meterDelete", log.Fields{"meterMod": meterMod, "logical-device-id": agent.logicalDeviceID})
meterHandle, have := agent.meterLoader.Lock(meterMod.MeterId)
if !have {
diff --git a/rw_core/core/device/logical_agent_meter_helpers.go b/rw_core/core/device/logical_agent_meter_helpers.go
index f0a8ad6..9894ee8 100644
--- a/rw_core/core/device/logical_agent_meter_helpers.go
+++ b/rw_core/core/device/logical_agent_meter_helpers.go
@@ -23,6 +23,7 @@
fu "github.com/opencord/voltha-lib-go/v7/pkg/flows"
"github.com/opencord/voltha-lib-go/v7/pkg/log"
ofp "github.com/opencord/voltha-protos/v5/go/openflow_13"
+ "google.golang.org/protobuf/proto"
)
// GetMeterConfig returns meters which which are used by the given flows
@@ -35,7 +36,7 @@
meterHandle, have := agent.meterLoader.Lock(flowMeterID)
if !have {
logger.Errorw(ctx, "Meter-referred-by-flow-is-not-found-in-logicaldevice",
- log.Fields{"meterID": flowMeterID, "Available-meters": metersConfig, "flow": *flow})
+ log.Fields{"meterID": flowMeterID, "Available-meters": metersConfig, "flow": flow})
return nil, fmt.Errorf("Meter-referred-by-flow-is-not-found-in-logicaldevice.MeterId-%d", flowMeterID)
}
@@ -57,7 +58,7 @@
meterID := fu.GetMeterIdFromFlow(flow)
logger.Debugw(ctx, "Meter-id-in-flow-mod", log.Fields{"meterId": meterID})
if meterID == 0 {
- logger.Debugw(ctx, "No-meter-present-in-the-flow", log.Fields{"flow": *flow})
+ logger.Debugw(ctx, "No-meter-present-in-the-flow", log.Fields{"flow": flow})
return true
}
@@ -74,7 +75,7 @@
oldMeter := meterHandle.GetReadOnly()
// avoiding using proto.Clone by only copying what have changed (this assumes that the oldMeter will never be modified)
- newStats := *oldMeter.Stats
+ newStats := proto.Clone(oldMeter.Stats).(*ofp.OfpMeterStats)
switch flowCommand {
case ofp.OfpFlowModCommand_OFPFC_ADD:
if revertUpdate {
diff --git a/rw_core/core/device/logical_agent_port.go b/rw_core/core/device/logical_agent_port.go
index e06cb6f..16d889f 100644
--- a/rw_core/core/device/logical_agent_port.go
+++ b/rw_core/core/device/logical_agent_port.go
@@ -28,6 +28,7 @@
"github.com/opencord/voltha-protos/v5/go/voltha"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
+ "google.golang.org/protobuf/proto"
)
// listLogicalDevicePorts returns logical device ports
@@ -164,9 +165,9 @@
}
func clonePortSetState(oldPort *voltha.LogicalPort, state voltha.OperStatus_Types) *voltha.LogicalPort {
- newPort := *oldPort // only clone the struct(s) that will be changed
- newOfpPort := *oldPort.OfpPort
- newPort.OfpPort = &newOfpPort
+ newPort := proto.Clone(oldPort).(*voltha.LogicalPort) // only clone the struct(s) that will be changed
+ newOfpPort := proto.Clone(oldPort.OfpPort).(*ofp.OfpPort)
+ newPort.OfpPort = newOfpPort
if state == voltha.OperStatus_ACTIVE {
newOfpPort.Config &= ^uint32(ofp.OfpPortConfig_OFPPC_PORT_DOWN)
@@ -175,7 +176,7 @@
newOfpPort.Config |= uint32(ofp.OfpPortConfig_OFPPC_PORT_DOWN)
newOfpPort.State = uint32(ofp.OfpPortState_OFPPS_LINK_DOWN)
}
- return &newPort
+ return newPort
}
// setupUNILogicalPorts creates a UNI port on the logical device that represents a child UNI interface
@@ -262,12 +263,12 @@
oldPort := portHandle.GetReadOnly()
- newPort := *oldPort // only clone the struct(s) that will be changed
- newOfpPort := *oldPort.OfpPort
- newPort.OfpPort = &newOfpPort
+ newPort := proto.Clone(oldPort).(*voltha.LogicalPort) // only clone the struct(s) that will be changed
+ newOfpPort := proto.Clone(oldPort.OfpPort).(*ofp.OfpPort)
+ newPort.OfpPort = newOfpPort
newOfpPort.Config &= ^uint32(ofp.OfpPortConfig_OFPPC_PORT_DOWN)
- if err := portHandle.Update(ctx, &newPort); err != nil {
+ if err := portHandle.Update(ctx, newPort); err != nil {
return err
}
agent.orderedEvents.send(ctx, agent, agent.logicalDeviceID, ofp.OfpPortReason_OFPPR_MODIFY, newPort.OfpPort)
@@ -284,12 +285,12 @@
oldPort := portHandle.GetReadOnly()
- newPort := *oldPort // only clone the struct(s) that will be changed
- newOfpPort := *oldPort.OfpPort
- newPort.OfpPort = &newOfpPort
+ newPort := proto.Clone(oldPort).(*voltha.LogicalPort) // only clone the struct(s) that will be changed
+ newOfpPort := proto.Clone(oldPort.OfpPort).(*ofp.OfpPort)
+ newPort.OfpPort = newOfpPort
newOfpPort.Config = (newOfpPort.Config & ^uint32(ofp.OfpPortConfig_OFPPC_PORT_DOWN)) | uint32(ofp.OfpPortConfig_OFPPC_PORT_DOWN)
- if err := portHandle.Update(ctx, &newPort); err != nil {
+ if err := portHandle.Update(ctx, newPort); err != nil {
return err
}
agent.orderedEvents.send(ctx, agent, agent.logicalDeviceID, ofp.OfpPortReason_OFPPR_MODIFY, newPort.OfpPort)
@@ -304,7 +305,7 @@
logger.Debugw(ctx, "add-nni-logical-port", log.Fields{"logical-device-id": agent.logicalDeviceID, "nni-port": port})
label := fmt.Sprintf("nni-%d", port.PortNo)
- ofpPort := *port.OfpPort
+ ofpPort := proto.Clone(port.OfpPort).(*ofp.OfpPort)
ofpPort.HwAddr = append([]uint32{}, port.OfpPort.HwAddr...)
ofpPort.PortNo = port.PortNo
ofpPort.Name = label
@@ -313,7 +314,7 @@
DeviceId: deviceID,
Id: label,
DevicePortNo: port.PortNo,
- OfpPort: &ofpPort,
+ OfpPort: ofpPort,
OfpPortStats: &ofp.OfpPortStats{},
}
@@ -356,7 +357,7 @@
logger.Infow(ctx, "device-not-ready", log.Fields{"device-id": deviceID, "admin": deviceAdminState, "oper": deviceOperStatus})
return nil
}
- ofpPort := *port.OfpPort
+ ofpPort := proto.Clone(port.OfpPort).(*ofp.OfpPort)
ofpPort.HwAddr = append([]uint32{}, port.OfpPort.HwAddr...)
ofpPort.PortNo = port.PortNo
uniPort := &voltha.LogicalPort{
@@ -364,7 +365,7 @@
DeviceId: deviceID,
Id: port.Label,
DevicePortNo: port.PortNo,
- OfpPort: &ofpPort,
+ OfpPort: ofpPort,
OfpPortStats: &ofp.OfpPortStats{},
}
diff --git a/rw_core/core/device/logical_agent_test.go b/rw_core/core/device/logical_agent_test.go
index 7eba187..64a2580 100644
--- a/rw_core/core/device/logical_agent_test.go
+++ b/rw_core/core/device/logical_agent_test.go
@@ -23,7 +23,6 @@
"testing"
"time"
- "github.com/gogo/protobuf/proto"
"github.com/opencord/voltha-go/db/model"
"github.com/opencord/voltha-go/rw_core/config"
"github.com/opencord/voltha-go/rw_core/core/adapter"
@@ -39,6 +38,7 @@
"github.com/opencord/voltha-protos/v5/go/voltha"
"github.com/phayes/freeport"
"github.com/stretchr/testify/assert"
+ "google.golang.org/protobuf/proto"
)
type LDATest struct {
diff --git a/rw_core/core/device/logical_manager.go b/rw_core/core/device/logical_manager.go
index 6e009f2..0742185 100644
--- a/rw_core/core/device/logical_manager.go
+++ b/rw_core/core/device/logical_manager.go
@@ -25,7 +25,6 @@
"sync"
"time"
- "github.com/golang/protobuf/ptypes/empty"
"github.com/opencord/voltha-go/db/model"
"github.com/opencord/voltha-go/rw_core/core/device/event"
"github.com/opencord/voltha-go/rw_core/utils"
@@ -35,6 +34,7 @@
"github.com/opencord/voltha-protos/v5/go/voltha"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
+ "google.golang.org/protobuf/types/known/emptypb"
)
// LogicalManager represent logical device manager attributes
@@ -116,7 +116,7 @@
}
// ListLogicalDevices returns the list of all logical devices
-func (ldMgr *LogicalManager) ListLogicalDevices(ctx context.Context, _ *empty.Empty) (*voltha.LogicalDevices, error) {
+func (ldMgr *LogicalManager) ListLogicalDevices(ctx context.Context, _ *emptypb.Empty) (*voltha.LogicalDevices, error) {
ctx = utils.WithRPCMetadataContext(ctx, "ListLogicalDevices")
logger.Debug(ctx, "list-all-logical-devices")
@@ -493,25 +493,25 @@
}
// UpdateLogicalDeviceFlowTable updates logical device flow table
-func (ldMgr *LogicalManager) UpdateLogicalDeviceFlowTable(ctx context.Context, flow *openflow_13.FlowTableUpdate) (*empty.Empty, error) {
+func (ldMgr *LogicalManager) UpdateLogicalDeviceFlowTable(ctx context.Context, flow *openflow_13.FlowTableUpdate) (*emptypb.Empty, error) {
ctx = utils.WithRPCMetadataContext(ctx, "UpdateLogicalDeviceFlowTable")
logger.Debugw(ctx, "update-logical-device-flow-table", log.Fields{"logical-device-id": flow.Id})
agent := ldMgr.getLogicalDeviceAgent(ctx, flow.Id)
if agent == nil {
return nil, status.Errorf(codes.NotFound, "%s", flow.Id)
}
- return &empty.Empty{}, agent.updateFlowTable(ctx, flow)
+ return &emptypb.Empty{}, agent.updateFlowTable(ctx, flow)
}
// UpdateLogicalDeviceMeterTable - This function sends meter mod request to logical device manager and waits for response
-func (ldMgr *LogicalManager) UpdateLogicalDeviceMeterTable(ctx context.Context, meter *openflow_13.MeterModUpdate) (*empty.Empty, error) {
+func (ldMgr *LogicalManager) UpdateLogicalDeviceMeterTable(ctx context.Context, meter *openflow_13.MeterModUpdate) (*emptypb.Empty, error) {
ctx = utils.WithRPCMetadataContext(ctx, "UpdateLogicalDeviceMeterTable")
logger.Debugw(ctx, "update-logical-device-meter-table", log.Fields{"logical-device-id": meter.Id})
agent := ldMgr.getLogicalDeviceAgent(ctx, meter.Id)
if agent == nil {
return nil, status.Errorf(codes.NotFound, "%s", meter.Id)
}
- return &empty.Empty{}, agent.updateMeterTable(ctx, meter.MeterMod)
+ return &emptypb.Empty{}, agent.updateMeterTable(ctx, meter.MeterMod)
}
// ListLogicalDeviceMeters returns logical device meters
@@ -532,18 +532,18 @@
}
// UpdateLogicalDeviceFlowGroupTable updates logical device flow group table
-func (ldMgr *LogicalManager) UpdateLogicalDeviceFlowGroupTable(ctx context.Context, flow *openflow_13.FlowGroupTableUpdate) (*empty.Empty, error) {
+func (ldMgr *LogicalManager) UpdateLogicalDeviceFlowGroupTable(ctx context.Context, flow *openflow_13.FlowGroupTableUpdate) (*emptypb.Empty, error) {
ctx = utils.WithRPCMetadataContext(ctx, "UpdateLogicalDeviceFlowGroupTable")
logger.Debugw(ctx, "update-group-table", log.Fields{"logical-device-id": flow.Id})
agent := ldMgr.getLogicalDeviceAgent(ctx, flow.Id)
if agent == nil {
return nil, status.Errorf(codes.NotFound, "%s", flow.Id)
}
- return &empty.Empty{}, agent.updateGroupTable(ctx, flow.GroupMod)
+ return &emptypb.Empty{}, agent.updateGroupTable(ctx, flow.GroupMod)
}
// EnableLogicalDevicePort enables logical device port
-func (ldMgr *LogicalManager) EnableLogicalDevicePort(ctx context.Context, id *voltha.LogicalPortId) (*empty.Empty, error) {
+func (ldMgr *LogicalManager) EnableLogicalDevicePort(ctx context.Context, id *voltha.LogicalPortId) (*emptypb.Empty, error) {
ctx = utils.WithRPCMetadataContext(ctx, "EnableLogicalDevicePort")
logger.Debugw(ctx, "enable-logical-device-port", log.Fields{"logical-device-id": id})
agent := ldMgr.getLogicalDeviceAgent(ctx, id.Id)
@@ -554,11 +554,11 @@
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, "failed to parse %s as a number", id.PortId)
}
- return &empty.Empty{}, agent.enableLogicalPort(ctx, uint32(portNo))
+ return &emptypb.Empty{}, agent.enableLogicalPort(ctx, uint32(portNo))
}
// DisableLogicalDevicePort disables logical device port
-func (ldMgr *LogicalManager) DisableLogicalDevicePort(ctx context.Context, id *voltha.LogicalPortId) (*empty.Empty, error) {
+func (ldMgr *LogicalManager) DisableLogicalDevicePort(ctx context.Context, id *voltha.LogicalPortId) (*emptypb.Empty, error) {
ctx = utils.WithRPCMetadataContext(ctx, "DisableLogicalDevicePort")
logger.Debugw(ctx, "disable-logical-device-port", log.Fields{"logical-device-id": id})
agent := ldMgr.getLogicalDeviceAgent(ctx, id.Id)
@@ -569,7 +569,7 @@
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, "failed to parse %s as a number", id.PortId)
}
- return &empty.Empty{}, agent.disableLogicalPort(ctx, uint32(portNo))
+ return &emptypb.Empty{}, agent.disableLogicalPort(ctx, uint32(portNo))
}
func (ldMgr *LogicalManager) packetIn(ctx context.Context, logicalDeviceID string, port uint32, packet []byte) error {
diff --git a/rw_core/core/device/manager_nbi.go b/rw_core/core/device/manager_nbi.go
index 866d6dc..44b1f4f 100644
--- a/rw_core/core/device/manager_nbi.go
+++ b/rw_core/core/device/manager_nbi.go
@@ -19,7 +19,6 @@
"context"
"errors"
- "github.com/golang/protobuf/ptypes/empty"
"github.com/opencord/voltha-go/rw_core/utils"
"github.com/opencord/voltha-lib-go/v7/pkg/log"
"github.com/opencord/voltha-protos/v5/go/common"
@@ -31,6 +30,7 @@
"github.com/opencord/voltha-protos/v5/go/voltha"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
+ "google.golang.org/protobuf/types/known/emptypb"
)
// CreateDevice creates a new parent device in the data model
@@ -40,7 +40,7 @@
return &voltha.Device{}, errors.New("no-device-info-present; MAC or HOSTIP&PORT")
}
ctx = utils.WithRPCMetadataContext(ctx, "CreateDevice")
- logger.Info(ctx, "create-device", log.Fields{"device": *device})
+ logger.Info(ctx, "create-device", log.Fields{"device": device})
deviceExist, err := dMgr.isParentDeviceExist(ctx, device)
if err != nil {
@@ -66,7 +66,7 @@
}
// EnableDevice activates a device by invoking the adopt_device API on the appropriate adapter
-func (dMgr *Manager) EnableDevice(ctx context.Context, id *voltha.ID) (*empty.Empty, error) {
+func (dMgr *Manager) EnableDevice(ctx context.Context, id *voltha.ID) (*emptypb.Empty, error) {
ctx = utils.WithRPCMetadataContext(ctx, "EnableDevice")
log.EnrichSpan(ctx, log.Fields{"device-id": id.Id})
@@ -75,11 +75,11 @@
if agent == nil {
return nil, status.Errorf(codes.NotFound, "%s", id.Id)
}
- return &empty.Empty{}, agent.enableDevice(ctx)
+ return &emptypb.Empty{}, agent.enableDevice(ctx)
}
// DisableDevice disables a device along with any child device it may have
-func (dMgr *Manager) DisableDevice(ctx context.Context, id *voltha.ID) (*empty.Empty, error) {
+func (dMgr *Manager) DisableDevice(ctx context.Context, id *voltha.ID) (*emptypb.Empty, error) {
ctx = utils.WithRPCMetadataContext(ctx, "DisableDevice")
log.EnrichSpan(ctx, log.Fields{"device-id": id.Id})
@@ -88,11 +88,11 @@
if agent == nil {
return nil, status.Errorf(codes.NotFound, "%s", id.Id)
}
- return &empty.Empty{}, agent.disableDevice(ctx)
+ return &emptypb.Empty{}, agent.disableDevice(ctx)
}
// RebootDevice invoked the reboot API to the corresponding adapter
-func (dMgr *Manager) RebootDevice(ctx context.Context, id *voltha.ID) (*empty.Empty, error) {
+func (dMgr *Manager) RebootDevice(ctx context.Context, id *voltha.ID) (*emptypb.Empty, error) {
ctx = utils.WithRPCMetadataContext(ctx, "RebootDevice")
log.EnrichSpan(ctx, log.Fields{"device-id": id.Id})
@@ -112,11 +112,11 @@
return nil, status.Errorf(codes.NotFound, "device agent for parent id %s for child %s", agent.device.ParentId, id.Id)
}
}
- return &empty.Empty{}, agent.rebootDevice(ctx)
+ return &emptypb.Empty{}, agent.rebootDevice(ctx)
}
// DeleteDevice removes a device from the data model
-func (dMgr *Manager) DeleteDevice(ctx context.Context, id *voltha.ID) (*empty.Empty, error) {
+func (dMgr *Manager) DeleteDevice(ctx context.Context, id *voltha.ID) (*emptypb.Empty, error) {
ctx = utils.WithRPCMetadataContext(ctx, "DeleteDevice")
log.EnrichSpan(ctx, log.Fields{"device-id": id.Id})
@@ -130,7 +130,7 @@
switch statusErr.Code() {
case codes.NotFound:
logger.Warnw(ctx, "The device handler/device entry is not found , further clean up ", log.Fields{"device-id": id.Id, "Error": err})
- return &empty.Empty{}, nil
+ return &emptypb.Empty{}, nil
case codes.Unavailable:
logger.Errorw(ctx, "Failed to delete device", log.Fields{"device-id": id.Id, "Error": err})
return nil, err
@@ -144,11 +144,11 @@
}
}
- return &empty.Empty{}, nil
+ return &emptypb.Empty{}, nil
}
// ForceDeleteDevice removes a device from the data model forcefully without successfully waiting for the adapters.
-func (dMgr *Manager) ForceDeleteDevice(ctx context.Context, id *voltha.ID) (*empty.Empty, error) {
+func (dMgr *Manager) ForceDeleteDevice(ctx context.Context, id *voltha.ID) (*emptypb.Empty, error) {
ctx = utils.WithRPCMetadataContext(ctx, "ForceDeleteDevice")
log.EnrichSpan(ctx, log.Fields{"device-id": id.Id})
@@ -157,11 +157,11 @@
if agent == nil {
return nil, status.Errorf(codes.NotFound, "%s", id.Id)
}
- return &empty.Empty{}, agent.deleteDeviceForce(ctx)
+ return &emptypb.Empty{}, agent.deleteDeviceForce(ctx)
}
// ListDevices retrieves the latest devices from the data model
-func (dMgr *Manager) ListDevices(ctx context.Context, _ *empty.Empty) (*voltha.Devices, error) {
+func (dMgr *Manager) ListDevices(ctx context.Context, _ *emptypb.Empty) (*voltha.Devices, error) {
ctx = utils.WithRPCMetadataContext(ctx, "ListDevices")
logger.Debug(ctx, "list-devices")
@@ -177,7 +177,7 @@
}
// ListDeviceIds retrieves the latest device IDs information from the data model (memory data only)
-func (dMgr *Manager) ListDeviceIds(ctx context.Context, _ *empty.Empty) (*voltha.IDs, error) {
+func (dMgr *Manager) ListDeviceIds(ctx context.Context, _ *emptypb.Empty) (*voltha.IDs, error) {
ctx = utils.WithRPCMetadataContext(ctx, "ListDeviceIds")
logger.Debug(ctx, "list-device-ids")
@@ -187,7 +187,7 @@
// ReconcileDevices is a request to a voltha core to update its list of managed devices. This will
// trigger loading the devices along with their children and parent in memory
-func (dMgr *Manager) ReconcileDevices(ctx context.Context, ids *voltha.IDs) (*empty.Empty, error) {
+func (dMgr *Manager) ReconcileDevices(ctx context.Context, ids *voltha.IDs) (*emptypb.Empty, error) {
ctx = utils.WithRPCMetadataContext(ctx, "ReconcileDevices")
numDevices := 0
@@ -213,7 +213,7 @@
} else {
return nil, status.Errorf(codes.InvalidArgument, "empty-list-of-ids")
}
- return &empty.Empty{}, nil
+ return &emptypb.Empty{}, nil
}
// GetDevice exists primarily to implement the gRPC interface.
@@ -787,7 +787,7 @@
// UpdateDevicePmConfigs updates the PM configs. This is executed when the northbound gRPC API is invoked, typically
// following a user action
-func (dMgr *Manager) UpdateDevicePmConfigs(ctx context.Context, configs *voltha.PmConfigs) (*empty.Empty, error) {
+func (dMgr *Manager) UpdateDevicePmConfigs(ctx context.Context, configs *voltha.PmConfigs) (*emptypb.Empty, error) {
ctx = utils.WithRPCMetadataContext(ctx, "UpdateDevicePmConfigs")
log.EnrichSpan(ctx, log.Fields{"device-id": configs.Id})
@@ -798,7 +798,7 @@
if agent == nil {
return nil, status.Errorf(codes.NotFound, "%s", configs.Id)
}
- return &empty.Empty{}, agent.updatePmConfigs(ctx, configs)
+ return &emptypb.Empty{}, agent.updatePmConfigs(ctx, configs)
}
// ListDeviceFlows returns the flow details for a specific device entry
@@ -838,7 +838,7 @@
return &ofp.FlowGroups{Items: ret}, nil
}
-func (dMgr *Manager) EnablePort(ctx context.Context, port *voltha.Port) (*empty.Empty, error) {
+func (dMgr *Manager) EnablePort(ctx context.Context, port *voltha.Port) (*emptypb.Empty, error) {
ctx = utils.WithRPCMetadataContext(ctx, "EnablePort")
log.EnrichSpan(ctx, log.Fields{"device-id": port.DeviceId})
@@ -847,10 +847,10 @@
if agent == nil {
return nil, status.Errorf(codes.NotFound, "%s", port.DeviceId)
}
- return &empty.Empty{}, agent.enablePort(ctx, port.PortNo)
+ return &emptypb.Empty{}, agent.enablePort(ctx, port.PortNo)
}
-func (dMgr *Manager) DisablePort(ctx context.Context, port *voltha.Port) (*empty.Empty, error) {
+func (dMgr *Manager) DisablePort(ctx context.Context, port *voltha.Port) (*emptypb.Empty, error) {
ctx = utils.WithRPCMetadataContext(ctx, "DisablePort")
log.EnrichSpan(ctx, log.Fields{"device-id": port.DeviceId})
@@ -859,7 +859,7 @@
if agent == nil {
return nil, status.Errorf(codes.NotFound, "%s", port.DeviceId)
}
- return &empty.Empty{}, agent.disablePort(ctx, port.PortNo)
+ return &emptypb.Empty{}, agent.disablePort(ctx, port.PortNo)
}
func (dMgr *Manager) GetExtValue(ctx context.Context, value *extension.ValueSpecifier) (*extension.ReturnValues, error) {
@@ -888,7 +888,7 @@
}
// SetExtValue set some given configs or value
-func (dMgr *Manager) SetExtValue(ctx context.Context, value *extension.ValueSet) (*empty.Empty, error) {
+func (dMgr *Manager) SetExtValue(ctx context.Context, value *extension.ValueSet) (*emptypb.Empty, error) {
ctx = utils.WithRPCMetadataContext(ctx, "SetExtValue")
logger.Info(ctx, "set-ext-value", log.Fields{"onu-id": value.Id})
@@ -936,23 +936,23 @@
return &common.OperationResp{Code: common.OperationResp_OPERATION_SUCCESS}, nil
}
-func (dMgr *Manager) PutVoipUserProfile(ctx context.Context, voipUserProfileRequest *voip_user_profile.VoipUserProfileRequest) (*empty.Empty, error) {
+func (dMgr *Manager) PutVoipUserProfile(ctx context.Context, voipUserProfileRequest *voip_user_profile.VoipUserProfileRequest) (*emptypb.Empty, error) {
return nil, status.Error(codes.Unimplemented, "put-voip-user-profile-not-implemented")
}
-func (dMgr *Manager) DeleteVoipUserProfile(ctx context.Context, key *common.Key) (*empty.Empty, error) {
+func (dMgr *Manager) DeleteVoipUserProfile(ctx context.Context, key *common.Key) (*emptypb.Empty, error) {
return nil, status.Error(codes.Unimplemented, "delete-voip-user-profile-not-implemented")
}
-func (dMgr *Manager) PutVoipSystemProfile(ctx context.Context, voipSystemProfileRequest *voip_system_profile.VoipSystemProfileRequest) (*empty.Empty, error) {
+func (dMgr *Manager) PutVoipSystemProfile(ctx context.Context, voipSystemProfileRequest *voip_system_profile.VoipSystemProfileRequest) (*emptypb.Empty, error) {
return nil, status.Error(codes.Unimplemented, "put-voip-system-profile-not-implemented")
}
-func (dMgr *Manager) DeleteVoipSystemProfile(ctx context.Context, key *common.Key) (*empty.Empty, error) {
+func (dMgr *Manager) DeleteVoipSystemProfile(ctx context.Context, key *common.Key) (*emptypb.Empty, error) {
return nil, status.Error(codes.Unimplemented, "delete-voip-system-profile-not-implemented")
}
-func (dMgr *Manager) DisableOnuDevice(ctx context.Context, id *voltha.ID) (*empty.Empty, error) {
+func (dMgr *Manager) DisableOnuDevice(ctx context.Context, id *voltha.ID) (*emptypb.Empty, error) {
ctx = utils.WithRPCMetadataContext(ctx, "DisableOnuDevice")
log.EnrichSpan(ctx, log.Fields{"device-id": id.Id})
@@ -967,10 +967,10 @@
return nil, status.Errorf(codes.NotFound, "%s", agent.device.ParentId)
}
logger.Debugw(ctx, "serial-no to be diabled", log.Fields{"serial-number": agent.device.SerialNumber})
- return &empty.Empty{}, agent.disableOnuDevice(ctx, oltAgent.adapterEndpoint)
+ return &emptypb.Empty{}, agent.disableOnuDevice(ctx, oltAgent.adapterEndpoint)
}
-func (dMgr *Manager) EnableOnuDevice(ctx context.Context, id *voltha.ID) (*empty.Empty, error) {
+func (dMgr *Manager) EnableOnuDevice(ctx context.Context, id *voltha.ID) (*emptypb.Empty, error) {
ctx = utils.WithRPCMetadataContext(ctx, "EnableOnuDevice")
log.EnrichSpan(ctx, log.Fields{"device-id": id.Id})
@@ -985,10 +985,10 @@
return nil, status.Errorf(codes.NotFound, "%s", agent.device.ParentId)
}
logger.Debugw(ctx, "serial-no to be enabled", log.Fields{"serial-number": agent.device.SerialNumber})
- return &empty.Empty{}, agent.enableOnuDevice(ctx, oltAgent.adapterEndpoint)
+ return &emptypb.Empty{}, agent.enableOnuDevice(ctx, oltAgent.adapterEndpoint)
}
-func (dMgr *Manager) DisableOnuSerialNumber(ctx context.Context, device *voltha.OnuSerialNumberOnOLTPon) (*empty.Empty, error) {
+func (dMgr *Manager) DisableOnuSerialNumber(ctx context.Context, device *voltha.OnuSerialNumberOnOLTPon) (*emptypb.Empty, error) {
ctx = utils.WithRPCMetadataContext(ctx, "DisableOnuSerialNumber")
log.EnrichSpan(ctx, log.Fields{"device-id": device.OltDeviceId})
@@ -1007,10 +1007,10 @@
if agent == nil {
return nil, status.Errorf(codes.NotFound, "%s", onuDeviceID)
}
- return &empty.Empty{}, agent.disableOnuSerialNumber(ctx, device, oltAgent.adapterEndpoint)
+ return &emptypb.Empty{}, agent.disableOnuSerialNumber(ctx, device, oltAgent.adapterEndpoint)
}
-func (dMgr *Manager) EnableOnuSerialNumber(ctx context.Context, device *voltha.OnuSerialNumberOnOLTPon) (*empty.Empty, error) {
+func (dMgr *Manager) EnableOnuSerialNumber(ctx context.Context, device *voltha.OnuSerialNumberOnOLTPon) (*emptypb.Empty, error) {
ctx = utils.WithRPCMetadataContext(ctx, "EnableOnuSerialNumber")
log.EnrichSpan(ctx, log.Fields{"device-id": device.OltDeviceId})
@@ -1030,11 +1030,11 @@
return nil, status.Errorf(codes.NotFound, "%s", onuDeviceID)
}
- return &empty.Empty{}, agent.enableOnuSerialNumber(ctx, device, oltAgent.adapterEndpoint)
+ return &emptypb.Empty{}, agent.enableOnuSerialNumber(ctx, device, oltAgent.adapterEndpoint)
}
// UpdateDevice updates the configuration of a device, such as changing the IP address of an OLT device.
-func (dMgr *Manager) UpdateDevice(ctx context.Context, config *voltha.UpdateDevice) (*empty.Empty, error) {
+func (dMgr *Manager) UpdateDevice(ctx context.Context, config *voltha.UpdateDevice) (*emptypb.Empty, error) {
ctx = utils.WithRPCMetadataContext(ctx, "UpdateDevice")
log.EnrichSpan(ctx, log.Fields{"device-id": config.Id})
@@ -1070,5 +1070,5 @@
return nil, status.Error(codes.InvalidArgument, "device-update-only-supported-for-olt-devices")
}
- return &empty.Empty{}, agent.updateDevice(ctx, config)
+ return &emptypb.Empty{}, agent.updateDevice(ctx, config)
}
diff --git a/rw_core/core/device/manager_sbi.go b/rw_core/core/device/manager_sbi.go
index 8af1d15..c229c4e 100644
--- a/rw_core/core/device/manager_sbi.go
+++ b/rw_core/core/device/manager_sbi.go
@@ -20,7 +20,6 @@
"fmt"
"time"
- "github.com/golang/protobuf/ptypes/empty"
"github.com/opencord/voltha-go/rw_core/utils"
"github.com/opencord/voltha-lib-go/v7/pkg/log"
"github.com/opencord/voltha-protos/v5/go/common"
@@ -30,9 +29,10 @@
"github.com/opencord/voltha-protos/v5/go/voltha"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
+ "google.golang.org/protobuf/types/known/emptypb"
)
-func (dMgr *Manager) PortCreated(ctx context.Context, port *voltha.Port) (*empty.Empty, error) {
+func (dMgr *Manager) PortCreated(ctx context.Context, port *voltha.Port) (*emptypb.Empty, error) {
ctx = utils.WithNewSpanAndRPCMetadataContext(ctx, "PortCreated")
logger.Debugw(ctx, "port-created", log.Fields{"port": port})
@@ -48,12 +48,12 @@
logger.Errorw(ctx, "unable-to-add-peer-port", log.Fields{"error": err, "device-id": port.DeviceId})
}
- return &empty.Empty{}, nil
+ return &emptypb.Empty{}, nil
}
return nil, status.Errorf(codes.NotFound, "%s", port.DeviceId)
}
-func (dMgr *Manager) DeviceUpdate(ctx context.Context, device *voltha.Device) (*empty.Empty, error) {
+func (dMgr *Manager) DeviceUpdate(ctx context.Context, device *voltha.Device) (*emptypb.Empty, error) {
ctx = utils.WithNewSpanAndRPCMetadataContext(ctx, "DeviceUpdate")
logger.Debugw(ctx, "device-update", log.Fields{"device-id": device.Id, "device": device})
@@ -61,12 +61,12 @@
if err := agent.updateDeviceUsingAdapterData(ctx, device); err != nil {
return nil, err
}
- return &empty.Empty{}, nil
+ return &emptypb.Empty{}, nil
}
return nil, status.Errorf(codes.NotFound, "%s", device.Id)
}
-func (dMgr *Manager) DeviceStateUpdate(ctx context.Context, ds *ca.DeviceStateFilter) (*empty.Empty, error) {
+func (dMgr *Manager) DeviceStateUpdate(ctx context.Context, ds *ca.DeviceStateFilter) (*emptypb.Empty, error) {
ctx = utils.WithNewSpanAndRPCMetadataContext(ctx, "DeviceStateUpdate")
logger.Debugw(ctx, "device-state-update", log.Fields{"device-id": ds.DeviceId, "operStatus": ds.OperStatus, "connStatus": ds.ConnStatus})
@@ -74,7 +74,7 @@
if err := agent.updateDeviceStatus(ctx, ds.OperStatus, ds.ConnStatus); err != nil {
return nil, err
}
- return &empty.Empty{}, nil
+ return &emptypb.Empty{}, nil
}
return nil, status.Errorf(codes.NotFound, "%s", ds.DeviceId)
}
@@ -230,7 +230,7 @@
}
// PortsStateUpdate updates the operational status of all ports on the device
-func (dMgr *Manager) PortsStateUpdate(ctx context.Context, ps *ca.PortStateFilter) (*empty.Empty, error) {
+func (dMgr *Manager) PortsStateUpdate(ctx context.Context, ps *ca.PortStateFilter) (*emptypb.Empty, error) {
ctx = utils.WithNewSpanAndRPCMetadataContext(ctx, "PortsStateUpdate")
logger.Debugw(ctx, "ports-state-update", log.Fields{"device-id": ps.DeviceId})
@@ -245,12 +245,12 @@
logger.Warnw(ctx, "ports-state-update-failed", log.Fields{"device-id": ps.DeviceId, "error": err})
return nil, err
}
- return &empty.Empty{}, nil
+ return &emptypb.Empty{}, nil
}
// ChildDevicesLost is invoked by an adapter to indicate that a parent device is in a state (Disabled) where it
// cannot manage the child devices. This will trigger the Core to disable all the child devices.
-func (dMgr *Manager) ChildDevicesLost(ctx context.Context, parentID *common.ID) (*empty.Empty, error) {
+func (dMgr *Manager) ChildDevicesLost(ctx context.Context, parentID *common.ID) (*emptypb.Empty, error) {
ctx = utils.WithNewSpanAndRPCMetadataContext(ctx, "ChildDevicesLost")
logger.Debugw(ctx, "child-devices-lost", log.Fields{"parent-id": parentID.Id})
@@ -262,12 +262,12 @@
if err = dMgr.DisableAllChildDevices(ctx, parentDevice); err != nil {
return nil, err
}
- return &empty.Empty{}, nil
+ return &emptypb.Empty{}, nil
}
// ChildDevicesDetected is invoked by an adapter when child devices are found, typically after after a
// disable/enable sequence. This will trigger the Core to Enable all the child devices of that parent.
-func (dMgr *Manager) ChildDevicesDetected(ctx context.Context, parentDeviceID *common.ID) (*empty.Empty, error) {
+func (dMgr *Manager) ChildDevicesDetected(ctx context.Context, parentDeviceID *common.ID) (*emptypb.Empty, error) {
ctx = utils.WithNewSpanAndRPCMetadataContext(ctx, "ChildDevicesDetected")
logger.Debugw(ctx, "child-devices-detected", log.Fields{"parent-device-id": parentDeviceID})
@@ -295,7 +295,7 @@
if !allChildEnableRequestSent {
return nil, err
}
- return &empty.Empty{}, nil
+ return &emptypb.Empty{}, nil
}
// GetChildDeviceWithProxyAddress will return a device based on proxy address
@@ -347,7 +347,7 @@
return dMgr.getAllChildDevices(ctx, parentDeviceID.Id)
}
-func (dMgr *Manager) ChildrenStateUpdate(ctx context.Context, ds *ca.DeviceStateFilter) (*empty.Empty, error) {
+func (dMgr *Manager) ChildrenStateUpdate(ctx context.Context, ds *ca.DeviceStateFilter) (*emptypb.Empty, error) {
ctx = utils.WithNewSpanAndRPCMetadataContext(ctx, "ChildrenStateUpdate")
logger.Debugw(ctx, "children-state-update", log.Fields{"parent-device-id": ds.ParentDeviceId, "operStatus": ds.OperStatus, "connStatus": ds.ConnStatus})
@@ -358,10 +358,10 @@
}
}
}
- return &empty.Empty{}, nil
+ return &emptypb.Empty{}, nil
}
-func (dMgr *Manager) PortStateUpdate(ctx context.Context, ps *ca.PortState) (*empty.Empty, error) {
+func (dMgr *Manager) PortStateUpdate(ctx context.Context, ps *ca.PortState) (*emptypb.Empty, error) {
ctx = utils.WithNewSpanAndRPCMetadataContext(ctx, "PortStateUpdate")
logger.Debugw(ctx, "port-state-update", log.Fields{"device-id": ps.DeviceId, "portType": ps.PortType, "portNo": ps.PortNo, "operStatus": ps.OperStatus})
@@ -386,12 +386,12 @@
}
}()
}
- return &empty.Empty{}, nil
+ return &emptypb.Empty{}, nil
}
return nil, status.Errorf(codes.NotFound, "%s", ps.DeviceId)
}
-func (dMgr *Manager) DeleteAllPorts(ctx context.Context, deviceID *common.ID) (*empty.Empty, error) {
+func (dMgr *Manager) DeleteAllPorts(ctx context.Context, deviceID *common.ID) (*emptypb.Empty, error) {
ctx = utils.WithNewSpanAndRPCMetadataContext(ctx, "DeleteAllPorts")
logger.Debugw(ctx, "delete-all-ports", log.Fields{"device-id": deviceID.Id})
@@ -413,7 +413,7 @@
logger.Warnw(ctx, "failed-to-retrieve-device", log.Fields{"device-id": deviceID.Id})
return nil, err
}
- return &empty.Empty{}, nil
+ return &emptypb.Empty{}, nil
}
return nil, status.Errorf(codes.NotFound, "%s", deviceID.Id)
}
@@ -431,7 +431,7 @@
}
// DevicePMConfigUpdate updates the pm configs as defined by the adapter.
-func (dMgr *Manager) DevicePMConfigUpdate(ctx context.Context, pc *voltha.PmConfigs) (*empty.Empty, error) {
+func (dMgr *Manager) DevicePMConfigUpdate(ctx context.Context, pc *voltha.PmConfigs) (*emptypb.Empty, error) {
ctx = utils.WithNewSpanAndRPCMetadataContext(ctx, "DevicePMConfigUpdate")
logger.Debugw(ctx, "device-pm-config-update", log.Fields{"device-id": pc.Id})
@@ -442,13 +442,13 @@
if err := agent.initPmConfigs(ctx, pc); err != nil {
return nil, err
}
- return &empty.Empty{}, nil
+ return &emptypb.Empty{}, nil
}
return nil, status.Errorf(codes.NotFound, "%s", pc.Id)
}
// SendPacketIn receives packetIn request from adapter
-func (dMgr *Manager) SendPacketIn(ctx context.Context, pi *ca.PacketIn) (*empty.Empty, error) {
+func (dMgr *Manager) SendPacketIn(ctx context.Context, pi *ca.PacketIn) (*emptypb.Empty, error) {
ctx = utils.WithNewSpanAndRPCMetadataContext(ctx, "SendPacketIn")
logger.Debugw(ctx, "packet-in", log.Fields{"device-id": pi.DeviceId, "port": pi.Port})
@@ -467,10 +467,10 @@
if err := dMgr.logicalDeviceMgr.packetIn(ctx, device.ParentId, pi.Port, pi.Packet); err != nil {
return nil, err
}
- return &empty.Empty{}, nil
+ return &emptypb.Empty{}, nil
}
-func (dMgr *Manager) DeviceReasonUpdate(ctx context.Context, dr *ca.DeviceReason) (*empty.Empty, error) {
+func (dMgr *Manager) DeviceReasonUpdate(ctx context.Context, dr *ca.DeviceReason) (*emptypb.Empty, error) {
ctx = utils.WithNewSpanAndRPCMetadataContext(ctx, "DeviceReasonUpdate")
logger.Debugw(ctx, "update-device-reason", log.Fields{"device-id": dr.DeviceId, "reason": dr.Reason})
@@ -478,12 +478,12 @@
if err := agent.updateDeviceReason(ctx, dr.Reason); err != nil {
return nil, err
}
- return &empty.Empty{}, nil
+ return &emptypb.Empty{}, nil
}
return nil, status.Errorf(codes.NotFound, "%s", dr.DeviceId)
}
-func (dMgr *Manager) ReconcileChildDevices(ctx context.Context, parentDeviceID *common.ID) (*empty.Empty, error) {
+func (dMgr *Manager) ReconcileChildDevices(ctx context.Context, parentDeviceID *common.ID) (*emptypb.Empty, error) {
ctx = utils.WithNewSpanAndRPCMetadataContext(ctx, "ReconcileChildDevices")
logger.Debugw(ctx, "reconcile-child-devices", log.Fields{"device-id": parentDeviceID.Id})
@@ -497,10 +497,10 @@
return true
})
logger.Debugw(ctx, "reconciling-child-devices-initiated", log.Fields{"parent-device-id": parentDeviceID.Id, "number-of-child-devices-to-reconcile": numberOfDevicesToReconcile})
- return &empty.Empty{}, nil
+ return &emptypb.Empty{}, nil
}
-func (dMgr *Manager) UpdateImageDownload(ctx context.Context, img *voltha.ImageDownload) (*empty.Empty, error) {
+func (dMgr *Manager) UpdateImageDownload(ctx context.Context, img *voltha.ImageDownload) (*emptypb.Empty, error) {
ctx = utils.WithNewSpanAndRPCMetadataContext(ctx, "UpdateImageDownload")
log.EnrichSpan(ctx, log.Fields{"device-id": img.Id})
@@ -514,7 +514,7 @@
} else {
return nil, status.Errorf(codes.NotFound, "%s", img.Id)
}
- return &empty.Empty{}, nil
+ return &emptypb.Empty{}, nil
}
func (dMgr *Manager) GetHealthStatus(stream core_service.CoreService_GetHealthStatusServer) error {
diff --git a/rw_core/core/device/manager_test.go_todo b/rw_core/core/device/manager_test.go_todo
deleted file mode 100644
index 8a55da1..0000000
--- a/rw_core/core/device/manager_test.go_todo
+++ /dev/null
@@ -1,887 +0,0 @@
-/*
- * Copyright 2019-2024 Open Networking Foundation (ONF) and the ONF Contributors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package device
-
-import (
- "context"
- "reflect"
- "strconv"
- "testing"
-
- "github.com/golang/mock/gomock"
- "github.com/golang/protobuf/ptypes"
- "github.com/golang/protobuf/ptypes/any"
- "github.com/opencord/voltha-go/db/model"
- "github.com/opencord/voltha-go/rw_core/config"
- "github.com/opencord/voltha-go/rw_core/core/adapter"
- tst "github.com/opencord/voltha-go/rw_core/test"
- "github.com/opencord/voltha-lib-go/v7/pkg/db"
- "github.com/opencord/voltha-lib-go/v7/pkg/events"
- "github.com/opencord/voltha-lib-go/v7/pkg/kafka"
- "github.com/opencord/voltha-protos/v5/go/common"
- "github.com/opencord/voltha-protos/v5/go/voltha"
- "github.com/phayes/freeport"
- "github.com/stretchr/testify/assert"
-)
-
-const (
- version = "dummy-version"
- url = "http://127.0.0.1:2222/dummy-image"
- vendor = "dummy"
-
- numberOfTestDevices = 10
-)
-
-func initialiseTest(ctx context.Context, t *testing.T) (*DATest, *MockInterContainerProxy, []*Agent) {
- dat := newDATest(ctx)
-
- controller := gomock.NewController(t)
- mockICProxy := NewMockInterContainerProxy(controller)
-
- // Set expectations for the mock
- mockICProxy.EXPECT().Start(gomock.Any()).AnyTimes().Return(nil)
- mockICProxy.EXPECT().SubscribeWithDefaultRequestHandler(gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes().Return(nil)
-
- dat.startCoreWithCustomICProxy(ctx, mockICProxy)
-
- var agents []*Agent
- for i := 1; i <= numberOfTestDevices; i++ {
- if agent := dat.createDeviceAgent(t); agent != nil {
- agents = append(agents, agent)
- }
- }
-
- assert.Equal(t, len(agents), numberOfTestDevices)
-
- dat.oltAdapter, dat.onuAdapter = tst.CreateAndregisterAdapters(ctx,
- t,
- dat.kClient,
- dat.coreInstanceID,
- dat.oltAdapterName,
- dat.onuAdapterName,
- dat.adapterMgr)
-
- return dat, mockICProxy, agents
-}
-
-func (dat *DATest) startCoreWithCustomICProxy(ctx context.Context, kmp kafka.InterContainerProxy) {
- cfg := &config.RWCoreFlags{}
- cfg.ParseCommandArguments([]string{})
- cfg.CoreTopic = "rw_core"
- cfg.EventTopic = "voltha.events"
- cfg.DefaultRequestTimeout = dat.defaultTimeout
- cfg.KVStoreAddress = "127.0.0.1" + ":" + strconv.Itoa(dat.kvClientPort)
- grpcPort, err := freeport.GetFreePort()
- if err != nil {
- logger.Fatal(ctx, "Cannot get a freeport for grpc")
- }
- cfg.GrpcAddress = "127.0.0.1" + ":" + strconv.Itoa(grpcPort)
- client := tst.SetupKVClient(ctx, cfg, dat.coreInstanceID)
- backend := &db.Backend{
- Client: client,
- StoreType: cfg.KVStoreType,
- Address: cfg.KVStoreAddress,
- Timeout: cfg.KVStoreTimeout,
- LivenessChannelInterval: cfg.LiveProbeInterval / 2}
-
- dat.kmp = kmp
-
- endpointMgr := kafka.NewEndpointManager(backend)
- proxy := model.NewDBPath(backend)
- dat.adapterMgr = adapter.NewAdapterManager(ctx, proxy, dat.coreInstanceID, dat.kClient)
- eventProxy := events.NewEventProxy(events.MsgClient(dat.kEventClient), events.MsgTopic(kafka.Topic{Name: cfg.EventTopic}))
- dat.deviceMgr, dat.logicalDeviceMgr = NewManagers(proxy, dat.adapterMgr, dat.kmp, endpointMgr, cfg, dat.coreInstanceID, eventProxy)
- dat.adapterMgr.Start(context.Background())
- if err = dat.kmp.Start(ctx); err != nil {
- logger.Fatal(ctx, "Cannot start InterContainerProxy")
- }
-
- if err := dat.kmp.SubscribeWithDefaultRequestHandler(ctx, kafka.Topic{Name: cfg.CoreTopic}, kafka.OffsetNewest); err != nil {
- logger.Fatalf(ctx, "Cannot add default request handler: %s", err)
- }
-
-}
-
-func TestManager_DownloadImageToDevice(t *testing.T) {
- type args struct {
- ctx context.Context
- request *voltha.DeviceImageDownloadRequest
- }
-
- ctx := context.Background()
- dat, mockICProxy, agents := initialiseTest(ctx, t)
-
- tests := []struct {
- name string
- args args
- want *voltha.DeviceImageResponse
- wantErr bool
- }{
- {
- name: "request-for-single-device",
- args: args{
- ctx: ctx,
- request: newDeviceImageDownloadRequest(agents[:1]),
- },
- want: newImageResponse(agents[:1], voltha.ImageState_DOWNLOAD_REQUESTED, voltha.ImageState_IMAGE_DOWNLOADING, voltha.ImageState_NO_ERROR),
- wantErr: false,
- },
- {
- name: "request-for-multiple-devices",
- args: args{
- ctx: ctx,
- request: newDeviceImageDownloadRequest(agents),
- },
- want: newImageResponse(agents, voltha.ImageState_DOWNLOAD_REQUESTED, voltha.ImageState_IMAGE_DOWNLOADING, voltha.ImageState_NO_ERROR),
- wantErr: false,
- },
- }
-
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- if tt.name == "request-for-single-device" {
- chnl := make(chan *kafka.RpcResponse, 10)
- // Set expectation for the API invocation
- mockICProxy.EXPECT().InvokeAsyncRPC(gomock.Any(),
- "Download_onu_image",
- gomock.Any(),
- gomock.Any(),
- true,
- gomock.Any(), gomock.Any()).Return(chnl)
- // Send the expected response to channel from a goroutine
- go func() {
- reply := newImageDownloadAdapterResponse(t, agents[0].deviceID, voltha.ImageState_DOWNLOAD_REQUESTED, voltha.ImageState_IMAGE_DOWNLOADING, voltha.ImageState_NO_ERROR)
-
- chnl <- &kafka.RpcResponse{
- MType: kafka.RpcSent,
- Err: nil,
- Reply: reply,
- }
-
- chnl <- &kafka.RpcResponse{
- MType: kafka.RpcReply,
- Err: nil,
- Reply: reply,
- }
- }()
- } else if tt.name == "request-for-multiple-devices" {
- // Map to store per device kafka response channel
- kafkaRespChans := make(map[string]chan *kafka.RpcResponse)
- for _, id := range tt.args.request.DeviceId {
- // Create a kafka response channel per device
- chnl := make(chan *kafka.RpcResponse)
-
- // Set expectation for the API invocation
- mockICProxy.EXPECT().InvokeAsyncRPC(gomock.Any(),
- "Download_onu_image",
- gomock.Any(),
- gomock.Any(),
- true,
- id.Id, gomock.Any()).Return(chnl)
-
- kafkaRespChans[id.Id] = chnl
- }
-
- // Send the expected response to channel from a goroutine
- go func() {
- for _, agent := range agents {
- reply := newImageDownloadAdapterResponse(t, agent.deviceID, voltha.ImageState_DOWNLOAD_REQUESTED, voltha.ImageState_IMAGE_DOWNLOADING, voltha.ImageState_NO_ERROR)
-
- kafkaRespChans[agent.deviceID] <- &kafka.RpcResponse{
- MType: kafka.RpcSent,
- Err: nil,
- Reply: reply,
- }
-
- kafkaRespChans[agent.deviceID] <- &kafka.RpcResponse{
- MType: kafka.RpcReply,
- Err: nil,
- Reply: reply,
- }
- }
- }()
- }
-
- got, err := dat.deviceMgr.DownloadImageToDevice(tt.args.ctx, tt.args.request)
- if (err != nil) != tt.wantErr {
- t.Errorf("DownloadImageToDevice() error = %v, wantErr %v", err, tt.wantErr)
- return
- }
-
- if !gotAllSuccess(got, tt.want) {
- t.Errorf("DownloadImageToDevice() got = %v, want = %v", got, tt.want)
- }
- })
- }
-}
-
-func TestManager_GetImageStatus(t *testing.T) {
- type args struct {
- ctx context.Context
- request *voltha.DeviceImageRequest
- }
-
- ctx := context.Background()
- dat, mockICProxy, agents := initialiseTest(ctx, t)
-
- tests := []struct {
- name string
- args args
- want *voltha.DeviceImageResponse
- wantErr bool
- }{
- {
- name: "request-for-single-device",
- args: args{
- ctx: ctx,
- request: newDeviceImagedRequest(agents[:1]),
- },
- want: newImageResponse(agents[:1], voltha.ImageState_DOWNLOAD_REQUESTED, voltha.ImageState_IMAGE_DOWNLOADING, voltha.ImageState_NO_ERROR),
- wantErr: false,
- },
- {
- name: "request-for-multiple-devices",
- args: args{
- ctx: ctx,
- request: newDeviceImagedRequest(agents),
- },
- want: newImageResponse(agents, voltha.ImageState_DOWNLOAD_REQUESTED, voltha.ImageState_IMAGE_DOWNLOADING, voltha.ImageState_NO_ERROR),
- wantErr: false,
- },
- }
-
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- if tt.name == "request-for-single-device" {
- chnl := make(chan *kafka.RpcResponse, 10)
- // Set expectation for the API invocation
- mockICProxy.EXPECT().InvokeAsyncRPC(gomock.Any(),
- "Get_onu_image_status",
- gomock.Any(),
- gomock.Any(),
- true,
- gomock.Any(), gomock.Any()).Return(chnl)
- // Send the expected response to channel from a goroutine
- go func() {
- reply := newImageStatusAdapterResponse(t, agents[:1], voltha.ImageState_DOWNLOAD_REQUESTED, voltha.ImageState_IMAGE_DOWNLOADING, voltha.ImageState_NO_ERROR)
-
- chnl <- &kafka.RpcResponse{
- MType: kafka.RpcSent,
- Err: nil,
- Reply: reply,
- }
-
- chnl <- &kafka.RpcResponse{
- MType: kafka.RpcReply,
- Err: nil,
- Reply: reply,
- }
- }()
- } else if tt.name == "request-for-multiple-devices" {
- // Map to store per device kafka response channel
- kafkaRespChans := make(map[string]chan *kafka.RpcResponse)
- for _, id := range tt.args.request.DeviceId {
- // Create a kafka response channel per device
- chnl := make(chan *kafka.RpcResponse)
-
- // Set expectation for the API invocation
- mockICProxy.EXPECT().InvokeAsyncRPC(gomock.Any(),
- "Get_onu_image_status",
- gomock.Any(),
- gomock.Any(),
- true,
- id.Id, gomock.Any()).Return(chnl)
-
- kafkaRespChans[id.Id] = chnl
- }
-
- // Send the expected response to channel from a goroutine
- go func() {
- for _, agent := range agents {
- reply := newImageStatusAdapterResponse(t, agents, voltha.ImageState_DOWNLOAD_REQUESTED, voltha.ImageState_IMAGE_DOWNLOADING, voltha.ImageState_NO_ERROR)
-
- kafkaRespChans[agent.deviceID] <- &kafka.RpcResponse{
- MType: kafka.RpcSent,
- Err: nil,
- Reply: reply,
- }
-
- kafkaRespChans[agent.deviceID] <- &kafka.RpcResponse{
- MType: kafka.RpcReply,
- Err: nil,
- Reply: reply,
- }
- }
- }()
- }
-
- got, err := dat.deviceMgr.GetImageStatus(tt.args.ctx, tt.args.request)
- if (err != nil) != tt.wantErr {
- t.Errorf("GetImageStatus() error = %v, wantErr %v", err, tt.wantErr)
- return
- }
-
- if !gotAllSuccess(got, tt.want) {
- t.Errorf("GetImageStatus() got = %v, want %v", got, tt.want)
- }
- })
- }
-}
-
-func TestManager_AbortImageUpgradeToDevice(t *testing.T) {
-
- type args struct {
- ctx context.Context
- request *voltha.DeviceImageRequest
- }
-
- ctx := context.Background()
- dat, mockICProxy, agents := initialiseTest(ctx, t)
-
- tests := []struct {
- name string
- args args
- want *voltha.DeviceImageResponse
- wantErr bool
- }{
- {
- name: "request-for-single-device",
- args: args{
- ctx: ctx,
- request: newDeviceImagedRequest(agents[:1]),
- },
- want: newImageResponse(agents[:1], voltha.ImageState_DOWNLOAD_CANCELLED, voltha.ImageState_IMAGE_ACTIVATION_ABORTED, voltha.ImageState_NO_ERROR),
- wantErr: false,
- },
- {
- name: "request-for-multiple-devices",
- args: args{
- ctx: ctx,
- request: newDeviceImagedRequest(agents[:1]),
- },
- want: newImageResponse(agents, voltha.ImageState_DOWNLOAD_CANCELLED, voltha.ImageState_IMAGE_ACTIVATION_ABORTED, voltha.ImageState_NO_ERROR),
- wantErr: false,
- },
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- if tt.name == "request-for-single-device" {
- chnl := make(chan *kafka.RpcResponse, 10)
- // Set expectation for the API invocation
- mockICProxy.EXPECT().InvokeAsyncRPC(gomock.Any(),
- "Abort_onu_image_upgrade",
- gomock.Any(),
- gomock.Any(),
- true,
- gomock.Any(), gomock.Any()).Return(chnl)
- // Send the expected response to channel from a goroutine
- go func() {
- reply := newImageStatusAdapterResponse(t, agents[:1], voltha.ImageState_DOWNLOAD_CANCELLED, voltha.ImageState_IMAGE_ACTIVATION_ABORTED, voltha.ImageState_NO_ERROR)
-
- chnl <- &kafka.RpcResponse{
- MType: kafka.RpcSent,
- Err: nil,
- Reply: reply,
- }
-
- chnl <- &kafka.RpcResponse{
- MType: kafka.RpcReply,
- Err: nil,
- Reply: reply,
- }
- }()
- } else if tt.name == "request-for-multiple-devices" {
- // Map to store per device kafka response channel
- kafkaRespChans := make(map[string]chan *kafka.RpcResponse)
- for _, id := range tt.args.request.DeviceId {
- // Create a kafka response channel per device
- chnl := make(chan *kafka.RpcResponse)
-
- // Set expectation for the API invocation
- mockICProxy.EXPECT().InvokeAsyncRPC(gomock.Any(),
- "Abort_onu_image_upgrade",
- gomock.Any(),
- gomock.Any(),
- true,
- id.Id, gomock.Any()).Return(chnl)
-
- kafkaRespChans[id.Id] = chnl
- }
-
- // Send the expected response to channel from a goroutine
- go func() {
- for _, agent := range agents {
- reply := newImageStatusAdapterResponse(t, agents, voltha.ImageState_DOWNLOAD_CANCELLED, voltha.ImageState_IMAGE_ACTIVATION_ABORTED, voltha.ImageState_NO_ERROR)
-
- kafkaRespChans[agent.deviceID] <- &kafka.RpcResponse{
- MType: kafka.RpcSent,
- Err: nil,
- Reply: reply,
- }
-
- kafkaRespChans[agent.deviceID] <- &kafka.RpcResponse{
- MType: kafka.RpcReply,
- Err: nil,
- Reply: reply,
- }
- }
- }()
- }
- got, err := dat.deviceMgr.AbortImageUpgradeToDevice(tt.args.ctx, tt.args.request)
- if (err != nil) != tt.wantErr {
- t.Errorf("AbortImageUpgradeToDevice() error = %v, wantErr %v", err, tt.wantErr)
- return
- }
-
- if !gotAllSuccess(got, tt.want) {
- t.Errorf("AbortImageUpgradeToDevice() got = %v, want %v", got, tt.want)
- }
- })
- }
-}
-
-func TestManager_ActivateImage(t *testing.T) {
- type args struct {
- ctx context.Context
- request *voltha.DeviceImageRequest
- }
-
- ctx := context.Background()
- dat, mockICProxy, agents := initialiseTest(ctx, t)
-
- tests := []struct {
- name string
- args args
- want *voltha.DeviceImageResponse
- wantErr bool
- }{
- {
- name: "request-for-single-device",
- args: args{
- ctx: ctx,
- request: newDeviceImagedRequest(agents[:1]),
- },
- want: newImageResponse(agents[:1], voltha.ImageState_DOWNLOAD_SUCCEEDED, voltha.ImageState_IMAGE_ACTIVATING, voltha.ImageState_NO_ERROR),
- wantErr: false,
- },
- {
- name: "request-for-multiple-devices",
- args: args{
- ctx: ctx,
- request: newDeviceImagedRequest(agents),
- },
- want: newImageResponse(agents, voltha.ImageState_DOWNLOAD_SUCCEEDED, voltha.ImageState_IMAGE_ACTIVATING, voltha.ImageState_NO_ERROR),
- wantErr: false,
- },
- }
-
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- if tt.name == "request-for-single-device" {
- chnl := make(chan *kafka.RpcResponse, 10)
- // Set expectation for the API invocation
- mockICProxy.EXPECT().InvokeAsyncRPC(gomock.Any(),
- "Activate_onu_image",
- gomock.Any(),
- gomock.Any(),
- true,
- gomock.Any(), gomock.Any()).Return(chnl)
- // Send the expected response to channel from a goroutine
- go func() {
- reply := newImageStatusAdapterResponse(t, agents[:1], voltha.ImageState_DOWNLOAD_SUCCEEDED, voltha.ImageState_IMAGE_ACTIVATING, voltha.ImageState_NO_ERROR)
-
- chnl <- &kafka.RpcResponse{
- MType: kafka.RpcSent,
- Err: nil,
- Reply: reply,
- }
-
- chnl <- &kafka.RpcResponse{
- MType: kafka.RpcReply,
- Err: nil,
- Reply: reply,
- }
- }()
- } else if tt.name == "request-for-multiple-devices" {
- // Map to store per device kafka response channel
- kafkaRespChans := make(map[string]chan *kafka.RpcResponse)
- for _, id := range tt.args.request.DeviceId {
- // Create a kafka response channel per device
- chnl := make(chan *kafka.RpcResponse)
-
- // Set expectation for the API invocation
- mockICProxy.EXPECT().InvokeAsyncRPC(gomock.Any(),
- "Activate_onu_image",
- gomock.Any(),
- gomock.Any(),
- true,
- id.Id, gomock.Any()).Return(chnl)
-
- kafkaRespChans[id.Id] = chnl
- }
-
- // Send the expected response to channel from a goroutine
- go func() {
- for _, agent := range agents {
- reply := newImageStatusAdapterResponse(t, agents, voltha.ImageState_DOWNLOAD_SUCCEEDED, voltha.ImageState_IMAGE_ACTIVATING, voltha.ImageState_NO_ERROR)
-
- kafkaRespChans[agent.deviceID] <- &kafka.RpcResponse{
- MType: kafka.RpcSent,
- Err: nil,
- Reply: reply,
- }
-
- kafkaRespChans[agent.deviceID] <- &kafka.RpcResponse{
- MType: kafka.RpcReply,
- Err: nil,
- Reply: reply,
- }
- }
- }()
- }
- got, err := dat.deviceMgr.ActivateImage(tt.args.ctx, tt.args.request)
- if (err != nil) != tt.wantErr {
- t.Errorf("ActivateImage() error = %v, wantErr %v", err, tt.wantErr)
- return
- }
- if !gotAllSuccess(got, tt.want) {
- t.Errorf("ActivateImage() got = %v, want %v", got, tt.want)
- }
- })
- }
-}
-
-func TestManager_CommitImage(t *testing.T) {
- type args struct {
- ctx context.Context
- request *voltha.DeviceImageRequest
- }
-
- ctx := context.Background()
- dat, mockICProxy, agents := initialiseTest(ctx, t)
-
- tests := []struct {
- name string
- args args
- want *voltha.DeviceImageResponse
- wantErr bool
- }{
- {
- name: "request-for-single-device",
- args: args{
- ctx: ctx,
- request: newDeviceImagedRequest(agents[:1]),
- },
- want: newImageResponse(agents[:1], voltha.ImageState_DOWNLOAD_SUCCEEDED, voltha.ImageState_IMAGE_COMMITTING, voltha.ImageState_NO_ERROR),
- wantErr: false,
- },
- {
- name: "request-for-multiple-devices",
- args: args{
- ctx: ctx,
- request: newDeviceImagedRequest(agents),
- },
- want: newImageResponse(agents, voltha.ImageState_DOWNLOAD_SUCCEEDED, voltha.ImageState_IMAGE_COMMITTING, voltha.ImageState_NO_ERROR),
- wantErr: false,
- },
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- if tt.name == "request-for-single-device" {
- chnl := make(chan *kafka.RpcResponse, 10)
- // Set expectation for the API invocation
- mockICProxy.EXPECT().InvokeAsyncRPC(gomock.Any(),
- "Commit_onu_image",
- gomock.Any(),
- gomock.Any(),
- true,
- gomock.Any(), gomock.Any()).Return(chnl)
- // Send the expected response to channel from a goroutine
- go func() {
- reply := newImageStatusAdapterResponse(t, agents[:1], voltha.ImageState_DOWNLOAD_SUCCEEDED, voltha.ImageState_IMAGE_COMMITTING, voltha.ImageState_NO_ERROR)
-
- chnl <- &kafka.RpcResponse{
- MType: kafka.RpcSent,
- Err: nil,
- Reply: reply,
- }
-
- chnl <- &kafka.RpcResponse{
- MType: kafka.RpcReply,
- Err: nil,
- Reply: reply,
- }
- }()
- } else if tt.name == "request-for-multiple-devices" {
- // Map to store per device kafka response channel
- kafkaRespChans := make(map[string]chan *kafka.RpcResponse)
- for _, id := range tt.args.request.DeviceId {
- // Create a kafka response channel per device
- chnl := make(chan *kafka.RpcResponse)
-
- // Set expectation for the API invocation
- mockICProxy.EXPECT().InvokeAsyncRPC(gomock.Any(),
- "Commit_onu_image",
- gomock.Any(),
- gomock.Any(),
- true,
- id.Id, gomock.Any()).Return(chnl)
-
- kafkaRespChans[id.Id] = chnl
- }
-
- // Send the expected response to channel from a goroutine
- go func() {
- for _, agent := range agents {
- reply := newImageStatusAdapterResponse(t, agents, voltha.ImageState_DOWNLOAD_SUCCEEDED, voltha.ImageState_IMAGE_COMMITTING, voltha.ImageState_NO_ERROR)
-
- kafkaRespChans[agent.deviceID] <- &kafka.RpcResponse{
- MType: kafka.RpcSent,
- Err: nil,
- Reply: reply,
- }
-
- kafkaRespChans[agent.deviceID] <- &kafka.RpcResponse{
- MType: kafka.RpcReply,
- Err: nil,
- Reply: reply,
- }
- }
- }()
- }
- got, err := dat.deviceMgr.CommitImage(tt.args.ctx, tt.args.request)
- if (err != nil) != tt.wantErr {
- t.Errorf("CommitImage() error = %v, wantErr %v", err, tt.wantErr)
- return
- }
- if !gotAllSuccess(got, tt.want) {
- t.Errorf("CommitImage() got = %v, want %v", got, tt.want)
- }
- })
- }
-}
-
-func TestManager_GetOnuImages(t *testing.T) {
- type args struct {
- ctx context.Context
- id *common.ID
- }
-
- ctx := context.Background()
- dat, mockICProxy, agents := initialiseTest(ctx, t)
-
- tests := []struct {
- name string
- args args
- want *voltha.OnuImages
- wantErr bool
- }{
- {
- name: "request-for-single-device",
- args: args{
- ctx: ctx,
- id: &common.ID{
- Id: agents[0].deviceID,
- },
- },
- want: &voltha.OnuImages{
- Items: []*voltha.OnuImage{{
- Version: version,
- IsCommited: true,
- IsActive: true,
- IsValid: true,
- }},
- },
- wantErr: false,
- },
- }
-
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- if tt.name == "request-for-single-device" {
- chnl := make(chan *kafka.RpcResponse, 10)
- // Set expectation for the API invocation
- mockICProxy.EXPECT().InvokeAsyncRPC(gomock.Any(),
- "Get_onu_images",
- gomock.Any(),
- gomock.Any(),
- true,
- gomock.Any(), gomock.Any()).Return(chnl)
- // Send the expected response to channel from a goroutine
- go func() {
- reply := newOnuImagesResponse(t)
- chnl <- &kafka.RpcResponse{
- MType: kafka.RpcSent,
- Err: nil,
- Reply: reply,
- }
-
- chnl <- &kafka.RpcResponse{
- MType: kafka.RpcReply,
- Err: nil,
- Reply: reply,
- }
- }()
- }
-
- got, err := dat.deviceMgr.GetOnuImages(tt.args.ctx, tt.args.id)
- if (err != nil) != tt.wantErr {
- t.Errorf("GetOnuImages() error = %v, wantErr %v", err, tt.wantErr)
- return
- }
- if !reflect.DeepEqual(got, tt.want) {
- t.Errorf("GetOnuImages() got = %v, want %v", got, tt.want)
- }
- })
- }
-}
-
-// verify that we got all the wanted response (order not important)
-func gotAllSuccess(got, want *voltha.DeviceImageResponse) bool {
- for _, imagestateGot := range got.DeviceImageStates {
- found := false
- for _, imageStateWant := range want.DeviceImageStates {
- if reflect.DeepEqual(imagestateGot, imageStateWant) {
- found = true
- }
- }
-
- if !found {
- return false
- }
- }
-
- return true
-}
-
-func newDeviceImagedRequest(agents []*Agent) *voltha.DeviceImageRequest {
- imgReq := &voltha.DeviceImageRequest{
- Version: version,
- CommitOnSuccess: true,
- }
-
- for _, agent := range agents {
- if agent != nil {
- imgReq.DeviceId = append(imgReq.DeviceId, &common.ID{
- Id: agent.deviceID,
- })
- }
- }
-
- return imgReq
-}
-
-func newDeviceImageDownloadRequest(agents []*Agent) *voltha.DeviceImageDownloadRequest {
- imgDownReq := &voltha.DeviceImageDownloadRequest{
- Image: &voltha.Image{
- Version: version,
- Url: url,
- Vendor: vendor,
- },
- ActivateOnSuccess: true,
- CommitOnSuccess: true,
- }
-
- for _, agent := range agents {
- if agent != nil {
- imgDownReq.DeviceId = append(imgDownReq.DeviceId, &common.ID{
- Id: agent.deviceID,
- })
- }
- }
-
- return imgDownReq
-}
-
-func newImageResponse(agents []*Agent,
- downloadState voltha.ImageState_ImageDownloadState,
- imageSate voltha.ImageState_ImageActivationState,
- reason voltha.ImageState_ImageFailureReason) *voltha.DeviceImageResponse {
- response := &voltha.DeviceImageResponse{}
-
- for _, agent := range agents {
- response.DeviceImageStates = append(response.DeviceImageStates, &voltha.DeviceImageState{
- DeviceId: agent.deviceID,
- ImageState: &voltha.ImageState{
- Version: version,
- DownloadState: downloadState,
- Reason: reason,
- ImageState: imageSate,
- },
- })
- }
-
- return response
-}
-
-func newImageDownloadAdapterResponse(t *testing.T,
- deviceID string,
- downloadState voltha.ImageState_ImageDownloadState,
- imageSate voltha.ImageState_ImageActivationState,
- reason voltha.ImageState_ImageFailureReason) *any.Any {
- reply, err := ptypes.MarshalAny(&voltha.DeviceImageResponse{
- DeviceImageStates: []*voltha.DeviceImageState{{
- DeviceId: deviceID,
- ImageState: &voltha.ImageState{
- Version: version,
- DownloadState: downloadState,
- Reason: reason,
- ImageState: imageSate,
- },
- }},
- })
- assert.Nil(t, err)
- return reply
-}
-
-func newImageStatusAdapterResponse(t *testing.T,
- agents []*Agent,
- downloadState voltha.ImageState_ImageDownloadState,
- imageSate voltha.ImageState_ImageActivationState,
- reason voltha.ImageState_ImageFailureReason) *any.Any {
- imgResponse := &voltha.DeviceImageResponse{}
- for _, agent := range agents {
- imgResponse.DeviceImageStates = append(imgResponse.DeviceImageStates, &voltha.DeviceImageState{
- DeviceId: agent.deviceID,
- ImageState: &voltha.ImageState{
- Version: version,
- DownloadState: downloadState,
- Reason: reason,
- ImageState: imageSate,
- },
- })
- }
-
- reply, err := ptypes.MarshalAny(imgResponse)
- assert.Nil(t, err)
- return reply
-}
-
-func newOnuImagesResponse(t *testing.T) *any.Any {
- onuImages := &voltha.OnuImages{
- Items: []*voltha.OnuImage{{
- Version: version,
- IsCommited: true,
- IsActive: true,
- IsValid: true,
- }},
- }
-
- reply, err := ptypes.MarshalAny(onuImages)
- assert.Nil(t, err)
- return reply
-}
diff --git a/rw_core/core/device/mock_kafka.go b/rw_core/core/device/mock_kafka.go
index de99eab..c87dae5 100644
--- a/rw_core/core/device/mock_kafka.go
+++ b/rw_core/core/device/mock_kafka.go
@@ -25,7 +25,7 @@
reflect "reflect"
gomock "github.com/golang/mock/gomock"
- any "github.com/golang/protobuf/ptypes/any"
+ anypb "google.golang.org/protobuf/types/known/anypb"
kafka "github.com/opencord/voltha-lib-go/v7/pkg/kafka"
)
@@ -54,7 +54,7 @@
// DeleteTopic mocks base method.
func (m *MockInterContainerProxy) DeleteTopic(arg0 context.Context, arg1 kafka.Topic) error {
- m.ctrl.T.Helper()
+
ret := m.ctrl.Call(m, "DeleteTopic", arg0, arg1)
ret0, _ := ret[0].(error)
return ret0
@@ -62,13 +62,13 @@
// DeleteTopic indicates an expected call of DeleteTopic.
func (mr *MockInterContainerProxyMockRecorder) DeleteTopic(arg0, arg1 interface{}) *gomock.Call {
- mr.mock.ctrl.T.Helper()
+
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteTopic", reflect.TypeOf((*MockInterContainerProxy)(nil).DeleteTopic), arg0, arg1)
}
// EnableLivenessChannel mocks base method.
func (m *MockInterContainerProxy) EnableLivenessChannel(arg0 context.Context, arg1 bool) chan bool {
- m.ctrl.T.Helper()
+
ret := m.ctrl.Call(m, "EnableLivenessChannel", arg0, arg1)
ret0, _ := ret[0].(chan bool)
return ret0
@@ -76,13 +76,13 @@
// EnableLivenessChannel indicates an expected call of EnableLivenessChannel.
func (mr *MockInterContainerProxyMockRecorder) EnableLivenessChannel(arg0, arg1 interface{}) *gomock.Call {
- mr.mock.ctrl.T.Helper()
+
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EnableLivenessChannel", reflect.TypeOf((*MockInterContainerProxy)(nil).EnableLivenessChannel), arg0, arg1)
}
// GetDefaultTopic mocks base method.
func (m *MockInterContainerProxy) GetDefaultTopic() *kafka.Topic {
- m.ctrl.T.Helper()
+
ret := m.ctrl.Call(m, "GetDefaultTopic")
ret0, _ := ret[0].(*kafka.Topic)
return ret0
@@ -90,13 +90,13 @@
// GetDefaultTopic indicates an expected call of GetDefaultTopic.
func (mr *MockInterContainerProxyMockRecorder) GetDefaultTopic() *gomock.Call {
- mr.mock.ctrl.T.Helper()
+
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetDefaultTopic", reflect.TypeOf((*MockInterContainerProxy)(nil).GetDefaultTopic))
}
// InvokeAsyncRPC mocks base method.
func (m *MockInterContainerProxy) InvokeAsyncRPC(arg0 context.Context, arg1 string, arg2, arg3 *kafka.Topic, arg4 bool, arg5 string, arg6 ...*kafka.KVArg) chan *kafka.RpcResponse {
- m.ctrl.T.Helper()
+
varargs := []interface{}{arg0, arg1, arg2, arg3, arg4, arg5}
for _, a := range arg6 {
varargs = append(varargs, a)
@@ -108,34 +108,34 @@
// InvokeAsyncRPC indicates an expected call of InvokeAsyncRPC.
func (mr *MockInterContainerProxyMockRecorder) InvokeAsyncRPC(arg0, arg1, arg2, arg3, arg4, arg5 interface{}, arg6 ...interface{}) *gomock.Call {
- mr.mock.ctrl.T.Helper()
+
varargs := append([]interface{}{arg0, arg1, arg2, arg3, arg4, arg5}, arg6...)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InvokeAsyncRPC", reflect.TypeOf((*MockInterContainerProxy)(nil).InvokeAsyncRPC), varargs...)
}
// InvokeRPC mocks base method.
-func (m *MockInterContainerProxy) InvokeRPC(arg0 context.Context, arg1 string, arg2, arg3 *kafka.Topic, arg4 bool, arg5 string, arg6 ...*kafka.KVArg) (bool, *any.Any) {
- m.ctrl.T.Helper()
+func (m *MockInterContainerProxy) InvokeRPC(arg0 context.Context, arg1 string, arg2, arg3 *kafka.Topic, arg4 bool, arg5 string, arg6 ...*kafka.KVArg) (bool, *anypb.Any) {
+
varargs := []interface{}{arg0, arg1, arg2, arg3, arg4, arg5}
for _, a := range arg6 {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "InvokeRPC", varargs...)
ret0, _ := ret[0].(bool)
- ret1, _ := ret[1].(*any.Any)
+ ret1, _ := ret[1].(*anypb.Any)
return ret0, ret1
}
// InvokeRPC indicates an expected call of InvokeRPC.
func (mr *MockInterContainerProxyMockRecorder) InvokeRPC(arg0, arg1, arg2, arg3, arg4, arg5 interface{}, arg6 ...interface{}) *gomock.Call {
- mr.mock.ctrl.T.Helper()
+
varargs := append([]interface{}{arg0, arg1, arg2, arg3, arg4, arg5}, arg6...)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InvokeRPC", reflect.TypeOf((*MockInterContainerProxy)(nil).InvokeRPC), varargs...)
}
// SendLiveness mocks base method.
func (m *MockInterContainerProxy) SendLiveness(arg0 context.Context) error {
- m.ctrl.T.Helper()
+
ret := m.ctrl.Call(m, "SendLiveness", arg0)
ret0, _ := ret[0].(error)
return ret0
@@ -149,7 +149,7 @@
// Start mocks base method.
func (m *MockInterContainerProxy) Start(arg0 context.Context) error {
- m.ctrl.T.Helper()
+
ret := m.ctrl.Call(m, "Start", arg0)
ret0, _ := ret[0].(error)
return ret0
@@ -157,25 +157,25 @@
// Start indicates an expected call of Start.
func (mr *MockInterContainerProxyMockRecorder) Start(arg0 interface{}) *gomock.Call {
- mr.mock.ctrl.T.Helper()
+
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Start", reflect.TypeOf((*MockInterContainerProxy)(nil).Start), arg0)
}
// Stop mocks base method.
func (m *MockInterContainerProxy) Stop(arg0 context.Context) {
- m.ctrl.T.Helper()
+
m.ctrl.Call(m, "Stop", arg0)
}
// Stop indicates an expected call of Stop.
func (mr *MockInterContainerProxyMockRecorder) Stop(arg0 interface{}) *gomock.Call {
- mr.mock.ctrl.T.Helper()
+
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Stop", reflect.TypeOf((*MockInterContainerProxy)(nil).Stop), arg0)
}
// SubscribeWithDefaultRequestHandler mocks base method.
func (m *MockInterContainerProxy) SubscribeWithDefaultRequestHandler(arg0 context.Context, arg1 kafka.Topic, arg2 int64) error {
- m.ctrl.T.Helper()
+
ret := m.ctrl.Call(m, "SubscribeWithDefaultRequestHandler", arg0, arg1, arg2)
ret0, _ := ret[0].(error)
return ret0
@@ -183,13 +183,13 @@
// SubscribeWithDefaultRequestHandler indicates an expected call of SubscribeWithDefaultRequestHandler.
func (mr *MockInterContainerProxyMockRecorder) SubscribeWithDefaultRequestHandler(arg0, arg1, arg2 interface{}) *gomock.Call {
- mr.mock.ctrl.T.Helper()
+
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubscribeWithDefaultRequestHandler", reflect.TypeOf((*MockInterContainerProxy)(nil).SubscribeWithDefaultRequestHandler), arg0, arg1, arg2)
}
// SubscribeWithRequestHandlerInterface mocks base method.
func (m *MockInterContainerProxy) SubscribeWithRequestHandlerInterface(arg0 context.Context, arg1 kafka.Topic, arg2 interface{}) error {
- m.ctrl.T.Helper()
+
ret := m.ctrl.Call(m, "SubscribeWithRequestHandlerInterface", arg0, arg1, arg2)
ret0, _ := ret[0].(error)
return ret0
@@ -197,13 +197,13 @@
// SubscribeWithRequestHandlerInterface indicates an expected call of SubscribeWithRequestHandlerInterface.
func (mr *MockInterContainerProxyMockRecorder) SubscribeWithRequestHandlerInterface(arg0, arg1, arg2 interface{}) *gomock.Call {
- mr.mock.ctrl.T.Helper()
+
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubscribeWithRequestHandlerInterface", reflect.TypeOf((*MockInterContainerProxy)(nil).SubscribeWithRequestHandlerInterface), arg0, arg1, arg2)
}
// UnSubscribeFromRequestHandler mocks base method.
func (m *MockInterContainerProxy) UnSubscribeFromRequestHandler(arg0 context.Context, arg1 kafka.Topic) error {
- m.ctrl.T.Helper()
+
ret := m.ctrl.Call(m, "UnSubscribeFromRequestHandler", arg0, arg1)
ret0, _ := ret[0].(error)
return ret0
@@ -211,6 +211,6 @@
// UnSubscribeFromRequestHandler indicates an expected call of UnSubscribeFromRequestHandler.
func (mr *MockInterContainerProxyMockRecorder) UnSubscribeFromRequestHandler(arg0, arg1 interface{}) *gomock.Call {
- mr.mock.ctrl.T.Helper()
+
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UnSubscribeFromRequestHandler", reflect.TypeOf((*MockInterContainerProxy)(nil).UnSubscribeFromRequestHandler), arg0, arg1)
}
diff --git a/rw_core/flowdecomposition/flow_decomposer.go b/rw_core/flowdecomposition/flow_decomposer.go
index 6d33a14..e9ef397 100644
--- a/rw_core/flowdecomposition/flow_decomposer.go
+++ b/rw_core/flowdecomposition/flow_decomposer.go
@@ -20,7 +20,6 @@
"context"
"fmt"
- "github.com/gogo/protobuf/proto"
"github.com/opencord/voltha-go/rw_core/route"
fu "github.com/opencord/voltha-lib-go/v7/pkg/flows"
"github.com/opencord/voltha-lib-go/v7/pkg/log"
@@ -28,6 +27,7 @@
"github.com/opencord/voltha-protos/v5/go/voltha"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
+ "google.golang.org/protobuf/proto"
)
// FlowDecomposer represent flow decomposer attribute
@@ -534,7 +534,7 @@
logger.Debugw(ctx, "process-multicast-flow", log.Fields{"flows": flow})
deviceRules = fd.processMulticastFlow(ctx, path, inPortNo, outPortNo, flow, grpID, groupMap)
} else {
- return deviceRules, status.Errorf(codes.Aborted, "unknown downstream flow %v", *flow)
+ return deviceRules, status.Errorf(codes.Aborted, "unknown downstream flow %v", flow)
}
}
deviceRules, err = fd.updateOutputPortForControllerBoundFlowForParentDevice(ctx, deviceRules)
diff --git a/rw_core/mocks/adapter.go b/rw_core/mocks/adapter.go
index 80465c8..88aed63 100644
--- a/rw_core/mocks/adapter.go
+++ b/rw_core/mocks/adapter.go
@@ -24,7 +24,6 @@
"sync"
"time"
- "github.com/golang/protobuf/ptypes/empty"
vgrpc "github.com/opencord/voltha-lib-go/v7/pkg/grpc"
"github.com/opencord/voltha-lib-go/v7/pkg/log"
"github.com/opencord/voltha-lib-go/v7/pkg/probe"
@@ -33,6 +32,7 @@
"github.com/opencord/voltha-protos/v5/go/core_service"
"github.com/opencord/voltha-protos/v5/go/health"
"google.golang.org/grpc"
+ "google.golang.org/protobuf/types/known/emptypb"
ca "github.com/opencord/voltha-protos/v5/go/core_adapter"
"github.com/opencord/voltha-protos/v5/go/extension"
@@ -72,6 +72,7 @@
// Adapter represents adapter attributes
type Adapter struct {
+ adapter_service.UnimplementedAdapterServiceServer
flows map[string]map[uint64]*openflow_13.OfpFlowStats
devices map[string]*voltha.Device
failFlowAdd map[string]bool
@@ -183,15 +184,15 @@
// Device
-func (ta *Adapter) AdoptDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) {
- return &empty.Empty{}, nil
+func (ta *Adapter) AdoptDevice(ctx context.Context, device *voltha.Device) (*emptypb.Empty, error) {
+ return &emptypb.Empty{}, nil
}
-func (ta *Adapter) ReconcileDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) {
- return &empty.Empty{}, nil
+func (ta *Adapter) ReconcileDevice(ctx context.Context, device *voltha.Device) (*emptypb.Empty, error) {
+ return &emptypb.Empty{}, nil
}
-func (ta *Adapter) DeleteDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) {
+func (ta *Adapter) DeleteDevice(ctx context.Context, device *voltha.Device) (*emptypb.Empty, error) {
ta.failDeleteDeviceLock.RLock()
haveToFail, ok := ta.failDeleteDevice[device.Id]
if ok && haveToFail {
@@ -203,27 +204,27 @@
ta.RemoveDevice(device.Id)
}
logger.Debugw(ctx, "device-deleted-in-adapter", log.Fields{"device-id": device.Id})
- return &empty.Empty{}, nil
+ return &emptypb.Empty{}, nil
}
-func (ta *Adapter) DisableDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) {
- return &empty.Empty{}, nil
+func (ta *Adapter) DisableDevice(ctx context.Context, device *voltha.Device) (*emptypb.Empty, error) {
+ return &emptypb.Empty{}, nil
}
-func (ta *Adapter) ReEnableDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) {
- return &empty.Empty{}, nil
+func (ta *Adapter) ReEnableDevice(ctx context.Context, device *voltha.Device) (*emptypb.Empty, error) {
+ return &emptypb.Empty{}, nil
}
-func (ta *Adapter) RebootDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) {
- return &empty.Empty{}, nil
+func (ta *Adapter) RebootDevice(ctx context.Context, device *voltha.Device) (*emptypb.Empty, error) {
+ return &emptypb.Empty{}, nil
}
-func (ta *Adapter) SelfTestDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) {
- return &empty.Empty{}, nil
+func (ta *Adapter) SelfTestDevice(ctx context.Context, device *voltha.Device) (*emptypb.Empty, error) {
+ return &emptypb.Empty{}, nil
}
-func (ta *Adapter) ChildDeviceLost(ctx context.Context, device *voltha.Device) (*empty.Empty, error) {
- return &empty.Empty{}, nil
+func (ta *Adapter) ChildDeviceLost(ctx context.Context, device *voltha.Device) (*emptypb.Empty, error) {
+ return &emptypb.Empty{}, nil
}
func (ta *Adapter) GetOfpDeviceInfo(ctx context.Context, device *voltha.Device) (*ca.SwitchCapability, error) {
@@ -232,20 +233,20 @@
// Ports
-func (ta *Adapter) EnablePort(ctx context.Context, port *voltha.Port) (*empty.Empty, error) {
- return &empty.Empty{}, nil
+func (ta *Adapter) EnablePort(ctx context.Context, port *voltha.Port) (*emptypb.Empty, error) {
+ return &emptypb.Empty{}, nil
}
-func (ta *Adapter) DisablePort(ctx context.Context, port *voltha.Port) (*empty.Empty, error) {
- return &empty.Empty{}, nil
+func (ta *Adapter) DisablePort(ctx context.Context, port *voltha.Port) (*emptypb.Empty, error) {
+ return &emptypb.Empty{}, nil
}
// Flows
-func (ta *Adapter) UpdateFlowsBulk(ctx context.Context, flows *ca.BulkFlows) (*empty.Empty, error) {
- return &empty.Empty{}, nil
+func (ta *Adapter) UpdateFlowsBulk(ctx context.Context, flows *ca.BulkFlows) (*emptypb.Empty, error) {
+ return &emptypb.Empty{}, nil
}
-func (ta *Adapter) UpdateFlowsIncrementally(ctx context.Context, incrFlows *ca.IncrementalFlows) (*empty.Empty, error) {
+func (ta *Adapter) UpdateFlowsIncrementally(ctx context.Context, incrFlows *ca.IncrementalFlows) (*emptypb.Empty, error) {
ta.flowLock.Lock()
defer ta.flowLock.Unlock()
@@ -275,17 +276,17 @@
delete(ta.flows[incrFlows.Device.Id], f.Id)
}
}
- return &empty.Empty{}, nil
+ return &emptypb.Empty{}, nil
}
// Packets
-func (ta *Adapter) SendPacketOut(ctx context.Context, packet *ca.PacketOut) (*empty.Empty, error) {
- return &empty.Empty{}, nil
+func (ta *Adapter) SendPacketOut(ctx context.Context, packet *ca.PacketOut) (*emptypb.Empty, error) {
+ return &emptypb.Empty{}, nil
}
// PM
-func (ta *Adapter) UpdatePmConfig(ctx context.Context, configs *ca.PmConfigsInfo) (*empty.Empty, error) {
- return &empty.Empty{}, nil
+func (ta *Adapter) UpdatePmConfig(ctx context.Context, configs *ca.PmConfigsInfo) (*emptypb.Empty, error) {
+ return &emptypb.Empty{}, nil
}
// Image
@@ -340,12 +341,12 @@
}
// Events
-func (ta *Adapter) SuppressEvent(ctx context.Context, filter *voltha.EventFilter) (*empty.Empty, error) {
- return &empty.Empty{}, nil
+func (ta *Adapter) SuppressEvent(ctx context.Context, filter *voltha.EventFilter) (*emptypb.Empty, error) {
+ return &emptypb.Empty{}, nil
}
-func (ta *Adapter) UnSuppressEvent(ctx context.Context, filter *voltha.EventFilter) (*empty.Empty, error) {
- return &empty.Empty{}, nil
+func (ta *Adapter) UnSuppressEvent(ctx context.Context, filter *voltha.EventFilter) (*emptypb.Empty, error) {
+ return &emptypb.Empty{}, nil
}
func (ta *Adapter) SimulateAlarm(context.Context, *ca.SimulateAlarmMessage) (*common.OperationResp, error) {
@@ -356,8 +357,8 @@
return &extension.ReturnValues{}, nil
}
-func (ta *Adapter) SetExtValue(context.Context, *ca.SetExtValueMessage) (*empty.Empty, error) {
- return &empty.Empty{}, nil
+func (ta *Adapter) SetExtValue(context.Context, *ca.SetExtValueMessage) (*emptypb.Empty, error) {
+ return &emptypb.Empty{}, nil
}
func (ta *Adapter) GetSingleValue(context.Context, *extension.SingleGetValueRequest) (*extension.SingleGetValueResponse, error) {
diff --git a/rw_core/mocks/adapter_olt.go b/rw_core/mocks/adapter_olt.go
index eddaaf7..3e0b7fb 100644
--- a/rw_core/mocks/adapter_olt.go
+++ b/rw_core/mocks/adapter_olt.go
@@ -24,7 +24,6 @@
"strings"
"time"
- "github.com/golang/protobuf/ptypes/empty"
"github.com/opencord/voltha-lib-go/v7/pkg/probe"
"github.com/opencord/voltha-protos/v5/go/adapter_service"
"github.com/opencord/voltha-protos/v5/go/common"
@@ -32,14 +31,15 @@
"github.com/opencord/voltha-protos/v5/go/health"
"github.com/opencord/voltha-protos/v5/go/omci"
"github.com/phayes/freeport"
+ "google.golang.org/protobuf/types/known/emptypb"
- "github.com/gogo/protobuf/proto"
com "github.com/opencord/voltha-lib-go/v7/pkg/adapters/common"
vgrpc "github.com/opencord/voltha-lib-go/v7/pkg/grpc"
"github.com/opencord/voltha-lib-go/v7/pkg/log"
ca "github.com/opencord/voltha-protos/v5/go/core_adapter"
of "github.com/opencord/voltha-protos/v5/go/openflow_13"
"github.com/opencord/voltha-protos/v5/go/voltha"
+ "google.golang.org/protobuf/proto"
)
// OLTAdapter represent OLT adapter
@@ -126,7 +126,7 @@
}
// Adopt_device creates new handler for added device
-func (oltA *OLTAdapter) AdoptDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) {
+func (oltA *OLTAdapter) AdoptDevice(ctx context.Context, device *voltha.Device) (*emptypb.Empty, error) {
logger.Debugw(ctx, "AdoptDevice", log.Fields{"device": device.AdapterEndpoint, "device-type": oltA.DeviceType})
go func() {
d := proto.Clone(device).(*voltha.Device)
@@ -210,12 +210,12 @@
}(i)
}
}()
- return &empty.Empty{}, nil
+ return &emptypb.Empty{}, nil
}
// Single_get_value_request retrieves a single value.
func (oltA *OLTAdapter) Single_get_value_request(ctx context.Context, // nolint
- request extension.SingleGetValueRequest) (*extension.SingleGetValueResponse, error) {
+ request *extension.SingleGetValueRequest) (*extension.SingleGetValueResponse, error) {
logger.Fatalf(ctx, "Single_get_value_request unimplemented")
return nil, nil
}
@@ -243,7 +243,7 @@
}
// Disable_device disables device
-func (oltA *OLTAdapter) DisableDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) { // nolint
+func (oltA *OLTAdapter) DisableDevice(ctx context.Context, device *voltha.Device) (*emptypb.Empty, error) { // nolint
go func() {
if d := oltA.getDevice(device.Id); d == nil {
logger.Fatalf(ctx, "device-not-found-%s", device.Id)
@@ -287,11 +287,11 @@
logger.Warnw(ctx, "lost-notif-of-child-devices-failed", log.Fields{"device-id": device.Id, "error": err})
}
}()
- return &empty.Empty{}, nil
+ return &emptypb.Empty{}, nil
}
// Reenable_device reenables device
-func (oltA *OLTAdapter) ReEnableDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) { // nolint
+func (oltA *OLTAdapter) ReEnableDevice(ctx context.Context, device *voltha.Device) (*emptypb.Empty, error) { // nolint
go func() {
if d := oltA.getDevice(device.Id); d == nil {
logger.Fatalf(ctx, "device-not-found-%s", device.Id)
@@ -332,11 +332,11 @@
logger.Fatalf(ctx, "detection-notif-of-child-devices-failed", log.Fields{"device-id": device.Id, "error": err})
}
}()
- return &empty.Empty{}, nil
+ return &emptypb.Empty{}, nil
}
// Enable_port -
-func (oltA *OLTAdapter) EnablePort(ctx context.Context, port *voltha.Port) (*empty.Empty, error) { //nolint
+func (oltA *OLTAdapter) EnablePort(ctx context.Context, port *voltha.Port) (*emptypb.Empty, error) { //nolint
go func() {
c, err := oltA.GetCoreClient()
if err != nil {
@@ -356,11 +356,11 @@
}
}()
- return &empty.Empty{}, nil
+ return &emptypb.Empty{}, nil
}
// Disable_port -
-func (oltA *OLTAdapter) DisablePort(ctx context.Context, port *voltha.Port) (*empty.Empty, error) { //nolint
+func (oltA *OLTAdapter) DisablePort(ctx context.Context, port *voltha.Port) (*emptypb.Empty, error) { //nolint
go func() {
c, err := oltA.GetCoreClient()
if err != nil {
@@ -379,11 +379,11 @@
}
}
}()
- return &empty.Empty{}, nil
+ return &emptypb.Empty{}, nil
}
// Reboot_device -
-func (oltA *OLTAdapter) RebootDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) { // nolint
+func (oltA *OLTAdapter) RebootDevice(ctx context.Context, device *voltha.Device) (*emptypb.Empty, error) { // nolint
logger.Infow(ctx, "reboot-device", log.Fields{"device-id": device.Id})
go func() {
@@ -410,7 +410,7 @@
logger.Warnw(ctx, "updating-ports-failed", log.Fields{"device-id": device.Id, "error": err})
}
}()
- return &empty.Empty{}, nil
+ return &emptypb.Empty{}, nil
}
// TODO: REMOVE Start_omci_test begins an omci self-test
@@ -490,24 +490,32 @@
}
-func (onuA *OLTAdapter) DisableOnuSerialNumber(ctx context.Context, in *voltha.OnuSerialNumberOnOLTPon) (*empty.Empty, error) {
- return &empty.Empty{}, nil
+// DisableOnuDevice disables an ONU device
+func (oltA *OLTAdapter) DisableOnuDevice(ctx context.Context, device *voltha.Device) (*emptypb.Empty, error) {
+ logger.Debugw(ctx, "DisableOnuDevice", log.Fields{"device-id": device.Id})
+ return &emptypb.Empty{}, nil
}
-func (onuA *OLTAdapter) EnableOnuSerialNumber(ctx context.Context, in *voltha.OnuSerialNumberOnOLTPon) (*empty.Empty, error) {
- return &empty.Empty{}, nil
+// EnableOnuDevice enables an ONU device
+func (oltA *OLTAdapter) EnableOnuDevice(ctx context.Context, device *voltha.Device) (*emptypb.Empty, error) {
+ logger.Debugw(ctx, "EnableOnuDevice", log.Fields{"device-id": device.Id})
+ return &emptypb.Empty{}, nil
}
-func (onuA *OLTAdapter) DisableOnuDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) {
- return &empty.Empty{}, nil
+// DisableOnuSerialNumber disables an ONU by serial number
+func (oltA *OLTAdapter) DisableOnuSerialNumber(ctx context.Context, request *voltha.OnuSerialNumberOnOLTPon) (*emptypb.Empty, error) {
+ logger.Debugw(ctx, "DisableOnuSerialNumber", log.Fields{"serial-number": request.SerialNumber})
+ return &emptypb.Empty{}, nil
}
-func (onuA *OLTAdapter) EnableOnuDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) {
- return &empty.Empty{}, nil
+// EnableOnuSerialNumber enables an ONU by serial number
+func (oltA *OLTAdapter) EnableOnuSerialNumber(ctx context.Context, request *voltha.OnuSerialNumberOnOLTPon) (*emptypb.Empty, error) {
+ logger.Debugw(ctx, "EnableOnuSerialNumber", log.Fields{"serial-number": request.SerialNumber})
+ return &emptypb.Empty{}, nil
}
-func (onuA *OLTAdapter) UpdateDevice(ctx context.Context, req *voltha.UpdateDevice) (*empty.Empty, error) {
+func (onuA *OLTAdapter) UpdateDevice(ctx context.Context, req *voltha.UpdateDevice) (*emptypb.Empty, error) {
logger.Debugw(ctx, "UpdateDevice called", log.Fields{"device-config": req})
// You can add logic here to update the device in your mock if needed.
- return &empty.Empty{}, nil
+ return &emptypb.Empty{}, nil
}
diff --git a/rw_core/mocks/adapter_onu.go b/rw_core/mocks/adapter_onu.go
index 610355e..6dd5733 100644
--- a/rw_core/mocks/adapter_onu.go
+++ b/rw_core/mocks/adapter_onu.go
@@ -23,7 +23,6 @@
"strings"
"time"
- "github.com/golang/protobuf/ptypes/empty"
vgrpc "github.com/opencord/voltha-lib-go/v7/pkg/grpc"
"github.com/opencord/voltha-lib-go/v7/pkg/probe"
"github.com/opencord/voltha-protos/v5/go/adapter_service"
@@ -32,13 +31,14 @@
"github.com/opencord/voltha-protos/v5/go/extension"
"github.com/opencord/voltha-protos/v5/go/health"
"github.com/phayes/freeport"
+ "google.golang.org/protobuf/types/known/emptypb"
- "github.com/gogo/protobuf/proto"
com "github.com/opencord/voltha-lib-go/v7/pkg/adapters/common"
"github.com/opencord/voltha-lib-go/v7/pkg/log"
"github.com/opencord/voltha-protos/v5/go/omci"
of "github.com/opencord/voltha-protos/v5/go/openflow_13"
"github.com/opencord/voltha-protos/v5/go/voltha"
+ "google.golang.org/protobuf/proto"
)
// ONUAdapter represent ONU adapter attributes
@@ -115,7 +115,7 @@
}
// Adopt_device creates new handler for added device
-func (onuA *ONUAdapter) AdoptDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) {
+func (onuA *ONUAdapter) AdoptDevice(ctx context.Context, device *voltha.Device) (*emptypb.Empty, error) {
logger.Debugw(ctx, "AdoptDevice", log.Fields{"device": device.AdapterEndpoint, "device-type": onuA.DeviceType})
go func() {
d := proto.Clone(device).(*voltha.Device)
@@ -204,18 +204,18 @@
onuA.updateDevice(d)
}()
- return &empty.Empty{}, nil
+ return &emptypb.Empty{}, nil
}
// Single_get_value_request retrieves a single value.
func (onuA *ONUAdapter) Single_get_value_request(ctx context.Context, // nolint
- request extension.SingleGetValueRequest) (*extension.SingleGetValueResponse, error) {
+ request *extension.SingleGetValueRequest) (*extension.SingleGetValueResponse, error) {
logger.Fatalf(ctx, "Single_get_value_request unimplemented")
return nil, nil
}
// Disable_device disables device
-func (onuA *ONUAdapter) DisableDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) { // nolint
+func (onuA *ONUAdapter) DisableDevice(ctx context.Context, device *voltha.Device) (*emptypb.Empty, error) { // nolint
go func() {
if d := onuA.getDevice(device.Id); d == nil {
logger.Fatalf(ctx, "device-not-found-%s", device.Id)
@@ -254,10 +254,10 @@
onuA.updateDevice(cloned)
}()
- return &empty.Empty{}, nil
+ return &emptypb.Empty{}, nil
}
-func (onuA *ONUAdapter) ReEnableDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) { // nolint
+func (onuA *ONUAdapter) ReEnableDevice(ctx context.Context, device *voltha.Device) (*emptypb.Empty, error) { // nolint
go func() {
if d := onuA.getDevice(device.Id); d == nil {
logger.Fatalf(ctx, "device-not-found-%s", device.Id)
@@ -295,7 +295,7 @@
}
onuA.updateDevice(cloned)
}()
- return &empty.Empty{}, nil
+ return &emptypb.Empty{}, nil
}
func (onuA *ONUAdapter) StartOmciTest(ctx context.Context, _ *ca.OMCITest) (*omci.TestResponse, error) { // nolint
@@ -339,24 +339,32 @@
return err
}
-func (onuA *ONUAdapter) DisableOnuSerialNumber(ctx context.Context, in *voltha.OnuSerialNumberOnOLTPon) (*empty.Empty, error) {
- return &empty.Empty{}, nil
+// DisableOnuDevice disables an ONU device
+func (onuA *ONUAdapter) DisableOnuDevice(ctx context.Context, device *voltha.Device) (*emptypb.Empty, error) {
+ logger.Debugw(ctx, "DisableOnuDevice", log.Fields{"device-id": device.Id})
+ return &emptypb.Empty{}, nil
}
-func (onuA *ONUAdapter) EnableOnuSerialNumber(ctx context.Context, in *voltha.OnuSerialNumberOnOLTPon) (*empty.Empty, error) {
- return &empty.Empty{}, nil
+// EnableOnuDevice enables an ONU device
+func (onuA *ONUAdapter) EnableOnuDevice(ctx context.Context, device *voltha.Device) (*emptypb.Empty, error) {
+ logger.Debugw(ctx, "EnableOnuDevice", log.Fields{"device-id": device.Id})
+ return &emptypb.Empty{}, nil
}
-func (onuA *ONUAdapter) DisableOnuDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) {
- return &empty.Empty{}, nil
+// DisableOnuSerialNumber disables an ONU by serial number
+func (onuA *ONUAdapter) DisableOnuSerialNumber(ctx context.Context, request *voltha.OnuSerialNumberOnOLTPon) (*emptypb.Empty, error) {
+ logger.Debugw(ctx, "DisableOnuSerialNumber", log.Fields{"serial-number": request.SerialNumber})
+ return &emptypb.Empty{}, nil
}
-func (onuA *ONUAdapter) EnableOnuDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) {
- return &empty.Empty{}, nil
+// EnableOnuSerialNumber enables an ONU by serial number
+func (onuA *ONUAdapter) EnableOnuSerialNumber(ctx context.Context, request *voltha.OnuSerialNumberOnOLTPon) (*emptypb.Empty, error) {
+ logger.Debugw(ctx, "EnableOnuSerialNumber", log.Fields{"serial-number": request.SerialNumber})
+ return &emptypb.Empty{}, nil
}
-func (onuA *ONUAdapter) UpdateDevice(ctx context.Context, req *voltha.UpdateDevice) (*empty.Empty, error) {
+func (onuA *ONUAdapter) UpdateDevice(ctx context.Context, req *voltha.UpdateDevice) (*emptypb.Empty, error) {
logger.Debugw(ctx, "UpdateDevice called", log.Fields{"device-config": req})
// You can add logic here to update the device in your mock if needed.
- return &empty.Empty{}, nil
+ return &emptypb.Empty{}, nil
}
diff --git a/rw_core/test/common_test.go b/rw_core/test/common_test.go
index 6974718..2ed0d0f 100644
--- a/rw_core/test/common_test.go
+++ b/rw_core/test/common_test.go
@@ -26,8 +26,8 @@
"github.com/opencord/voltha-protos/v5/go/common"
ofp "github.com/opencord/voltha-protos/v5/go/openflow_13"
- "github.com/golang/protobuf/ptypes/empty"
"github.com/opencord/voltha-protos/v5/go/voltha"
+ "google.golang.org/protobuf/types/known/emptypb"
)
var retryInterval = 50 * time.Millisecond
@@ -191,7 +191,7 @@
done := false
go func() {
for {
- devices, _ := nbi.ListDevices(getContext(), &empty.Empty{})
+ devices, _ := nbi.ListDevices(getContext(), &emptypb.Empty{})
if verificationFunction(devices) {
ch <- 1
break
@@ -219,7 +219,7 @@
done := false
go func() {
for {
- lDevices, _ := nbi.ListLogicalDevices(getContext(), &empty.Empty{})
+ lDevices, _ := nbi.ListLogicalDevices(getContext(), &emptypb.Empty{})
if verificationFunction(lDevices) {
ch <- 1
break
@@ -358,7 +358,7 @@
break
}
for {
- devices, _ := nbi.ListDevices(getContext(), &empty.Empty{})
+ devices, _ := nbi.ListDevices(getContext(), &emptypb.Empty{})
removed := devices == nil || len(devices.Items) == 0
if !removed {
removed = true
@@ -420,7 +420,7 @@
continue
}
// verifyParentDeletionOnly is False => check children as well
- devices, _ := nbi.ListDevices(getContext(), &empty.Empty{})
+ devices, _ := nbi.ListDevices(getContext(), &emptypb.Empty{})
removed := devices == nil || len(devices.Items) == 0
if !removed {
removed = true
diff --git a/rw_core/test/core_nbi_handler_multi_test.go b/rw_core/test/core_nbi_handler_multi_test.go
index e136fbc..09533d1 100755
--- a/rw_core/test/core_nbi_handler_multi_test.go
+++ b/rw_core/test/core_nbi_handler_multi_test.go
@@ -32,7 +32,6 @@
"time"
"github.com/IBM/sarama"
- "github.com/golang/protobuf/ptypes/empty"
"github.com/opencord/voltha-lib-go/v7/pkg/flows"
"github.com/opencord/voltha-lib-go/v7/pkg/kafka"
mock_kafka "github.com/opencord/voltha-lib-go/v7/pkg/mocks/kafka"
@@ -42,7 +41,6 @@
"github.com/opencord/voltha-protos/v5/go/voltha"
"google.golang.org/grpc"
- "github.com/golang/protobuf/jsonpb"
"github.com/opencord/voltha-go/rw_core/config"
c "github.com/opencord/voltha-go/rw_core/core"
cm "github.com/opencord/voltha-go/rw_core/mocks"
@@ -50,6 +48,8 @@
mock_etcd "github.com/opencord/voltha-lib-go/v7/pkg/mocks/etcd"
"github.com/phayes/freeport"
"github.com/stretchr/testify/assert"
+ "google.golang.org/protobuf/encoding/protojson"
+ "google.golang.org/protobuf/types/known/emptypb"
)
var oltAdapters = map[string]*AdapterInfo{
@@ -268,7 +268,7 @@
func (nb *NBTest) verifyLogicalDevices(t *testing.T, oltDevice *voltha.Device, nbi voltha.VolthaServiceClient) {
// Get the latest logical device
- logicalDevices, err := nbi.ListLogicalDevices(getContext(), &empty.Empty{})
+ logicalDevices, err := nbi.ListLogicalDevices(getContext(), &emptypb.Empty{})
assert.Nil(t, err)
assert.NotNil(t, logicalDevices)
var ld *voltha.LogicalDevice
@@ -316,7 +316,7 @@
func (nb *NBTest) verifyDevices(t *testing.T, nbi voltha.VolthaServiceClient, oltDeviceID string) {
// Get the latest set of devices
- devices, err := nbi.ListDevices(getContext(), &empty.Empty{})
+ devices, err := nbi.ListDevices(getContext(), &emptypb.Empty{})
assert.Nil(t, err)
assert.NotNil(t, devices)
@@ -385,7 +385,7 @@
}
func (nb *NBTest) getChildDevices(parentID string, nbi voltha.VolthaServiceClient) (*voltha.Devices, error) {
- devices, err := nbi.ListDevices(getContext(), &empty.Empty{})
+ devices, err := nbi.ListDevices(getContext(), &emptypb.Empty{})
if err != nil {
return nil, err
}
@@ -399,15 +399,15 @@
}
func (nb *NBTest) testCoreWithoutData(t *testing.T, nbi voltha.VolthaServiceClient) {
- lds, err := nbi.ListLogicalDevices(getContext(), &empty.Empty{})
+ lds, err := nbi.ListLogicalDevices(getContext(), &emptypb.Empty{})
assert.Nil(t, err)
assert.NotNil(t, lds)
assert.Equal(t, 0, len(lds.Items))
- devices, err := nbi.ListDevices(getContext(), &empty.Empty{})
+ devices, err := nbi.ListDevices(getContext(), &emptypb.Empty{})
assert.Nil(t, err)
assert.NotNil(t, devices)
assert.Equal(t, 0, len(devices.Items))
- adapters, err := nbi.ListAdapters(getContext(), &empty.Empty{})
+ adapters, err := nbi.ListAdapters(getContext(), &emptypb.Empty{})
assert.Equal(t, 0, len(adapters.Items))
assert.Nil(t, err)
assert.NotNil(t, adapters)
@@ -425,7 +425,7 @@
func (nb *NBTest) testAdapterRegistration(t *testing.T, nbi voltha.VolthaServiceClient) {
ctx := context.Background()
- adapters, err := nbi.ListAdapters(getContext(), &empty.Empty{})
+ adapters, err := nbi.ListAdapters(getContext(), &emptypb.Empty{})
assert.Nil(t, err)
assert.NotNil(t, adapters)
assert.Equal(t, nb.getNumAdapters(), len(adapters.Items))
@@ -446,7 +446,7 @@
logger.Fatal(ctx, "unregistered-adapter", a.Id)
}
}
- deviceTypes, err := nbi.ListDeviceTypes(getContext(), &empty.Empty{})
+ deviceTypes, err := nbi.ListDeviceTypes(getContext(), &emptypb.Empty{})
assert.Nil(t, err)
assert.NotNil(t, deviceTypes)
assert.Equal(t, len(nb.oltAdapters)+len(nb.onuAdapters), len(deviceTypes.Items))
@@ -724,7 +724,7 @@
assert.NotNil(t, oltDevice)
// Verify oltDevice exist in the core
- devices, err := nbi.ListDevices(getContext(), &empty.Empty{})
+ devices, err := nbi.ListDevices(getContext(), &emptypb.Empty{})
assert.Nil(t, err)
exist := false
for _, d := range devices.Items {
@@ -1346,6 +1346,17 @@
uniPorts = append(uniPorts, p)
}
}
+ if len(ports) == 0 {
+ t.Logf("Warning: No ports provided to sendTrapFlows for logical device %s", logicalDeviceID)
+ return 0, 0
+ }
+ if len(nniPorts) == 0 {
+ t.Logf("Warning: No NNI ports found for logical device %s, total ports: %d", logicalDeviceID, len(ports))
+ for i, p := range ports {
+ t.Logf("Port %d: DeviceID=%s, PortNo=%d, RootPort=%v, DevicePortNo=%d", i, p.DeviceId, p.OfpPort.PortNo, p.RootPort, p.DevicePortNo)
+ }
+ return 0, len(uniPorts)
+ }
assert.Equal(t, 1, len(nniPorts))
//assert.Greater(t, len(uniPorts), 1 )
nniPort := nniPorts[0].OfpPort.PortNo
@@ -1441,7 +1452,7 @@
opt := grpc.EmptyCallOption{}
streamCtx, streamDone := context.WithCancel(log.WithSpanFromContext(context.Background(), ctx))
defer streamDone()
- stream, err := nbi.ReceiveChangeEvents(streamCtx, &empty.Empty{}, opt)
+ stream, err := nbi.ReceiveChangeEvents(streamCtx, &emptypb.Empty{}, opt)
if err != nil {
logger.Errorw(ctx, "cannot-establish-receive-change-events", log.Fields{"error": err})
return
@@ -1463,7 +1474,7 @@
}
func (nb *NBTest) getOLTAdapterInstance(t *testing.T, nbi voltha.VolthaServiceClient, oltDeviceID string) (*cm.OLTAdapter, error) {
- devices, err := nbi.ListDevices(getContext(), &empty.Empty{})
+ devices, err := nbi.ListDevices(getContext(), &emptypb.Empty{})
assert.Nil(t, err)
nb.oltAdaptersLock.RLock()
defer nb.oltAdaptersLock.RUnlock()
@@ -1484,7 +1495,7 @@
func (nb *NBTest) getAdapterInstancesWithDeviceIds(t *testing.T, nbi voltha.VolthaServiceClient, oltDeviceID string) (*cm.OLTAdapter, map[string]*cm.ONUAdapter, []string, error) {
var oltAdapter *cm.OLTAdapter
onuAdapters := make(map[string]*cm.ONUAdapter)
- devices, err := nbi.ListDevices(getContext(), &empty.Empty{})
+ devices, err := nbi.ListDevices(getContext(), &emptypb.Empty{})
onuDeviceIDs := make([]string, 0)
assert.Nil(t, err)
oltAdapterFound := false
@@ -1555,7 +1566,7 @@
err := waitUntilConditionForLogicalDevices(nb.maxTimeout, nbi, vlFunction)
assert.Nil(t, err)
- logicalDevices, err := nbi.ListLogicalDevices(getContext(), &empty.Empty{})
+ logicalDevices, err := nbi.ListLogicalDevices(getContext(), &emptypb.Empty{})
assert.Nil(t, err)
assert.NotNil(t, logicalDevices)
var logicalDevice *voltha.LogicalDevice
@@ -1733,7 +1744,7 @@
// Verify that the logical device has been setup correctly
nb.verifyLogicalDevices(t, oltDevice, nbi)
- logicalDevices, err := nbi.ListLogicalDevices(getContext(), &empty.Empty{})
+ logicalDevices, err := nbi.ListLogicalDevices(getContext(), &emptypb.Empty{})
assert.Nil(t, err)
assert.NotNil(t, logicalDevices)
var logicalDevice *voltha.LogicalDevice
@@ -1774,9 +1785,9 @@
logicalPorts, err := nbi.ListLogicalDevicePorts(context.Background(), &voltha.ID{Id: logicalDevice.Id})
assert.NoError(t, err)
- m := jsonpb.Marshaler{}
- logicalPortsJson, err := m.MarshalToString(logicalPorts)
+ logicalPortsJsonBytes, err := protojson.Marshal(logicalPorts)
assert.NoError(t, err)
+ logicalPortsJson := string(logicalPortsJsonBytes)
testLogger.Infow(getContext(), "list-logical-ports", log.Fields{"ports": logicalPortsJson})
@@ -1805,8 +1816,8 @@
flowMod = makeSimpleFlowMod(fa)
flowMod.TableId = 0
- m := jsonpb.Marshaler{}
- flowModJson, _ := m.MarshalToString(flowMod)
+ flowModJsonBytes, _ := protojson.Marshal(flowMod)
+ flowModJson := string(flowModJsonBytes)
testLogger.Infow(getContext(), "onu-upstream-flow", log.Fields{"flow-mod": flowModJson})
return
}
@@ -1834,8 +1845,8 @@
}
flowMod = makeSimpleFlowMod(fa)
flowMod.TableId = 1
- m := jsonpb.Marshaler{}
- flowModJson, _ := m.MarshalToString(flowMod)
+ flowModJsonBytes, _ := protojson.Marshal(flowMod)
+ flowModJson := string(flowModJsonBytes)
testLogger.Infow(getContext(), "olt-upstream-flow", log.Fields{"flow-mod": flowModJson})
return
}
@@ -1857,8 +1868,8 @@
}
flowMod = makeSimpleFlowMod(fa)
flowMod.TableId = 0
- m := jsonpb.Marshaler{}
- flowModJson, _ := m.MarshalToString(flowMod)
+ flowModJsonBytes, _ := protojson.Marshal(flowMod)
+ flowModJson := string(flowModJsonBytes)
testLogger.Infow(getContext(), "olt-mpls-downstream-single-tag-flow", log.Fields{"flow-mod": flowModJson})
return
}
@@ -1879,8 +1890,8 @@
}
flowMod = makeSimpleFlowMod(fa)
flowMod.TableId = 0
- m := jsonpb.Marshaler{}
- flowModJson, _ := m.MarshalToString(flowMod)
+ flowModJsonBytes, _ := protojson.Marshal(flowMod)
+ flowModJson := string(flowModJsonBytes)
testLogger.Infow(getContext(), "olt-mpls-downstream-double-tagged-flow", log.Fields{"flow-mod": flowModJson})
return
}
@@ -1898,8 +1909,8 @@
}
flowMod = makeSimpleFlowMod(fa)
flowMod.TableId = 1
- m := jsonpb.Marshaler{}
- flowModJson, _ := m.MarshalToString(flowMod)
+ flowModJsonBytes, _ := protojson.Marshal(flowMod)
+ flowModJson := string(flowModJsonBytes)
testLogger.Infow(getContext(), "olt-downstream-flow", log.Fields{"flow-mod": flowModJson})
return
}
@@ -1918,8 +1929,8 @@
}
flowMod = makeSimpleFlowMod(fa)
flowMod.TableId = 2
- m := jsonpb.Marshaler{}
- flowModJson, _ := m.MarshalToString(flowMod)
+ flowModJsonBytes, _ := protojson.Marshal(flowMod)
+ flowModJson := string(flowModJsonBytes)
testLogger.Infow(getContext(), "onu-downstream-flow", log.Fields{"flow-mod": flowModJson})
return
}
@@ -2090,7 +2101,7 @@
// Wait for adapters to be fully running
var isCoreConnectedToAdapters isConditionSatisfied = func() bool {
- adpts, err := nbi.ListAdapters(getContext(), &empty.Empty{})
+ adpts, err := nbi.ListAdapters(getContext(), &emptypb.Empty{})
if err != nil || len(adpts.Items) < numAdapters {
return false
}