VOL-1710 Generate OLT connectivity related alarms in golang OpenOLT adapter
Change-Id: Icd7758385ad7b6b358bf54edc33f71e0469a8f8e
diff --git a/adaptercore/device_handler.go b/adaptercore/device_handler.go
index 96e6189..a2dec0a 100644
--- a/adaptercore/device_handler.go
+++ b/adaptercore/device_handler.go
@@ -292,11 +292,14 @@
}
func (dh *DeviceHandler) handleOltIndication(oltIndication *oop.OltIndication) {
+ raisedTs := time.Now().UnixNano()
if oltIndication.OperState == "up" {
dh.transitionMap.Handle(DeviceUpInd)
} else if oltIndication.OperState == "down" {
dh.transitionMap.Handle(DeviceDownInd)
}
+ // Send or clear Alarm
+ dh.eventMgr.oltUpDownIndication(oltIndication, dh.deviceID, raisedTs)
}
func (dh *DeviceHandler) handleIndication(indication *oop.Indication) {
diff --git a/adaptercore/openolt_eventmgr.go b/adaptercore/openolt_eventmgr.go
index b993aea..e1cb576 100644
--- a/adaptercore/openolt_eventmgr.go
+++ b/adaptercore/openolt_eventmgr.go
@@ -32,6 +32,7 @@
onuLopcMissEvent = "ONU_LOPC_MISS"
onuLopcMicErrorEvent = "ONU_LOPC_MIC_ERROR"
oltLosEvent = "OLT_LOSS_OF_SIGNAL"
+ oltIndicationDown = "OLT_DOWN_INDICATION"
onuDyingGaspEvent = "ONU_DYING_GASP"
onuSignalsFailEvent = "ONU_SIGNALS_FAIL"
onuStartupFailEvent = "ONU_STARTUP_FAIL"
@@ -117,6 +118,27 @@
}
}
+// oltUpDownIndication handles Up and Down state of an OLT
+func (em *OpenOltEventMgr) oltUpDownIndication(oltIndication *oop.OltIndication, deviceID string, raisedTs int64) {
+ var de voltha.DeviceEvent
+ context := make(map[string]string)
+ /* Populating event context */
+ context["oper-state"] = string(oltIndication.OperState)
+ /* Populating device event body */
+ de.Context = context
+ de.ResourceId = deviceID
+ if oltIndication.OperState == "down" {
+ de.DeviceEventName = fmt.Sprintf("%s_%s", oltIndicationDown, "RAISE_EVENT")
+ } else if oltIndication.OperState == "up" {
+ de.DeviceEventName = fmt.Sprintf("%s_%s", oltIndicationDown, "CLEAR_EVENT")
+ }
+ /* Send event to KAFKA */
+ if err := em.eventProxy.SendDeviceEvent(&de, communication, olt, raisedTs); err != nil {
+ log.Errorw("Failed to send OLT event", log.Fields{"err": err})
+ }
+ log.Infow("OLT UpDown event sent to KAFKA", log.Fields{})
+}
+
// OnuDiscoveryIndication is an exported method to handle ONU discovery event
func (em *OpenOltEventMgr) OnuDiscoveryIndication(onuDisc *oop.OnuDiscIndication, deviceID string, OnuID uint32, serialNumber string, raisedTs int64) {
var de voltha.DeviceEvent