[VOL-3644] fixed wrong topic names
The adapter_open_olt_topic is a configurable parameter from the command line
When sending InterAdapterMessage to the openonu-adapter, openolt-adapter
uses hardcoded "openolt" or deviceType fields as source topic name. This causes
not getting the responses from the openonu-adapter
if the topic name argument is set different than "openolt".
Change-Id: I0f88c1e8f9bfe322344c062478593444466869d4
diff --git a/internal/pkg/core/device_handler.go b/internal/pkg/core/device_handler.go
index 66ca4bb..cb569d7 100644
--- a/internal/pkg/core/device_handler.go
+++ b/internal/pkg/core/device_handler.go
@@ -636,10 +636,10 @@
onuInd := oop.OnuIndication{}
onuInd.OperState = "down"
err := dh.AdapterProxy.SendInterAdapterMessage(ctx, &onuInd, ic.InterAdapterMessageType_ONU_IND_REQUEST,
- "openolt", onuDevice.Type, onuDevice.Id, onuDevice.ProxyAddress.DeviceId, "")
+ dh.openOLT.config.Topic, onuDevice.Type, onuDevice.Id, onuDevice.ProxyAddress.DeviceId, "")
if err != nil {
_ = olterrors.NewErrCommunication("inter-adapter-send-failed", log.Fields{
- "source": "openolt",
+ "source": dh.openOLT.config.Topic,
"onu-indicator": onuInd,
"device-type": onuDevice.Type,
"device-id": onuDevice.Id}, err).LogAt(log.ErrorLevel)
@@ -949,10 +949,10 @@
omciMsg := &ic.InterAdapterOmciMessage{Message: omciInd.Pkt}
if err := dh.AdapterProxy.SendInterAdapterMessage(log.WithSpanFromContext(context.Background(), ctx), omciMsg,
- ic.InterAdapterMessageType_OMCI_REQUEST, dh.device.Type, deviceType,
+ ic.InterAdapterMessageType_OMCI_REQUEST, dh.openOLT.config.Topic, deviceType,
deviceID, proxyDeviceID, ""); err != nil {
return olterrors.NewErrCommunication("omci-request", log.Fields{
- "source": dh.device.Type,
+ "source": dh.openOLT.config.Topic,
"destination": deviceType,
"onu-id": deviceID,
"proxy-device-id": proxyDeviceID}, err)
@@ -1296,11 +1296,11 @@
logger.Debugw(ctx, "sending-interadapter-onu-indication", log.Fields{"onuIndication": onuInd, "device-id": onuDevice.Id, "operStatus": onuDevice.OperStatus, "adminStatus": onuDevice.AdminState})
// TODO NEW CORE do not hardcode adapter name. Handler needs Adapter reference
err := dh.AdapterProxy.SendInterAdapterMessage(ctx, onuInd, ic.InterAdapterMessageType_ONU_IND_REQUEST,
- "openolt", onuDevice.Type, onuDevice.Id, onuDevice.ProxyAddress.DeviceId, "")
+ dh.openOLT.config.Topic, onuDevice.Type, onuDevice.Id, onuDevice.ProxyAddress.DeviceId, "")
if err != nil {
return olterrors.NewErrCommunication("inter-adapter-send-failed", log.Fields{
"onu-indicator": onuInd,
- "source": "openolt",
+ "source": dh.openOLT.config.Topic,
"device-type": onuDevice.Type,
"device-id": onuDevice.Id}, err)
}
@@ -1308,11 +1308,11 @@
logger.Debugw(ctx, "sending-interadapter-onu-indication", log.Fields{"onuIndication": onuInd, "device-id": onuDevice.Id, "operStatus": onuDevice.OperStatus, "adminStatus": onuDevice.AdminState})
// TODO NEW CORE do not hardcode adapter name. Handler needs Adapter reference
err := dh.AdapterProxy.SendInterAdapterMessage(ctx, onuInd, ic.InterAdapterMessageType_ONU_IND_REQUEST,
- "openolt", onuDevice.Type, onuDevice.Id, onuDevice.ProxyAddress.DeviceId, "")
+ dh.openOLT.config.Topic, onuDevice.Type, onuDevice.Id, onuDevice.ProxyAddress.DeviceId, "")
if err != nil {
return olterrors.NewErrCommunication("inter-adapter-send-failed", log.Fields{
"onu-indicator": onuInd,
- "source": "openolt",
+ "source": dh.openOLT.config.Topic,
"device-type": onuDevice.Type,
"device-id": onuDevice.Id}, err)
}
@@ -1531,10 +1531,10 @@
if onuDevices != nil {
for _, onuDevice := range onuDevices.Items {
err := dh.AdapterProxy.SendInterAdapterMessage(log.WithSpanFromContext(context.TODO(), ctx), &onuInd, ic.InterAdapterMessageType_ONU_IND_REQUEST,
- "openolt", onuDevice.Type, onuDevice.Id, onuDevice.ProxyAddress.DeviceId, "")
+ dh.openOLT.config.Topic, onuDevice.Type, onuDevice.Id, onuDevice.ProxyAddress.DeviceId, "")
if err != nil {
logger.Errorw(ctx, "failed-to-send-inter-adapter-message", log.Fields{"OnuInd": onuInd,
- "From Adapter": "openolt", "DeviceType": onuDevice.Type, "device-id": onuDevice.Id})
+ "From Adapter": dh.openOLT.config.Topic, "DeviceType": onuDevice.Type, "device-id": onuDevice.Id})
}
}
diff --git a/internal/pkg/core/openolt_flowmgr.go b/internal/pkg/core/openolt_flowmgr.go
index 4e87682..44c6788 100644
--- a/internal/pkg/core/openolt_flowmgr.go
+++ b/internal/pkg/core/openolt_flowmgr.go
@@ -22,6 +22,9 @@
"encoding/hex"
"errors"
"fmt"
+ "strings"
+ "sync"
+
"github.com/opencord/voltha-lib-go/v4/pkg/flows"
"github.com/opencord/voltha-lib-go/v4/pkg/log"
tp "github.com/opencord/voltha-lib-go/v4/pkg/techprofile"
@@ -32,8 +35,6 @@
openoltpb2 "github.com/opencord/voltha-protos/v4/go/openolt"
tp_pb "github.com/opencord/voltha-protos/v4/go/tech_profile"
"github.com/opencord/voltha-protos/v4/go/voltha"
- "strings"
- "sync"
"github.com/opencord/voltha-openolt-adapter/internal/pkg/olterrors"
"google.golang.org/grpc/codes"
@@ -1687,13 +1688,13 @@
if sendErr := f.deviceHandler.AdapterProxy.SendInterAdapterMessage(log.WithSpanFromContext(context.Background(), ctx),
delGemPortMsg,
ic.InterAdapterMessageType_DELETE_GEM_PORT_REQUEST,
- f.deviceHandler.device.Type,
+ f.deviceHandler.openOLT.config.Topic,
onuDev.deviceType,
onuDev.deviceID,
onuDev.proxyDeviceID, ""); sendErr != nil {
return olterrors.NewErrCommunication("send-delete-gem-port-to-onu-adapter",
log.Fields{
- "from-adapter": f.deviceHandler.device.Type,
+ "from-adapter": f.deviceHandler.openOLT.config.Topic,
"to-adapter": onuDev.deviceType,
"onu-id": onuDev.deviceID,
"proxyDeviceID": onuDev.proxyDeviceID,
@@ -1728,13 +1729,13 @@
if sendErr := f.deviceHandler.AdapterProxy.SendInterAdapterMessage(log.WithSpanFromContext(context.Background(), ctx),
delTcontMsg,
ic.InterAdapterMessageType_DELETE_TCONT_REQUEST,
- f.deviceHandler.device.Type,
+ f.deviceHandler.openOLT.config.Topic,
onuDev.deviceType,
onuDev.deviceID,
onuDev.proxyDeviceID, ""); sendErr != nil {
return olterrors.NewErrCommunication("send-delete-tcont-to-onu-adapter",
log.Fields{
- "from-adapter": f.deviceHandler.device.Type,
+ "from-adapter": f.deviceHandler.openOLT.config.Topic,
"to-adapter": onuDev.deviceType, "onu-id": onuDev.deviceID,
"proxyDeviceID": onuDev.proxyDeviceID,
"device-id": f.deviceHandler.device.Id}, sendErr)
@@ -2331,14 +2332,14 @@
sendErr := f.deviceHandler.AdapterProxy.SendInterAdapterMessage(log.WithSpanFromContext(context.Background(), ctx),
tpDownloadMsg,
ic.InterAdapterMessageType_TECH_PROFILE_DOWNLOAD_REQUEST,
- f.deviceHandler.device.Type,
+ f.deviceHandler.openOLT.config.Topic,
onuDev.deviceType,
onuDev.deviceID,
onuDev.proxyDeviceID, "")
if sendErr != nil {
return olterrors.NewErrCommunication("send-techprofile-download-request",
log.Fields{
- "from-adapter": f.deviceHandler.device.Type,
+ "from-adapter": f.deviceHandler.openOLT.config.Topic,
"to-adapter": onuDev.deviceType,
"onu-id": onuDev.deviceID,
"proxyDeviceID": onuDev.proxyDeviceID}, sendErr)