Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018-present Open Networking Foundation |
| 3 | |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Scott Baker | dbd960e | 2020-02-28 08:57:51 -0800 | [diff] [blame] | 17 | // Package core provides APIs for the openOLT adapter |
| 18 | package core |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 19 | |
| 20 | import ( |
kesavand | 39e0aa3 | 2020-01-28 20:58:50 -0500 | [diff] [blame] | 21 | ctx "context" |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 22 | "fmt" |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 23 | "strconv" |
Naga Manjunath | a8dc937 | 2019-10-31 23:01:18 +0530 | [diff] [blame] | 24 | |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 25 | "github.com/opencord/voltha-lib-go/v3/pkg/adapters/adapterif" |
| 26 | "github.com/opencord/voltha-lib-go/v3/pkg/log" |
Thomas Lee S | 94109f1 | 2020-03-03 16:39:29 +0530 | [diff] [blame] | 27 | "github.com/opencord/voltha-openolt-adapter/internal/pkg/olterrors" |
kesavand | 39e0aa3 | 2020-01-28 20:58:50 -0500 | [diff] [blame] | 28 | "github.com/opencord/voltha-protos/v3/go/common" |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 29 | oop "github.com/opencord/voltha-protos/v3/go/openolt" |
| 30 | "github.com/opencord/voltha-protos/v3/go/voltha" |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 31 | ) |
| 32 | |
| 33 | const ( |
Devmalya Paul | 41a762d | 2020-03-01 18:56:54 -0500 | [diff] [blame] | 34 | onuDiscoveryEvent = "ONU_DISCOVERY" |
| 35 | onuLosEvent = "ONU_LOSS_OF_SIGNAL" |
| 36 | onuLobEvent = "ONU_LOSS_OF_BURST" |
| 37 | onuLopcMissEvent = "ONU_LOPC_MISS" |
| 38 | onuLopcMicErrorEvent = "ONU_LOPC_MIC_ERROR" |
| 39 | oltLosEvent = "OLT_LOSS_OF_SIGNAL" |
| 40 | oltIndicationDown = "OLT_DOWN_INDICATION" |
| 41 | onuDyingGaspEvent = "ONU_DYING_GASP" |
| 42 | onuSignalsFailEvent = "ONU_SIGNALS_FAIL" |
| 43 | onuStartupFailEvent = "ONU_STARTUP_FAIL" |
| 44 | onuSignalDegradeEvent = "ONU_SIGNAL_DEGRADE" |
| 45 | onuDriftOfWindowEvent = "ONU_DRIFT_OF_WINDOW" |
| 46 | onuActivationFailEvent = "ONU_ACTIVATION_FAIL" |
| 47 | onuProcessingErrorEvent = "ONU_PROCESSING_ERROR" |
| 48 | onuTiwiEvent = "ONU_TRANSMISSION_WARNING" |
| 49 | onuLossOmciEvent = "ONU_LOSS_OF_OMCI_CHANNEL" |
| 50 | onuLossOfKeySyncEvent = "ONU_LOSS_OF_KEY_SYNC" |
| 51 | onuLossOfFrameEvent = "ONU_LOSS_OF_FRAME" |
| 52 | onuLossOfPloamEvent = "ONU_LOSS_OF_PLOAM" |
| 53 | ponIntfDownIndiction = "OLT_PON_INTERFACE_DOWN" |
| 54 | onuDeactivationFailureEvent = "ONU_DEACTIVATION_FAILURE" |
| 55 | onuRemoteDefectIndication = "ONU_REMOTE_DEFECT" |
| 56 | onuLossOfGEMChannelDelineationEvent = "ONU_LOSS_OF_GEM_CHANNEL_DELINEATION" |
| 57 | onuPhysicalEquipmentErrorEvent = "ONU_PHYSICAL_EQUIPMENT_ERROR" |
| 58 | onuLossOfAcknowledgementEvent = "ONU_LOSS_OF_ACKNOWLEDGEMENT" |
Devmalya Paul | eb5294e | 2020-03-19 03:01:39 -0400 | [diff] [blame] | 59 | onuDifferentialReachExceededEvent = "ONU_DIFFERENTIAL_REACH_EXCEEDED" |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 60 | ) |
| 61 | |
| 62 | const ( |
| 63 | pon = voltha.EventSubCategory_PON |
| 64 | olt = voltha.EventSubCategory_OLT |
| 65 | ont = voltha.EventSubCategory_ONT |
| 66 | onu = voltha.EventSubCategory_ONU |
| 67 | nni = voltha.EventSubCategory_NNI |
| 68 | service = voltha.EventCategory_SERVICE |
| 69 | security = voltha.EventCategory_SECURITY |
| 70 | equipment = voltha.EventCategory_EQUIPMENT |
| 71 | processing = voltha.EventCategory_PROCESSING |
| 72 | environment = voltha.EventCategory_ENVIRONMENT |
| 73 | communication = voltha.EventCategory_COMMUNICATION |
| 74 | ) |
| 75 | |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 76 | const ( |
| 77 | // statusCheckOn represents status check On |
| 78 | statusCheckOn = "on" |
| 79 | // statusCheckOff represents status check Off |
| 80 | statusCheckOff = "off" |
| 81 | // operationStateUp represents operation state Up |
| 82 | operationStateUp = "up" |
| 83 | // operationStateDown represents operation state Down |
| 84 | operationStateDown = "down" |
| 85 | // base10 represents base 10 conversion |
| 86 | base10 = 10 |
| 87 | ) |
| 88 | |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 89 | // OpenOltEventMgr struct contains |
| 90 | type OpenOltEventMgr struct { |
kdarapu | 381c690 | 2019-07-31 18:23:16 +0530 | [diff] [blame] | 91 | eventProxy adapterif.EventProxy |
Devmalya Paul | 90ca301 | 2019-09-02 21:55:45 -0400 | [diff] [blame] | 92 | handler *DeviceHandler |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | // NewEventMgr is a Function to get a new event manager struct for the OpenOLT to process and publish OpenOLT event |
Devmalya Paul | 90ca301 | 2019-09-02 21:55:45 -0400 | [diff] [blame] | 96 | func NewEventMgr(eventProxy adapterif.EventProxy, handler *DeviceHandler) *OpenOltEventMgr { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 97 | var em OpenOltEventMgr |
| 98 | em.eventProxy = eventProxy |
Devmalya Paul | 90ca301 | 2019-09-02 21:55:45 -0400 | [diff] [blame] | 99 | em.handler = handler |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 100 | return &em |
| 101 | } |
| 102 | |
| 103 | // ProcessEvents is function to process and publish OpenOLT event |
Devmalya Paul | 41a762d | 2020-03-01 18:56:54 -0500 | [diff] [blame] | 104 | // nolint: gocyclo |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 105 | func (em *OpenOltEventMgr) ProcessEvents(alarmInd *oop.AlarmIndication, deviceID string, raisedTs int64) error { |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 106 | var err error |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 107 | switch alarmInd.Data.(type) { |
| 108 | case *oop.AlarmIndication_LosInd: |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 109 | logger.Debugw("Received LOS indication", log.Fields{"alarm_ind": alarmInd}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 110 | err = em.oltLosIndication(alarmInd.GetLosInd(), deviceID, raisedTs) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 111 | case *oop.AlarmIndication_OnuAlarmInd: |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 112 | logger.Debugw("Received onu alarm indication ", log.Fields{"alarm_ind": alarmInd}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 113 | err = em.onuAlarmIndication(alarmInd.GetOnuAlarmInd(), deviceID, raisedTs) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 114 | case *oop.AlarmIndication_DyingGaspInd: |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 115 | logger.Debugw("Received dying gasp indication", log.Fields{"alarm_ind": alarmInd}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 116 | err = em.onuDyingGaspIndication(alarmInd.GetDyingGaspInd(), deviceID, raisedTs) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 117 | case *oop.AlarmIndication_OnuActivationFailInd: |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 118 | logger.Debugw("Received onu activation fail indication ", log.Fields{"alarm_ind": alarmInd}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 119 | err = em.onuActivationFailIndication(alarmInd.GetOnuActivationFailInd(), deviceID, raisedTs) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 120 | case *oop.AlarmIndication_OnuLossOmciInd: |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 121 | logger.Debugw("Received onu loss omci indication ", log.Fields{"alarm_ind": alarmInd}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 122 | err = em.onuLossOmciIndication(alarmInd.GetOnuLossOmciInd(), deviceID, raisedTs) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 123 | case *oop.AlarmIndication_OnuDriftOfWindowInd: |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 124 | logger.Debugw("Received onu drift of window indication ", log.Fields{"alarm_ind": alarmInd}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 125 | err = em.onuDriftOfWindowIndication(alarmInd.GetOnuDriftOfWindowInd(), deviceID, raisedTs) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 126 | case *oop.AlarmIndication_OnuSignalDegradeInd: |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 127 | logger.Debugw("Received onu signal degrade indication ", log.Fields{"alarm_ind": alarmInd}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 128 | err = em.onuSignalDegradeIndication(alarmInd.GetOnuSignalDegradeInd(), deviceID, raisedTs) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 129 | case *oop.AlarmIndication_OnuSignalsFailInd: |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 130 | logger.Debugw("Received onu signal fail indication ", log.Fields{"alarm_ind": alarmInd}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 131 | err = em.onuSignalsFailIndication(alarmInd.GetOnuSignalsFailInd(), deviceID, raisedTs) |
Naga Manjunath | f6f7464 | 2020-01-13 21:37:28 +0530 | [diff] [blame] | 132 | case *oop.AlarmIndication_OnuStartupFailInd: |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 133 | logger.Debugw("Received onu startup fail indication ", log.Fields{"alarm_ind": alarmInd}) |
Naga Manjunath | f6f7464 | 2020-01-13 21:37:28 +0530 | [diff] [blame] | 134 | err = em.onuStartupFailedIndication(alarmInd.GetOnuStartupFailInd(), deviceID, raisedTs) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 135 | case *oop.AlarmIndication_OnuTiwiInd: |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 136 | logger.Debugw("Received onu transmission warning indication ", log.Fields{"alarm_ind": alarmInd}) |
| 137 | logger.Debugw("Not implemented yet", log.Fields{"alarm_ind": "Onu-Transmission-indication"}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 138 | case *oop.AlarmIndication_OnuLossOfSyncFailInd: |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 139 | logger.Debugw("Received onu Loss of Sync Fail indication ", log.Fields{"alarm_ind": alarmInd}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 140 | err = em.onuLossOfSyncIndication(alarmInd.GetOnuLossOfSyncFailInd(), deviceID, raisedTs) |
| 141 | case *oop.AlarmIndication_OnuItuPonStatsInd: |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 142 | logger.Debugw("Received onu Itu Pon Stats indication ", log.Fields{"alarm_ind": alarmInd}) |
| 143 | logger.Debugw("Not implemented yet", log.Fields{"alarm_ind": alarmInd}) |
Devmalya Paul | 6f063a6 | 2020-02-19 19:19:06 -0500 | [diff] [blame] | 144 | case *oop.AlarmIndication_OnuRemoteDefectInd: |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 145 | logger.Debugw("Received onu remote defect indication ", log.Fields{"alarm_ind": alarmInd}) |
Devmalya Paul | 6f063a6 | 2020-02-19 19:19:06 -0500 | [diff] [blame] | 146 | err = em.onuRemoteDefectIndication(alarmInd.GetOnuRemoteDefectInd(), deviceID, raisedTs) |
Devmalya Paul | 1abc34e | 2020-02-04 20:48:06 -0500 | [diff] [blame] | 147 | case *oop.AlarmIndication_OnuDeactivationFailureInd: |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 148 | logger.Debugw("Received onu deactivation failure indication ", log.Fields{"alarm_ind": alarmInd}) |
Devmalya Paul | 1abc34e | 2020-02-04 20:48:06 -0500 | [diff] [blame] | 149 | err = em.onuDeactivationFailureIndication(alarmInd.GetOnuDeactivationFailureInd(), deviceID, raisedTs) |
Devmalya Paul | 41a762d | 2020-03-01 18:56:54 -0500 | [diff] [blame] | 150 | case *oop.AlarmIndication_OnuLossGemDelineationInd: |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 151 | logger.Debugw("Received onu loss of GEM channel delineation indication ", log.Fields{"alarm_ind": alarmInd}) |
Devmalya Paul | 41a762d | 2020-03-01 18:56:54 -0500 | [diff] [blame] | 152 | err = em.onuLossOfGEMChannelDelineationIndication(alarmInd.GetOnuLossGemDelineationInd(), deviceID, raisedTs) |
| 153 | case *oop.AlarmIndication_OnuPhysicalEquipmentErrorInd: |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 154 | logger.Debugw("Received onu physical equipment error indication ", log.Fields{"alarm_ind": alarmInd}) |
Devmalya Paul | 41a762d | 2020-03-01 18:56:54 -0500 | [diff] [blame] | 155 | err = em.onuPhysicalEquipmentErrorIndication(alarmInd.GetOnuPhysicalEquipmentErrorInd(), deviceID, raisedTs) |
| 156 | case *oop.AlarmIndication_OnuLossOfAckInd: |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 157 | logger.Debugw("Received onu loss of acknowledgement indication ", log.Fields{"alarm_ind": alarmInd}) |
Devmalya Paul | 41a762d | 2020-03-01 18:56:54 -0500 | [diff] [blame] | 158 | err = em.onuLossOfAcknowledgementIndication(alarmInd.GetOnuLossOfAckInd(), deviceID, raisedTs) |
Devmalya Paul | eb5294e | 2020-03-19 03:01:39 -0400 | [diff] [blame] | 159 | case *oop.AlarmIndication_OnuDiffReachExceededInd: |
| 160 | logger.Debugw("Received onu differential reach exceeded indication ", log.Fields{"alarm_ind": alarmInd}) |
| 161 | err = em.onuDifferentialReachExceededIndication(alarmInd.GetOnuDiffReachExceededInd(), deviceID, raisedTs) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 162 | default: |
Thomas Lee S | 94109f1 | 2020-03-03 16:39:29 +0530 | [diff] [blame] | 163 | err = olterrors.NewErrInvalidValue(log.Fields{"indication-type": alarmInd}, nil) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 164 | } |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 165 | if err != nil { |
Thomas Lee S | 94109f1 | 2020-03-03 16:39:29 +0530 | [diff] [blame] | 166 | return olterrors.NewErrCommunication("publish-message", log.Fields{"indication-type": alarmInd}, err).Log() |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 167 | } |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 168 | return nil |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 169 | } |
| 170 | |
Daniele Rossi | 051466a | 2019-07-26 13:39:37 +0000 | [diff] [blame] | 171 | // oltUpDownIndication handles Up and Down state of an OLT |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 172 | func (em *OpenOltEventMgr) oltUpDownIndication(oltIndication *oop.OltIndication, deviceID string, raisedTs int64) error { |
Daniele Rossi | 051466a | 2019-07-26 13:39:37 +0000 | [diff] [blame] | 173 | var de voltha.DeviceEvent |
| 174 | context := make(map[string]string) |
| 175 | /* Populating event context */ |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 176 | context["oper-state"] = oltIndication.OperState |
Daniele Rossi | 051466a | 2019-07-26 13:39:37 +0000 | [diff] [blame] | 177 | /* Populating device event body */ |
| 178 | de.Context = context |
| 179 | de.ResourceId = deviceID |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 180 | if oltIndication.OperState == operationStateDown { |
Daniele Rossi | 051466a | 2019-07-26 13:39:37 +0000 | [diff] [blame] | 181 | de.DeviceEventName = fmt.Sprintf("%s_%s", oltIndicationDown, "RAISE_EVENT") |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 182 | } else if oltIndication.OperState == operationStateUp { |
Daniele Rossi | 051466a | 2019-07-26 13:39:37 +0000 | [diff] [blame] | 183 | de.DeviceEventName = fmt.Sprintf("%s_%s", oltIndicationDown, "CLEAR_EVENT") |
| 184 | } |
| 185 | /* Send event to KAFKA */ |
| 186 | if err := em.eventProxy.SendDeviceEvent(&de, communication, olt, raisedTs); err != nil { |
Girish Kumar | f26e488 | 2020-03-05 06:49:10 +0000 | [diff] [blame] | 187 | return olterrors.NewErrCommunication("send-olt-event", log.Fields{"device-id": deviceID}, err) |
Daniele Rossi | 051466a | 2019-07-26 13:39:37 +0000 | [diff] [blame] | 188 | } |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 189 | logger.Debugw("OLT UpDown event sent to KAFKA", log.Fields{}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 190 | return nil |
Daniele Rossi | 051466a | 2019-07-26 13:39:37 +0000 | [diff] [blame] | 191 | } |
| 192 | |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 193 | // OnuDiscoveryIndication is an exported method to handle ONU discovery event |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 194 | func (em *OpenOltEventMgr) OnuDiscoveryIndication(onuDisc *oop.OnuDiscIndication, deviceID string, OnuID uint32, serialNumber string, raisedTs int64) error { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 195 | var de voltha.DeviceEvent |
| 196 | context := make(map[string]string) |
| 197 | /* Populating event context */ |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 198 | context["onu-id"] = strconv.FormatUint(uint64(OnuID), base10) |
| 199 | context["intf-id"] = strconv.FormatUint(uint64(onuDisc.IntfId), base10) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 200 | context["serial-number"] = serialNumber |
| 201 | /* Populating device event body */ |
| 202 | de.Context = context |
| 203 | de.ResourceId = deviceID |
| 204 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuDiscoveryEvent, "RAISE_EVENT") |
| 205 | /* Send event to KAFKA */ |
| 206 | if err := em.eventProxy.SendDeviceEvent(&de, equipment, pon, raisedTs); err != nil { |
Girish Kumar | f26e488 | 2020-03-05 06:49:10 +0000 | [diff] [blame] | 207 | return olterrors.NewErrCommunication("send-onu-discovery-event", log.Fields{"serial-number": serialNumber, "intf-id": onuDisc.IntfId}, err) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 208 | } |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 209 | logger.Debugw("ONU discovery event sent to KAFKA", log.Fields{"serial-number": serialNumber, "intf-id": onuDisc.IntfId}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 210 | return nil |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 211 | } |
| 212 | |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 213 | func (em *OpenOltEventMgr) oltLosIndication(oltLos *oop.LosIndication, deviceID string, raisedTs int64) error { |
Thiyagarajan Subramani | 34a0028 | 2020-03-10 20:19:31 +0530 | [diff] [blame] | 214 | var err error = nil |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 215 | var de voltha.DeviceEvent |
Thiyagarajan Subramani | 34a0028 | 2020-03-10 20:19:31 +0530 | [diff] [blame] | 216 | var alarmInd oop.OnuAlarmIndication |
| 217 | ponIntdID := PortNoToIntfID(oltLos.IntfId, voltha.Port_PON_OLT) |
| 218 | |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 219 | context := make(map[string]string) |
| 220 | /* Populating event context */ |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 221 | context["intf-id"] = strconv.FormatUint(uint64(oltLos.IntfId), base10) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 222 | /* Populating device event body */ |
| 223 | de.Context = context |
| 224 | de.ResourceId = deviceID |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 225 | if oltLos.Status == statusCheckOn { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 226 | de.DeviceEventName = fmt.Sprintf("%s_%s", oltLosEvent, "RAISE_EVENT") |
Thiyagarajan Subramani | 34a0028 | 2020-03-10 20:19:31 +0530 | [diff] [blame] | 227 | |
| 228 | /* When PON cable disconnected from OLT, it was expected OnuAlarmIndication |
| 229 | with "los_status: on" should be raised for each Onu connected to the PON |
| 230 | but BAL does not raise this Alarm hence manually sending OnuLosRaise event |
| 231 | for all the ONU's connected to PON on receiving LoSIndication for PON */ |
| 232 | em.handler.onus.Range(func(Onukey interface{}, onuInCache interface{}) bool { |
| 233 | if onuInCache.(*OnuDevice).intfID == ponIntdID { |
| 234 | alarmInd.IntfId = ponIntdID |
| 235 | alarmInd.OnuId = onuInCache.(*OnuDevice).onuID |
| 236 | alarmInd.LosStatus = statusCheckOn |
| 237 | err = em.onuAlarmIndication(&alarmInd, deviceID, raisedTs) |
| 238 | } |
| 239 | return true |
| 240 | }) |
| 241 | if err != nil { |
| 242 | /* Return if any error encountered while processing ONU LoS Event*/ |
| 243 | return err |
| 244 | } |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 245 | } else { |
| 246 | de.DeviceEventName = fmt.Sprintf("%s_%s", oltLosEvent, "CLEAR_EVENT") |
| 247 | } |
| 248 | /* Send event to KAFKA */ |
| 249 | if err := em.eventProxy.SendDeviceEvent(&de, communication, olt, raisedTs); err != nil { |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 250 | return err |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 251 | } |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 252 | logger.Debugw("OLT LOS event sent to KAFKA", log.Fields{"intf-id": oltLos.IntfId}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 253 | return nil |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 254 | } |
| 255 | |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 256 | func (em *OpenOltEventMgr) onuDyingGaspIndication(dgi *oop.DyingGaspIndication, deviceID string, raisedTs int64) error { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 257 | var de voltha.DeviceEvent |
Devmalya Paul | 90ca301 | 2019-09-02 21:55:45 -0400 | [diff] [blame] | 258 | var serialNumber string |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 259 | context := make(map[string]string) |
| 260 | /* Populating event context */ |
Devmalya Paul | 90ca301 | 2019-09-02 21:55:45 -0400 | [diff] [blame] | 261 | serialNumber = "" |
Naga Manjunath | a8dc937 | 2019-10-31 23:01:18 +0530 | [diff] [blame] | 262 | onu := em.handler.formOnuKey(dgi.IntfId, dgi.OnuId) |
| 263 | if onu, ok := em.handler.onus.Load(onu); ok { |
| 264 | serialNumber = onu.(*OnuDevice).serialNumber |
Devmalya Paul | 90ca301 | 2019-09-02 21:55:45 -0400 | [diff] [blame] | 265 | } |
| 266 | context["serial-number"] = serialNumber |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 267 | context["intf-id"] = strconv.FormatUint(uint64(dgi.IntfId), base10) |
| 268 | context["onu-id"] = strconv.FormatUint(uint64(dgi.OnuId), base10) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 269 | /* Populating device event body */ |
| 270 | de.Context = context |
| 271 | de.ResourceId = deviceID |
Thomas Lee S | f68399e | 2020-02-11 15:41:38 +0530 | [diff] [blame] | 272 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuDyingGaspEvent, "EVENT") |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 273 | /* Send event to KAFKA */ |
| 274 | if err := em.eventProxy.SendDeviceEvent(&de, communication, pon, raisedTs); err != nil { |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 275 | return err |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 276 | } |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 277 | logger.Debugw("ONU dying gasp event sent to KAFKA", log.Fields{"intf-id": dgi.IntfId}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 278 | return nil |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 279 | } |
| 280 | |
Thiyagarajan Subramani | 34a0028 | 2020-03-10 20:19:31 +0530 | [diff] [blame] | 281 | //wasLosRaised checks whether los raised already. If already raised returns true else false |
| 282 | func (em *OpenOltEventMgr) wasLosRaised(onuAlarm *oop.OnuAlarmIndication) bool { |
| 283 | onuKey := em.handler.formOnuKey(onuAlarm.IntfId, onuAlarm.OnuId) |
| 284 | if onuInCache, ok := em.handler.onus.Load(onuKey); ok { |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 285 | logger.Debugw("onu-device-found-in-cache.", log.Fields{"intfID": onuAlarm.IntfId, "onuID": onuAlarm.OnuId}) |
Thiyagarajan Subramani | 34a0028 | 2020-03-10 20:19:31 +0530 | [diff] [blame] | 286 | |
| 287 | if onuAlarm.LosStatus == statusCheckOn { |
| 288 | if onuInCache.(*OnuDevice).losRaised { |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 289 | logger.Warnw("onu-los-raised-already", log.Fields{"onu_id": onuAlarm.OnuId, |
Thiyagarajan Subramani | 34a0028 | 2020-03-10 20:19:31 +0530 | [diff] [blame] | 290 | "intf_id": onuAlarm.IntfId, "LosStatus": onuAlarm.LosStatus}) |
| 291 | return true |
| 292 | } |
| 293 | return false |
| 294 | } |
| 295 | } |
| 296 | return true |
| 297 | } |
| 298 | |
| 299 | //wasLosCleared checks whether los cleared already. If already cleared returns true else false |
| 300 | func (em *OpenOltEventMgr) wasLosCleared(onuAlarm *oop.OnuAlarmIndication) bool { |
| 301 | onuKey := em.handler.formOnuKey(onuAlarm.IntfId, onuAlarm.OnuId) |
| 302 | if onuInCache, ok := em.handler.onus.Load(onuKey); ok { |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 303 | logger.Debugw("onu-device-found-in-cache.", log.Fields{"intfID": onuAlarm.IntfId, "onuID": onuAlarm.OnuId}) |
Thiyagarajan Subramani | 34a0028 | 2020-03-10 20:19:31 +0530 | [diff] [blame] | 304 | |
| 305 | if onuAlarm.LosStatus == statusCheckOff { |
| 306 | if !onuInCache.(*OnuDevice).losRaised { |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 307 | logger.Warnw("onu-los-cleared-already", log.Fields{"onu_id": onuAlarm.OnuId, |
Thiyagarajan Subramani | 34a0028 | 2020-03-10 20:19:31 +0530 | [diff] [blame] | 308 | "intf_id": onuAlarm.IntfId, "LosStatus": onuAlarm.LosStatus}) |
| 309 | return true |
| 310 | } |
| 311 | return false |
| 312 | } |
| 313 | } |
| 314 | return true |
| 315 | } |
| 316 | |
| 317 | func (em *OpenOltEventMgr) getDeviceEventName(onuAlarm *oop.OnuAlarmIndication) string { |
| 318 | var deviceEventName string |
| 319 | if onuAlarm.LosStatus == statusCheckOn { |
| 320 | deviceEventName = fmt.Sprintf("%s_%s", onuLosEvent, "RAISE_EVENT") |
| 321 | } else if onuAlarm.LosStatus == statusCheckOff { |
| 322 | deviceEventName = fmt.Sprintf("%s_%s", onuLosEvent, "CLEAR_EVENT") |
| 323 | } else if onuAlarm.LobStatus == statusCheckOn { |
| 324 | deviceEventName = fmt.Sprintf("%s_%s", onuLobEvent, "RAISE_EVENT") |
| 325 | } else if onuAlarm.LobStatus == statusCheckOff { |
| 326 | deviceEventName = fmt.Sprintf("%s_%s", onuLobEvent, "CLEAR_EVENT") |
| 327 | } else if onuAlarm.LopcMissStatus == statusCheckOn { |
| 328 | deviceEventName = fmt.Sprintf("%s_%s", onuLopcMissEvent, "RAISE_EVENT") |
| 329 | } else if onuAlarm.LopcMissStatus == statusCheckOff { |
| 330 | deviceEventName = fmt.Sprintf("%s_%s", onuLopcMissEvent, "CLEAR_EVENT") |
| 331 | } else if onuAlarm.LopcMicErrorStatus == statusCheckOn { |
| 332 | deviceEventName = fmt.Sprintf("%s_%s", onuLopcMicErrorEvent, "RAISE_EVENT") |
| 333 | } else if onuAlarm.LopcMicErrorStatus == statusCheckOff { |
| 334 | deviceEventName = fmt.Sprintf("%s_%s", onuLopcMicErrorEvent, "CLEAR_EVENT") |
| 335 | } else if onuAlarm.LofiStatus == statusCheckOn { |
| 336 | deviceEventName = fmt.Sprintf("%s_%s", onuLossOfFrameEvent, "RAISE_EVENT") |
| 337 | } else if onuAlarm.LofiStatus == statusCheckOff { |
| 338 | deviceEventName = fmt.Sprintf("%s_%s", onuLossOfFrameEvent, "CLEAR_EVENT") |
| 339 | } else if onuAlarm.LoamiStatus == statusCheckOn { |
| 340 | deviceEventName = fmt.Sprintf("%s_%s", onuLossOfPloamEvent, "RAISE_EVENT") |
| 341 | } else if onuAlarm.LoamiStatus == statusCheckOff { |
| 342 | deviceEventName = fmt.Sprintf("%s_%s", onuLossOfPloamEvent, "CLEAR_EVENT") |
| 343 | } |
| 344 | return deviceEventName |
| 345 | } |
| 346 | |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 347 | func (em *OpenOltEventMgr) onuAlarmIndication(onuAlarm *oop.OnuAlarmIndication, deviceID string, raisedTs int64) error { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 348 | var de voltha.DeviceEvent |
Thiyagarajan Subramani | 34a0028 | 2020-03-10 20:19:31 +0530 | [diff] [blame] | 349 | var serialNumber string |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 350 | context := make(map[string]string) |
| 351 | /* Populating event context */ |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 352 | context["intf-id"] = strconv.FormatUint(uint64(onuAlarm.IntfId), base10) |
| 353 | context["onu-id"] = strconv.FormatUint(uint64(onuAlarm.OnuId), base10) |
Thiyagarajan Subramani | 34a0028 | 2020-03-10 20:19:31 +0530 | [diff] [blame] | 354 | serialNumber = "" |
| 355 | onuKey := em.handler.formOnuKey(onuAlarm.IntfId, onuAlarm.OnuId) |
| 356 | if onu, ok := em.handler.onus.Load(onuKey); ok { |
| 357 | serialNumber = onu.(*OnuDevice).serialNumber |
| 358 | } |
| 359 | context["serial-number"] = serialNumber |
| 360 | |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 361 | /* Populating device event body */ |
| 362 | de.Context = context |
| 363 | de.ResourceId = deviceID |
Thiyagarajan Subramani | 34a0028 | 2020-03-10 20:19:31 +0530 | [diff] [blame] | 364 | de.DeviceEventName = em.getDeviceEventName(onuAlarm) |
| 365 | |
| 366 | switch onuAlarm.LosStatus { |
| 367 | case statusCheckOn: |
| 368 | if em.wasLosRaised(onuAlarm) { |
| 369 | /* No need to raise Onu Los Event as it might have already raised |
| 370 | or Onu might have deleted */ |
| 371 | return nil |
| 372 | } |
| 373 | onuKey := em.handler.formOnuKey(onuAlarm.IntfId, onuAlarm.OnuId) |
| 374 | if onuInCache, ok := em.handler.onus.Load(onuKey); ok { |
| 375 | /* Update onu device with LoS raised state as true */ |
| 376 | em.handler.onus.Store(onuKey, NewOnuDevice(onuInCache.(*OnuDevice).deviceID, onuInCache.(*OnuDevice).deviceType, |
| 377 | onuInCache.(*OnuDevice).serialNumber, onuInCache.(*OnuDevice).onuID, onuInCache.(*OnuDevice).intfID, |
| 378 | onuInCache.(*OnuDevice).proxyDeviceID, true)) |
| 379 | } |
| 380 | case statusCheckOff: |
| 381 | if em.wasLosCleared(onuAlarm) { |
| 382 | /* No need to clear Onu Los Event as it might have already cleared |
| 383 | or Onu might have deleted */ |
| 384 | return nil |
| 385 | } |
| 386 | onuKey := em.handler.formOnuKey(onuAlarm.IntfId, onuAlarm.OnuId) |
| 387 | if onuInCache, ok := em.handler.onus.Load(onuKey); ok { |
| 388 | /* Update onu device with LoS raised state as false */ |
| 389 | em.handler.onus.Store(onuKey, NewOnuDevice(onuInCache.(*OnuDevice).deviceID, onuInCache.(*OnuDevice).deviceType, |
| 390 | onuInCache.(*OnuDevice).serialNumber, onuInCache.(*OnuDevice).onuID, onuInCache.(*OnuDevice).intfID, |
| 391 | onuInCache.(*OnuDevice).proxyDeviceID, false)) |
| 392 | } |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 393 | } |
Thiyagarajan Subramani | 34a0028 | 2020-03-10 20:19:31 +0530 | [diff] [blame] | 394 | |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 395 | /* Send event to KAFKA */ |
| 396 | if err := em.eventProxy.SendDeviceEvent(&de, communication, onu, raisedTs); err != nil { |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 397 | return err |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 398 | } |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 399 | logger.Debugw("ONU LOS event sent to KAFKA", log.Fields{"onu-id": onuAlarm.OnuId, "intf-id": onuAlarm.IntfId}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 400 | return nil |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 401 | } |
| 402 | |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 403 | func (em *OpenOltEventMgr) onuActivationFailIndication(oaf *oop.OnuActivationFailureIndication, deviceID string, raisedTs int64) error { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 404 | var de voltha.DeviceEvent |
| 405 | context := make(map[string]string) |
| 406 | /* Populating event context */ |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 407 | context["intf-id"] = strconv.FormatUint(uint64(oaf.IntfId), base10) |
| 408 | context["onu-id"] = strconv.FormatUint(uint64(oaf.OnuId), base10) |
Scott Baker | d4df118 | 2020-02-05 11:38:42 -0800 | [diff] [blame] | 409 | context["fail-reason"] = strconv.FormatUint(uint64(oaf.FailReason), base10) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 410 | /* Populating device event body */ |
| 411 | de.Context = context |
| 412 | de.ResourceId = deviceID |
| 413 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuActivationFailEvent, "RAISE_EVENT") |
| 414 | /* Send event to KAFKA */ |
| 415 | if err := em.eventProxy.SendDeviceEvent(&de, equipment, pon, raisedTs); err != nil { |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 416 | return err |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 417 | } |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 418 | logger.Debugw("ONU activation failure event sent to KAFKA", log.Fields{"onu-id": oaf.OnuId, "intf-id": oaf.IntfId}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 419 | return nil |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 420 | } |
| 421 | |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 422 | func (em *OpenOltEventMgr) onuLossOmciIndication(onuLossOmci *oop.OnuLossOfOmciChannelIndication, deviceID string, raisedTs int64) error { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 423 | var de voltha.DeviceEvent |
| 424 | context := make(map[string]string) |
| 425 | /* Populating event context */ |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 426 | context["intf-id"] = strconv.FormatUint(uint64(onuLossOmci.IntfId), base10) |
| 427 | context["onu-id"] = strconv.FormatUint(uint64(onuLossOmci.OnuId), base10) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 428 | /* Populating device event body */ |
| 429 | de.Context = context |
| 430 | de.ResourceId = deviceID |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 431 | if onuLossOmci.Status == statusCheckOn { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 432 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuLossOmciEvent, "RAISE_EVENT") |
| 433 | } else { |
| 434 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuLossOmciEvent, "CLEAR_EVENT") |
| 435 | } |
| 436 | /* Send event to KAFKA */ |
| 437 | if err := em.eventProxy.SendDeviceEvent(&de, communication, pon, raisedTs); err != nil { |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 438 | return err |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 439 | } |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 440 | logger.Debugw("ONU loss of OMCI channel event sent to KAFKA", log.Fields{"onu-id": onuLossOmci.OnuId, "intf-id": onuLossOmci.IntfId}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 441 | return nil |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 442 | } |
| 443 | |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 444 | func (em *OpenOltEventMgr) onuDriftOfWindowIndication(onuDriftWindow *oop.OnuDriftOfWindowIndication, deviceID string, raisedTs int64) error { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 445 | var de voltha.DeviceEvent |
| 446 | context := make(map[string]string) |
| 447 | /* Populating event context */ |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 448 | context["intf-id"] = strconv.FormatUint(uint64(onuDriftWindow.IntfId), base10) |
| 449 | context["onu-id"] = strconv.FormatUint(uint64(onuDriftWindow.OnuId), base10) |
Scott Baker | d4df118 | 2020-02-05 11:38:42 -0800 | [diff] [blame] | 450 | context["drift"] = strconv.FormatUint(uint64(onuDriftWindow.Drift), base10) |
| 451 | context["new-eqd"] = strconv.FormatUint(uint64(onuDriftWindow.NewEqd), base10) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 452 | /* Populating device event body */ |
| 453 | de.Context = context |
| 454 | de.ResourceId = deviceID |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 455 | if onuDriftWindow.Status == statusCheckOn { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 456 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuDriftOfWindowEvent, "RAISE_EVENT") |
| 457 | } else { |
| 458 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuDriftOfWindowEvent, "CLEAR_EVENT") |
| 459 | } |
| 460 | /* Send event to KAFKA */ |
| 461 | if err := em.eventProxy.SendDeviceEvent(&de, communication, pon, raisedTs); err != nil { |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 462 | return err |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 463 | } |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 464 | logger.Debugw("ONU drift of window event sent to KAFKA", log.Fields{"onu-id": onuDriftWindow.OnuId, "intf-id": onuDriftWindow.IntfId}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 465 | return nil |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 466 | } |
| 467 | |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 468 | func (em *OpenOltEventMgr) onuSignalDegradeIndication(onuSignalDegrade *oop.OnuSignalDegradeIndication, deviceID string, raisedTs int64) error { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 469 | var de voltha.DeviceEvent |
| 470 | context := make(map[string]string) |
| 471 | /* Populating event context */ |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 472 | context["intf-id"] = strconv.FormatUint(uint64(onuSignalDegrade.IntfId), base10) |
| 473 | context["onu-id"] = strconv.FormatUint(uint64(onuSignalDegrade.OnuId), base10) |
Scott Baker | d4df118 | 2020-02-05 11:38:42 -0800 | [diff] [blame] | 474 | context["inverse-bit-error-rate"] = strconv.FormatUint(uint64(onuSignalDegrade.InverseBitErrorRate), base10) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 475 | /* Populating device event body */ |
| 476 | de.Context = context |
| 477 | de.ResourceId = deviceID |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 478 | if onuSignalDegrade.Status == statusCheckOn { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 479 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuSignalDegradeEvent, "RAISE_EVENT") |
| 480 | } else { |
| 481 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuSignalDegradeEvent, "CLEAR_EVENT") |
| 482 | } |
| 483 | /* Send event to KAFKA */ |
| 484 | if err := em.eventProxy.SendDeviceEvent(&de, communication, pon, raisedTs); err != nil { |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 485 | return err |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 486 | } |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 487 | logger.Debugw("ONU signal degrade event sent to KAFKA", log.Fields{"onu-id": onuSignalDegrade.OnuId, "intf-id": onuSignalDegrade.IntfId}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 488 | return nil |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 489 | } |
| 490 | |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 491 | func (em *OpenOltEventMgr) onuSignalsFailIndication(onuSignalsFail *oop.OnuSignalsFailureIndication, deviceID string, raisedTs int64) error { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 492 | var de voltha.DeviceEvent |
| 493 | context := make(map[string]string) |
| 494 | /* Populating event context */ |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 495 | context["onu-id"] = strconv.FormatUint(uint64(onuSignalsFail.OnuId), base10) |
| 496 | context["intf-id"] = strconv.FormatUint(uint64(onuSignalsFail.IntfId), base10) |
| 497 | context["inverse-bit-error-rate"] = strconv.FormatUint(uint64(onuSignalsFail.InverseBitErrorRate), base10) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 498 | /* Populating device event body */ |
| 499 | de.Context = context |
| 500 | de.ResourceId = deviceID |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 501 | if onuSignalsFail.Status == statusCheckOn { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 502 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuSignalsFailEvent, "RAISE_EVENT") |
| 503 | } else { |
| 504 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuSignalsFailEvent, "CLEAR_EVENT") |
| 505 | } |
| 506 | /* Send event to KAFKA */ |
| 507 | if err := em.eventProxy.SendDeviceEvent(&de, communication, pon, raisedTs); err != nil { |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 508 | return err |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 509 | } |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 510 | logger.Debugw("ONU signals fail event sent to KAFKA", log.Fields{"onu-id": onuSignalsFail.OnuId, "intf-id": onuSignalsFail.IntfId}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 511 | return nil |
| 512 | } |
| 513 | |
Naga Manjunath | f6f7464 | 2020-01-13 21:37:28 +0530 | [diff] [blame] | 514 | func (em *OpenOltEventMgr) onuStartupFailedIndication(onuStartupFail *oop.OnuStartupFailureIndication, deviceID string, raisedTs int64) error { |
| 515 | var de voltha.DeviceEvent |
| 516 | context := make(map[string]string) |
| 517 | /* Populating event context */ |
| 518 | context["onu-id"] = strconv.FormatUint(uint64(onuStartupFail.OnuId), base10) |
| 519 | context["intf-id"] = strconv.FormatUint(uint64(onuStartupFail.IntfId), base10) |
| 520 | |
| 521 | /* Populating device event body */ |
| 522 | de.Context = context |
| 523 | de.ResourceId = deviceID |
| 524 | if onuStartupFail.Status == statusCheckOn { |
| 525 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuStartupFailEvent, "RAISE_EVENT") |
| 526 | } else { |
| 527 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuStartupFailEvent, "CLEAR_EVENT") |
| 528 | } |
| 529 | /* Send event to KAFKA */ |
| 530 | if err := em.eventProxy.SendDeviceEvent(&de, communication, pon, raisedTs); err != nil { |
Naga Manjunath | f6f7464 | 2020-01-13 21:37:28 +0530 | [diff] [blame] | 531 | return err |
| 532 | } |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 533 | logger.Debugw("ONU startup fail event sent to KAFKA", log.Fields{"onu-id": onuStartupFail.OnuId, "intf-id": onuStartupFail.IntfId}) |
Naga Manjunath | f6f7464 | 2020-01-13 21:37:28 +0530 | [diff] [blame] | 534 | return nil |
| 535 | } |
| 536 | |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 537 | func (em *OpenOltEventMgr) onuLossOfSyncIndication(onuLOKI *oop.OnuLossOfKeySyncFailureIndication, deviceID string, raisedTs int64) error { |
| 538 | var de voltha.DeviceEvent |
| 539 | context := make(map[string]string) |
| 540 | /* Populating event context */ |
| 541 | context["onu-id"] = strconv.FormatUint(uint64(onuLOKI.OnuId), base10) |
| 542 | context["intf-id"] = strconv.FormatUint(uint64(onuLOKI.IntfId), base10) |
| 543 | /* Populating device event body */ |
| 544 | de.Context = context |
| 545 | de.ResourceId = deviceID |
| 546 | if onuLOKI.Status == statusCheckOn { |
| 547 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuLossOfKeySyncEvent, "RAISE_EVENT") |
| 548 | } else { |
| 549 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuLossOfKeySyncEvent, "CLEAR_EVENT") |
| 550 | } |
| 551 | |
| 552 | /* Send event to KAFKA */ |
| 553 | if err := em.eventProxy.SendDeviceEvent(&de, security, onu, raisedTs); err != nil { |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 554 | return err |
| 555 | } |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 556 | logger.Debugw("ONU loss of key sync event sent to KAFKA", log.Fields{"onu-id": onuLOKI.OnuId, "intf-id": onuLOKI.IntfId}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 557 | return nil |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 558 | } |
kesavand | 39e0aa3 | 2020-01-28 20:58:50 -0500 | [diff] [blame] | 559 | |
| 560 | // oltIntfOperIndication handles Up and Down state of an OLT PON ports |
Devmalya Paul | 2440047 | 2020-03-12 19:26:02 -0400 | [diff] [blame] | 561 | func (em *OpenOltEventMgr) oltIntfOperIndication(ifindication *oop.IntfOperIndication, deviceID string, raisedTs int64) error { |
kesavand | 39e0aa3 | 2020-01-28 20:58:50 -0500 | [diff] [blame] | 562 | var de voltha.DeviceEvent |
| 563 | context := make(map[string]string) |
| 564 | portID := IntfIDToPortNo(ifindication.IntfId, voltha.Port_PON_OLT) |
| 565 | device, err := em.handler.coreProxy.GetDevice(ctx.Background(), deviceID, deviceID) |
| 566 | if err != nil { |
Devmalya Paul | 2440047 | 2020-03-12 19:26:02 -0400 | [diff] [blame] | 567 | return olterrors.NewErrAdapter("Error while fetching Device object", log.Fields{"DeviceId": deviceID}, err) |
kesavand | 39e0aa3 | 2020-01-28 20:58:50 -0500 | [diff] [blame] | 568 | } |
| 569 | for _, port := range device.Ports { |
| 570 | if port.PortNo == portID { |
| 571 | // Events are suppressed if the Port Adminstate is not enabled. |
| 572 | if port.AdminState != common.AdminState_ENABLED { |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 573 | logger.Debugw("Port disable/enable event not generated because, The port is not enabled by operator", log.Fields{"deviceId": deviceID, "port": port}) |
Devmalya Paul | 2440047 | 2020-03-12 19:26:02 -0400 | [diff] [blame] | 574 | return nil |
kesavand | 39e0aa3 | 2020-01-28 20:58:50 -0500 | [diff] [blame] | 575 | } |
| 576 | break |
| 577 | } |
| 578 | } |
| 579 | /* Populating event context */ |
| 580 | context["oper-state"] = ifindication.GetOperState() |
| 581 | /* Populating device event body */ |
| 582 | de.Context = context |
| 583 | de.ResourceId = deviceID |
| 584 | |
| 585 | if ifindication.GetOperState() == operationStateDown { |
| 586 | de.DeviceEventName = fmt.Sprintf("%s_%s", ponIntfDownIndiction, "RAISE_EVENT") |
| 587 | } else if ifindication.OperState == operationStateUp { |
| 588 | de.DeviceEventName = fmt.Sprintf("%s_%s", ponIntfDownIndiction, "CLEAR_EVENT") |
| 589 | } |
| 590 | /* Send event to KAFKA */ |
| 591 | if err := em.eventProxy.SendDeviceEvent(&de, communication, olt, raisedTs); err != nil { |
Devmalya Paul | 2440047 | 2020-03-12 19:26:02 -0400 | [diff] [blame] | 592 | return olterrors.NewErrCommunication("send-olt-intf-oper-status-event", log.Fields{"device-id": deviceID, "intf-id": ifindication.IntfId, "oper-state": ifindication.OperState}, err).Log() |
kesavand | 39e0aa3 | 2020-01-28 20:58:50 -0500 | [diff] [blame] | 593 | } |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 594 | logger.Debug("sent-olt-intf-oper-status-event-to-kafka") |
Devmalya Paul | 2440047 | 2020-03-12 19:26:02 -0400 | [diff] [blame] | 595 | return nil |
kesavand | 39e0aa3 | 2020-01-28 20:58:50 -0500 | [diff] [blame] | 596 | } |
Devmalya Paul | 1abc34e | 2020-02-04 20:48:06 -0500 | [diff] [blame] | 597 | |
| 598 | func (em *OpenOltEventMgr) onuDeactivationFailureIndication(onuDFI *oop.OnuDeactivationFailureIndication, deviceID string, raisedTs int64) error { |
| 599 | var de voltha.DeviceEvent |
| 600 | context := make(map[string]string) |
| 601 | /* Populating event context */ |
| 602 | context["onu-id"] = strconv.FormatUint(uint64(onuDFI.OnuId), base10) |
| 603 | context["intf-id"] = strconv.FormatUint(uint64(onuDFI.IntfId), base10) |
| 604 | context["failure-reason"] = strconv.FormatUint(uint64(onuDFI.FailReason), base10) |
| 605 | /* Populating device event body */ |
| 606 | de.Context = context |
| 607 | de.ResourceId = deviceID |
| 608 | de.DeviceEventName = onuDeactivationFailureEvent |
| 609 | |
| 610 | /* Send event to KAFKA */ |
| 611 | if err := em.eventProxy.SendDeviceEvent(&de, equipment, onu, raisedTs); err != nil { |
Devmalya Paul | 1abc34e | 2020-02-04 20:48:06 -0500 | [diff] [blame] | 612 | return err |
| 613 | } |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 614 | logger.Debugw("ONU deactivation failure event sent to KAFKA", log.Fields{"onu-id": onuDFI.OnuId, "intf-id": onuDFI.IntfId}) |
Devmalya Paul | 1abc34e | 2020-02-04 20:48:06 -0500 | [diff] [blame] | 615 | return nil |
| 616 | } |
Devmalya Paul | 6f063a6 | 2020-02-19 19:19:06 -0500 | [diff] [blame] | 617 | |
| 618 | func (em *OpenOltEventMgr) onuRemoteDefectIndication(onuRDI *oop.OnuRemoteDefectIndication, deviceID string, raisedTs int64) error { |
| 619 | /* Populating event context */ |
| 620 | context := map[string]string{ |
| 621 | "onu-id": strconv.FormatUint(uint64(onuRDI.OnuId), base10), |
| 622 | "intf-id": strconv.FormatUint(uint64(onuRDI.IntfId), base10), |
| 623 | "rdi-errors": strconv.FormatUint(uint64(onuRDI.RdiErrors), base10), |
| 624 | } |
| 625 | /* Populating device event body */ |
| 626 | de := &voltha.DeviceEvent{ |
| 627 | Context: context, |
| 628 | ResourceId: deviceID, |
| 629 | DeviceEventName: onuRemoteDefectIndication, |
| 630 | } |
| 631 | /* Send event to KAFKA */ |
| 632 | if err := em.eventProxy.SendDeviceEvent(de, equipment, onu, raisedTs); err != nil { |
Devmalya Paul | 6f063a6 | 2020-02-19 19:19:06 -0500 | [diff] [blame] | 633 | return err |
| 634 | } |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 635 | logger.Debugw("ONU remote defect event sent to KAFKA", log.Fields{"onu-id": onuRDI.OnuId, "intf-id": onuRDI.IntfId}) |
Devmalya Paul | 41a762d | 2020-03-01 18:56:54 -0500 | [diff] [blame] | 636 | return nil |
| 637 | } |
| 638 | |
| 639 | func (em *OpenOltEventMgr) onuLossOfGEMChannelDelineationIndication(onuGCD *oop.OnuLossOfGEMChannelDelineationIndication, deviceID string, raisedTs int64) error { |
| 640 | /* Populating event context */ |
| 641 | context := map[string]string{ |
| 642 | "onu-id": strconv.FormatUint(uint64(onuGCD.OnuId), base10), |
| 643 | "intf-id": strconv.FormatUint(uint64(onuGCD.IntfId), base10), |
| 644 | "delineation-errors": strconv.FormatUint(uint64(onuGCD.DelineationErrors), base10), |
| 645 | } |
| 646 | /* Populating device event body */ |
| 647 | de := &voltha.DeviceEvent{ |
| 648 | Context: context, |
| 649 | ResourceId: deviceID, |
| 650 | } |
| 651 | if onuGCD.Status == statusCheckOn { |
| 652 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuLossOfGEMChannelDelineationEvent, "RAISE_EVENT") |
| 653 | } else { |
| 654 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuLossOfGEMChannelDelineationEvent, "CLEAR_EVENT") |
| 655 | } |
| 656 | /* Send event to KAFKA */ |
| 657 | if err := em.eventProxy.SendDeviceEvent(de, communication, onu, raisedTs); err != nil { |
| 658 | return err |
| 659 | } |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 660 | logger.Debugw("ONU loss of GEM channel delineation event sent to KAFKA", log.Fields{"onu-id": onuGCD.OnuId, "intf-id": onuGCD.IntfId}) |
Devmalya Paul | 41a762d | 2020-03-01 18:56:54 -0500 | [diff] [blame] | 661 | return nil |
| 662 | } |
| 663 | |
| 664 | func (em *OpenOltEventMgr) onuPhysicalEquipmentErrorIndication(onuErr *oop.OnuPhysicalEquipmentErrorIndication, deviceID string, raisedTs int64) error { |
| 665 | /* Populating event context */ |
| 666 | context := map[string]string{ |
| 667 | "onu-id": strconv.FormatUint(uint64(onuErr.OnuId), base10), |
| 668 | "intf-id": strconv.FormatUint(uint64(onuErr.IntfId), base10), |
| 669 | } |
| 670 | /* Populating device event body */ |
| 671 | de := &voltha.DeviceEvent{ |
| 672 | Context: context, |
| 673 | ResourceId: deviceID, |
| 674 | } |
| 675 | if onuErr.Status == statusCheckOn { |
| 676 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuPhysicalEquipmentErrorEvent, "RAISE_EVENT") |
| 677 | } else { |
| 678 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuPhysicalEquipmentErrorEvent, "CLEAR_EVENT") |
| 679 | } |
| 680 | /* Send event to KAFKA */ |
| 681 | if err := em.eventProxy.SendDeviceEvent(de, equipment, onu, raisedTs); err != nil { |
| 682 | return err |
| 683 | } |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 684 | logger.Debugw("ONU physical equipment error event sent to KAFKA", log.Fields{"onu-id": onuErr.OnuId, "intf-id": onuErr.IntfId}) |
Devmalya Paul | 41a762d | 2020-03-01 18:56:54 -0500 | [diff] [blame] | 685 | return nil |
| 686 | } |
| 687 | |
| 688 | func (em *OpenOltEventMgr) onuLossOfAcknowledgementIndication(onuLOA *oop.OnuLossOfAcknowledgementIndication, deviceID string, raisedTs int64) error { |
| 689 | /* Populating event context */ |
| 690 | context := map[string]string{ |
| 691 | "onu-id": strconv.FormatUint(uint64(onuLOA.OnuId), base10), |
| 692 | "intf-id": strconv.FormatUint(uint64(onuLOA.IntfId), base10), |
| 693 | } |
| 694 | /* Populating device event body */ |
| 695 | de := &voltha.DeviceEvent{ |
| 696 | Context: context, |
| 697 | ResourceId: deviceID, |
| 698 | } |
| 699 | if onuLOA.Status == statusCheckOn { |
| 700 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuLossOfAcknowledgementEvent, "RAISE_EVENT") |
| 701 | } else { |
| 702 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuLossOfAcknowledgementEvent, "CLEAR_EVENT") |
| 703 | } |
| 704 | /* Send event to KAFKA */ |
| 705 | if err := em.eventProxy.SendDeviceEvent(de, equipment, onu, raisedTs); err != nil { |
| 706 | return err |
| 707 | } |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 708 | logger.Debugw("ONU physical equipment error event sent to KAFKA", log.Fields{"onu-id": onuLOA.OnuId, "intf-id": onuLOA.IntfId}) |
Devmalya Paul | 6f063a6 | 2020-02-19 19:19:06 -0500 | [diff] [blame] | 709 | return nil |
| 710 | } |
Devmalya Paul | eb5294e | 2020-03-19 03:01:39 -0400 | [diff] [blame] | 711 | |
| 712 | func (em *OpenOltEventMgr) onuDifferentialReachExceededIndication(onuDRE *oop.OnuDifferentialReachExceededIndication, deviceID string, raisedTs int64) error { |
| 713 | /* Populating event context */ |
| 714 | context := map[string]string{ |
| 715 | "onu-id": strconv.FormatUint(uint64(onuDRE.OnuId), base10), |
| 716 | "intf-id": strconv.FormatUint(uint64(onuDRE.IntfId), base10), |
| 717 | "differential-distance": strconv.FormatUint(uint64(onuDRE.Distance), base10), |
| 718 | } |
| 719 | /* Populating device event body */ |
| 720 | de := &voltha.DeviceEvent{ |
| 721 | Context: context, |
| 722 | ResourceId: deviceID, |
| 723 | } |
| 724 | if onuDRE.Status == statusCheckOn { |
| 725 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuDifferentialReachExceededEvent, "RAISE_EVENT") |
| 726 | } else { |
| 727 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuDifferentialReachExceededEvent, "CLEAR_EVENT") |
| 728 | } |
| 729 | /* Send event to KAFKA */ |
| 730 | if err := em.eventProxy.SendDeviceEvent(de, equipment, onu, raisedTs); err != nil { |
| 731 | return err |
| 732 | } |
| 733 | log.Debugw("ONU differential reach exceeded event sent to KAFKA", log.Fields{"onu-id": onuDRE.OnuId, "intf-id": onuDRE.IntfId}) |
| 734 | return nil |
| 735 | } |