VOL-1888 Not enough info in ONU DGI to Identify the ONU.
Fixed to fetch the serial number from the list of ONUs
handled by the device handler from the onu-id and the
intf-id which is sent by the openolt agent in the dgi
indication.
Change-Id: I54342b9009d4d12c0efa3745d1f48567f183c245
diff --git a/adaptercore/device_handler.go b/adaptercore/device_handler.go
index 95bc170..ab30edd 100644
--- a/adaptercore/device_handler.go
+++ b/adaptercore/device_handler.go
@@ -514,7 +514,7 @@
}
/* TODO: Instantiate Alarm , stats , BW managers */
/* Instantiating Event Manager to handle Alarms and KPIs */
- dh.eventMgr = NewEventMgr(dh.EventProxy)
+ dh.eventMgr = NewEventMgr(dh.EventProxy, dh)
// Start reading indications
go dh.readIndications()
diff --git a/adaptercore/openolt_eventmgr.go b/adaptercore/openolt_eventmgr.go
index ba74f18..0d1432c 100644
--- a/adaptercore/openolt_eventmgr.go
+++ b/adaptercore/openolt_eventmgr.go
@@ -19,7 +19,6 @@
import (
"fmt"
-
"github.com/opencord/voltha-go/adapters/adapterif"
"github.com/opencord/voltha-go/common/log"
oop "github.com/opencord/voltha-protos/go/openolt"
@@ -62,12 +61,14 @@
// OpenOltEventMgr struct contains
type OpenOltEventMgr struct {
eventProxy adapterif.EventProxy
+ handler *DeviceHandler
}
// NewEventMgr is a Function to get a new event manager struct for the OpenOLT to process and publish OpenOLT event
-func NewEventMgr(eventProxy adapterif.EventProxy) *OpenOltEventMgr {
+func NewEventMgr(eventProxy adapterif.EventProxy, handler *DeviceHandler) *OpenOltEventMgr {
var em OpenOltEventMgr
em.eventProxy = eventProxy
+ em.handler = handler
return &em
}
@@ -181,8 +182,14 @@
func (em *OpenOltEventMgr) onuDyingGaspIndication(dgi *oop.DyingGaspIndication, deviceID string, raisedTs int64) {
var de voltha.DeviceEvent
+ var serialNumber string
context := make(map[string]string)
/* Populating event context */
+ serialNumber = ""
+ if onu, ok := em.handler.onus[em.handler.formOnuKey(dgi.IntfId, dgi.OnuId)]; ok {
+ serialNumber = onu.serialNumber
+ }
+ context["serial-number"] = serialNumber
context["intf-id"] = string(dgi.IntfId)
context["onu-id"] = string(dgi.OnuId)
/* Populating device event body */
diff --git a/adaptercore/openolt_eventmgr_test.go b/adaptercore/openolt_eventmgr_test.go
index 7de341f..dcfcef3 100644
--- a/adaptercore/openolt_eventmgr_test.go
+++ b/adaptercore/openolt_eventmgr_test.go
@@ -27,7 +27,13 @@
func mockEventMgr() *OpenOltEventMgr {
ep := &mocks.MockEventProxy{}
- return NewEventMgr(ep)
+ dh := &DeviceHandler{}
+ dh.onus = make(map[string]*OnuDevice)
+ dh.onus[dh.formOnuKey(1, 1)] = &OnuDevice{deviceID: "TEST_ONU",
+ deviceType: "ONU",
+ serialNumber: "TEST_ONU_123",
+ onuID: 1, intfID: 1}
+ return NewEventMgr(ep, dh)
}
func TestOpenOltEventMgr_ProcessEvents(t *testing.T) {
em := mockEventMgr()