Alarm - ONU Remote Defect Indicator

        Added support for ONU remote defect indication

Change-Id: I9db2ecd6552f4720fdc405d41685155f348aa29d
diff --git a/internal/pkg/core/openolt_eventmgr.go b/internal/pkg/core/openolt_eventmgr.go
index 4e21d11..45d963e 100644
--- a/internal/pkg/core/openolt_eventmgr.go
+++ b/internal/pkg/core/openolt_eventmgr.go
@@ -51,6 +51,7 @@
 	onuLossOfPloamEvent         = "ONU_LOSS_OF_PLOAM"
 	ponIntfDownIndiction        = "OLT_PON_INTERFACE_DOWN"
 	onuDeactivationFailureEvent = "ONU_DEACTIVATION_FAILURE"
+	onuRemoteDefectIndication   = "ONU_REMOTE_DEFECT"
 )
 
 const (
@@ -134,6 +135,9 @@
 	case *oop.AlarmIndication_OnuItuPonStatsInd:
 		log.Infow("Received onu Itu Pon Stats indication ", log.Fields{"alarm_ind": alarmInd})
 		log.Infow("Not implemented yet", log.Fields{"alarm_ind": alarmInd})
+	case *oop.AlarmIndication_OnuRemoteDefectInd:
+		log.Infow("Received onu remote defect indication ", log.Fields{"alarm_ind": alarmInd})
+		err = em.onuRemoteDefectIndication(alarmInd.GetOnuRemoteDefectInd(), deviceID, raisedTs)
 	case *oop.AlarmIndication_OnuDeactivationFailureInd:
 		log.Infow("Received onu deactivation failure indication ", log.Fields{"alarm_ind": alarmInd})
 		err = em.onuDeactivationFailureIndication(alarmInd.GetOnuDeactivationFailureInd(), deviceID, raisedTs)
@@ -502,3 +506,25 @@
 	log.Infow("ONU deactivation failure event sent to KAFKA", log.Fields{"onu-id": onuDFI.OnuId, "intf-id": onuDFI.IntfId})
 	return nil
 }
+
+func (em *OpenOltEventMgr) onuRemoteDefectIndication(onuRDI *oop.OnuRemoteDefectIndication, deviceID string, raisedTs int64) error {
+	/* Populating event context */
+	context := map[string]string{
+		"onu-id":     strconv.FormatUint(uint64(onuRDI.OnuId), base10),
+		"intf-id":    strconv.FormatUint(uint64(onuRDI.IntfId), base10),
+		"rdi-errors": strconv.FormatUint(uint64(onuRDI.RdiErrors), base10),
+	}
+	/* Populating device event body */
+	de := &voltha.DeviceEvent{
+		Context:         context,
+		ResourceId:      deviceID,
+		DeviceEventName: onuRemoteDefectIndication,
+	}
+	/* Send event to KAFKA */
+	if err := em.eventProxy.SendDeviceEvent(de, equipment, onu, raisedTs); err != nil {
+		log.Errorw("Failed to send ONU remote defect event", log.Fields{"onu-id": onuRDI.OnuId, "intf-id": onuRDI.IntfId})
+		return err
+	}
+	log.Infow("ONU remote defect event sent to KAFKA", log.Fields{"onu-id": onuRDI.OnuId, "intf-id": onuRDI.IntfId})
+	return nil
+}