| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 1 | /* |
| Joey Armstrong | 11f5a57 | 2024-01-12 19:11:32 -0500 | [diff] [blame] | 2 | * Copyright 2018-2024 Open Networking Foundation (ONF) and the ONF Contributors |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 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 ( |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 21 | "context" |
| Devmalya Paul | a1efa64 | 2020-04-20 01:36:43 -0400 | [diff] [blame] | 22 | "errors" |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 23 | "fmt" |
| Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 24 | "strconv" |
| Naga Manjunath | a8dc937 | 2019-10-31 23:01:18 +0530 | [diff] [blame] | 25 | |
| khenaidoo | dc2116e | 2021-10-19 17:33:19 -0400 | [diff] [blame] | 26 | ca "github.com/opencord/voltha-protos/v5/go/core_adapter" |
| khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 27 | |
| 28 | "github.com/opencord/voltha-lib-go/v7/pkg/events/eventif" |
| 29 | "github.com/opencord/voltha-lib-go/v7/pkg/log" |
| Mahir Gunyel | 85f61c1 | 2021-10-06 11:53:45 -0700 | [diff] [blame] | 30 | plt "github.com/opencord/voltha-lib-go/v7/pkg/platform" |
| Thomas Lee S | 94109f1 | 2020-03-03 16:39:29 +0530 | [diff] [blame] | 31 | "github.com/opencord/voltha-openolt-adapter/internal/pkg/olterrors" |
| khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 32 | "github.com/opencord/voltha-protos/v5/go/common" |
| 33 | oop "github.com/opencord/voltha-protos/v5/go/openolt" |
| 34 | "github.com/opencord/voltha-protos/v5/go/voltha" |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 35 | ) |
| 36 | |
| 37 | const ( |
| Devmalya Paul | 41a762d | 2020-03-01 18:56:54 -0500 | [diff] [blame] | 38 | onuDiscoveryEvent = "ONU_DISCOVERY" |
| 39 | onuLosEvent = "ONU_LOSS_OF_SIGNAL" |
| 40 | onuLobEvent = "ONU_LOSS_OF_BURST" |
| 41 | onuLopcMissEvent = "ONU_LOPC_MISS" |
| 42 | onuLopcMicErrorEvent = "ONU_LOPC_MIC_ERROR" |
| 43 | oltLosEvent = "OLT_LOSS_OF_SIGNAL" |
| Gustavo Silva | 41af912 | 2022-10-11 11:05:13 -0300 | [diff] [blame] | 44 | oltRebootFailedEvent = "OLT_REBOOT_FAILED" |
| Gamze Abaka | 07868a5 | 2020-12-17 14:19:28 +0000 | [diff] [blame] | 45 | oltCommFailure = "OLT_COMMUNICATION_FAILURE" |
| Devmalya Paul | 41a762d | 2020-03-01 18:56:54 -0500 | [diff] [blame] | 46 | oltIndicationDown = "OLT_DOWN_INDICATION" |
| 47 | onuDyingGaspEvent = "ONU_DYING_GASP" |
| 48 | onuSignalsFailEvent = "ONU_SIGNALS_FAIL" |
| 49 | onuStartupFailEvent = "ONU_STARTUP_FAIL" |
| 50 | onuSignalDegradeEvent = "ONU_SIGNAL_DEGRADE" |
| 51 | onuDriftOfWindowEvent = "ONU_DRIFT_OF_WINDOW" |
| 52 | onuActivationFailEvent = "ONU_ACTIVATION_FAIL" |
| Devmalya Paul | 41a762d | 2020-03-01 18:56:54 -0500 | [diff] [blame] | 53 | onuLossOmciEvent = "ONU_LOSS_OF_OMCI_CHANNEL" |
| 54 | onuLossOfKeySyncEvent = "ONU_LOSS_OF_KEY_SYNC" |
| 55 | onuLossOfFrameEvent = "ONU_LOSS_OF_FRAME" |
| 56 | onuLossOfPloamEvent = "ONU_LOSS_OF_PLOAM" |
| balaji.nagarajan | 68f56e8 | 2025-07-04 15:16:01 +0530 | [diff] [blame] | 57 | onuDisableEvent = "ONU_DISABLE" |
| 58 | onuEnableEvent = "ONU_ENABLE" |
| Devmalya Paul | 41a762d | 2020-03-01 18:56:54 -0500 | [diff] [blame] | 59 | ponIntfDownIndiction = "OLT_PON_INTERFACE_DOWN" |
| 60 | onuDeactivationFailureEvent = "ONU_DEACTIVATION_FAILURE" |
| 61 | onuRemoteDefectIndication = "ONU_REMOTE_DEFECT" |
| 62 | onuLossOfGEMChannelDelineationEvent = "ONU_LOSS_OF_GEM_CHANNEL_DELINEATION" |
| 63 | onuPhysicalEquipmentErrorEvent = "ONU_PHYSICAL_EQUIPMENT_ERROR" |
| 64 | onuLossOfAcknowledgementEvent = "ONU_LOSS_OF_ACKNOWLEDGEMENT" |
| Devmalya Paul | eb5294e | 2020-03-19 03:01:39 -0400 | [diff] [blame] | 65 | onuDifferentialReachExceededEvent = "ONU_DIFFERENTIAL_REACH_EXCEEDED" |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 66 | ) |
| 67 | |
| 68 | const ( |
| Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 69 | // statusCheckOn represents status check On |
| 70 | statusCheckOn = "on" |
| 71 | // statusCheckOff represents status check Off |
| 72 | statusCheckOff = "off" |
| 73 | // operationStateUp represents operation state Up |
| 74 | operationStateUp = "up" |
| 75 | // operationStateDown represents operation state Down |
| 76 | operationStateDown = "down" |
| 77 | // base10 represents base 10 conversion |
| 78 | base10 = 10 |
| 79 | ) |
| 80 | |
| Amit Ghosh | 502056b | 2020-07-15 09:15:48 +0100 | [diff] [blame] | 81 | const ( |
| Gamze Abaka | 07868a5 | 2020-12-17 14:19:28 +0000 | [diff] [blame] | 82 | // ContextOltAdminState is for the admin state of the Olt in the context of the event |
| 83 | ContextOltAdminState = "admin-state" |
| 84 | // ContextOltConnectState is for the connect state of the Olt in the context of the event |
| 85 | ContextOltConnectState = "connect-state" |
| Gustavo Silva | 41af912 | 2022-10-11 11:05:13 -0300 | [diff] [blame] | 86 | // ContextOltFailureReason is to report the reason of an operation failure in the Olt |
| 87 | ContextOltFailureReason = "failure-reason" |
| Amit Ghosh | 502056b | 2020-07-15 09:15:48 +0100 | [diff] [blame] | 88 | // ContextOltOperState is for the operational state of the Olt in the context of the event |
| 89 | ContextOltOperState = "oper-state" |
| Gamze Abaka | 07868a5 | 2020-12-17 14:19:28 +0000 | [diff] [blame] | 90 | // ContextOltVendor is for the Olt vendor in the context of the event |
| 91 | ContextOltVendor = "vendor" |
| 92 | // ContextOltType is for the Olt type in the context of the event |
| 93 | ContextOltType = "type" |
| 94 | // ContextOltParentID is for the Olt parent id in the context of the event |
| 95 | ContextOltParentID = "parent-id" |
| 96 | // ContextOltParentPortNo is for the Olt parent port no in the context of the event |
| 97 | ContextOltParentPortNo = "parent-port-no" |
| 98 | // ContextOltFirmwareVersion is for the Olt firmware version in the context of the event |
| 99 | ContextOltFirmwareVersion = "firmware-version" |
| 100 | // ContextOltHardwareVersion is for the Olt hardware version in the context of the event |
| 101 | ContextOltHardwareVersion = "hardware-version" |
| 102 | // ContextOltSerialNumber is for the serial number of the OLT |
| 103 | ContextOltSerialNumber = "serial-number" |
| 104 | // ContextOltMacAddress is for the OLT mac address |
| 105 | ContextOltMacAddress = "mac-address" |
| 106 | // ContextDeviceID is for the device id in the context of the event |
| 107 | ContextDeviceID = "id" |
| Amit Ghosh | 502056b | 2020-07-15 09:15:48 +0100 | [diff] [blame] | 108 | // ContextOnuOnuID is for the Onu Id in the context of the event |
| 109 | ContextOnuOnuID = "onu-id" |
| 110 | // ContextOnuPonIntfID is for the PON interface Id on which the Onu Event occurred |
| 111 | ContextOnuPonIntfID = "intf-id" |
| 112 | // ContextOnuSerialNumber is for the serial number of the ONU |
| 113 | ContextOnuSerialNumber = "serial-number" |
| 114 | // ContextOnuDeviceID is for the device id of the ONU generated by VOLTHA |
| 115 | ContextOnuDeviceID = "onu-device-id" |
| 116 | // ContextOltPonIntfID is for the PON interface Id on an OLT event |
| 117 | ContextOltPonIntfID = "intf-id" |
| 118 | // ContextOnuFailureReaseon is for the reason of failure of/at ONU indicated by the event |
| 119 | ContextOnuFailureReaseon = "fail-reason" |
| 120 | // ContextOnuDrift is for the drift of an ONU in the context of an event |
| 121 | ContextOnuDrift = "drift" |
| 122 | // ContextOnuNewEqd is for the New Eqd of an ONU in the context of an event |
| 123 | ContextOnuNewEqd = "new-eqd" |
| 124 | // ContextOnuInverseBitErrorRate is for the inverse bit error rate in the context of an ONU event |
| 125 | ContextOnuInverseBitErrorRate = "inverse-bit-error-rate" |
| 126 | // ContextOltPonIntfOperState is for the operational state of a PON port in the context of an OLT event |
| 127 | ContextOltPonIntfOperState = "oper-state" |
| 128 | // ContextOnuRemoteDefectIndicatorCount is for the rdi in the context of an ONU event |
| 129 | ContextOnuRemoteDefectIndicatorCount = "rdi-count" |
| 130 | // ContextOnuDelineationErrors is for the delineation errors if present in an ONU events context |
| 131 | ContextOnuDelineationErrors = "delineation-errors" |
| 132 | // ContextOnuDifferentialDistance is for the differential distance in an ONU event context |
| 133 | ContextOnuDifferentialDistance = "differential-distance" |
| ssiddiqui | 04386ee | 2021-08-23 21:58:25 +0530 | [diff] [blame] | 134 | // ContextOltPonTechnology is to indicate the pon-technology type, ie, 'GPON' or 'XGS-PON' (TODO check for combo?) |
| 135 | ContextOltPonTechnology = "pon-technology" |
| 136 | // ContextOltPortLabel is to indicate the string label of the pon-port, example: pon-0 |
| 137 | ContextOltPortLabel = "port-label" |
| Amit Ghosh | 502056b | 2020-07-15 09:15:48 +0100 | [diff] [blame] | 138 | ) |
| 139 | |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 140 | // OpenOltEventMgr struct contains |
| 141 | type OpenOltEventMgr struct { |
| Himani Chawla | cd40780 | 2020-12-10 12:08:59 +0530 | [diff] [blame] | 142 | eventProxy eventif.EventProxy |
| Devmalya Paul | 90ca301 | 2019-09-02 21:55:45 -0400 | [diff] [blame] | 143 | handler *DeviceHandler |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 144 | } |
| 145 | |
| 146 | // NewEventMgr is a Function to get a new event manager struct for the OpenOLT to process and publish OpenOLT event |
| Himani Chawla | cd40780 | 2020-12-10 12:08:59 +0530 | [diff] [blame] | 147 | func NewEventMgr(eventProxy eventif.EventProxy, handler *DeviceHandler) *OpenOltEventMgr { |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 148 | var em OpenOltEventMgr |
| 149 | em.eventProxy = eventProxy |
| Devmalya Paul | 90ca301 | 2019-09-02 21:55:45 -0400 | [diff] [blame] | 150 | em.handler = handler |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 151 | return &em |
| 152 | } |
| 153 | |
| 154 | // ProcessEvents is function to process and publish OpenOLT event |
| Devmalya Paul | 41a762d | 2020-03-01 18:56:54 -0500 | [diff] [blame] | 155 | // nolint: gocyclo |
| Kent Hagerman | e6ff101 | 2020-07-14 15:07:53 -0400 | [diff] [blame] | 156 | func (em *OpenOltEventMgr) ProcessEvents(ctx context.Context, alarmInd *oop.AlarmIndication, deviceID string, raisedTs int64) { |
| Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 157 | var err error |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 158 | switch alarmInd.Data.(type) { |
| 159 | case *oop.AlarmIndication_LosInd: |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 160 | logger.Debugw(ctx, "received-los-indication", log.Fields{"alarm-ind": alarmInd}) |
| 161 | err = em.oltLosIndication(ctx, alarmInd.GetLosInd(), deviceID, raisedTs) |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 162 | case *oop.AlarmIndication_OnuAlarmInd: |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 163 | logger.Debugw(ctx, "received-onu-alarm-indication ", log.Fields{"alarm-ind": alarmInd}) |
| 164 | err = em.onuAlarmIndication(ctx, alarmInd.GetOnuAlarmInd(), deviceID, raisedTs) |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 165 | case *oop.AlarmIndication_DyingGaspInd: |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 166 | logger.Debugw(ctx, "received-dying-gasp-indication", log.Fields{"alarm-ind": alarmInd}) |
| 167 | err = em.onuDyingGaspIndication(ctx, alarmInd.GetDyingGaspInd(), deviceID, raisedTs) |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 168 | case *oop.AlarmIndication_OnuLossOmciInd: |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 169 | logger.Debugw(ctx, "received-onu-loss-omci-indication ", log.Fields{"alarm-ind": alarmInd}) |
| 170 | err = em.onuLossOmciIndication(ctx, alarmInd.GetOnuLossOmciInd(), deviceID, raisedTs) |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 171 | case *oop.AlarmIndication_OnuDriftOfWindowInd: |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 172 | logger.Debugw(ctx, "received-onu-drift-of-window-indication ", log.Fields{"alarm-ind": alarmInd}) |
| 173 | err = em.onuDriftOfWindowIndication(ctx, alarmInd.GetOnuDriftOfWindowInd(), deviceID, raisedTs) |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 174 | case *oop.AlarmIndication_OnuSignalDegradeInd: |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 175 | logger.Debugw(ctx, "received-onu-signal-degrade-indication ", log.Fields{"alarm-ind": alarmInd}) |
| 176 | err = em.onuSignalDegradeIndication(ctx, alarmInd.GetOnuSignalDegradeInd(), deviceID, raisedTs) |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 177 | case *oop.AlarmIndication_OnuSignalsFailInd: |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 178 | logger.Debugw(ctx, "received-onu-signal-fail-indication ", log.Fields{"alarm-ind": alarmInd}) |
| 179 | err = em.onuSignalsFailIndication(ctx, alarmInd.GetOnuSignalsFailInd(), deviceID, raisedTs) |
| Naga Manjunath | f6f7464 | 2020-01-13 21:37:28 +0530 | [diff] [blame] | 180 | case *oop.AlarmIndication_OnuStartupFailInd: |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 181 | logger.Debugw(ctx, "received-onu-startup-fail-indication ", log.Fields{"alarm-ind": alarmInd}) |
| 182 | err = em.onuStartupFailedIndication(ctx, alarmInd.GetOnuStartupFailInd(), deviceID, raisedTs) |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 183 | case *oop.AlarmIndication_OnuTiwiInd: |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 184 | logger.Debugw(ctx, "received-onu-transmission-warning-indication ", log.Fields{"alarm-ind": alarmInd}) |
| 185 | logger.Warnw(ctx, "not-implemented-yet", log.Fields{"alarm-ind": "Onu-Transmission-indication"}) |
| Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 186 | case *oop.AlarmIndication_OnuLossOfSyncFailInd: |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 187 | logger.Debugw(ctx, "received-onu-loss-of-sync-fail-indication ", log.Fields{"alarm-ind": alarmInd}) |
| 188 | err = em.onuLossOfSyncIndication(ctx, alarmInd.GetOnuLossOfSyncFailInd(), deviceID, raisedTs) |
| Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 189 | case *oop.AlarmIndication_OnuItuPonStatsInd: |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 190 | logger.Debugw(ctx, "received-onu-itu-pon-stats-indication ", log.Fields{"alarm-ind": alarmInd}) |
| 191 | err = em.onuItuPonStatsIndication(ctx, alarmInd.GetOnuItuPonStatsInd(), deviceID, raisedTs) |
| Devmalya Paul | 1abc34e | 2020-02-04 20:48:06 -0500 | [diff] [blame] | 192 | case *oop.AlarmIndication_OnuDeactivationFailureInd: |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 193 | logger.Debugw(ctx, "received-onu-deactivation-failure-indication ", log.Fields{"alarm-ind": alarmInd}) |
| 194 | err = em.onuDeactivationFailureIndication(ctx, alarmInd.GetOnuDeactivationFailureInd(), deviceID, raisedTs) |
| Devmalya Paul | 41a762d | 2020-03-01 18:56:54 -0500 | [diff] [blame] | 195 | case *oop.AlarmIndication_OnuLossGemDelineationInd: |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 196 | logger.Debugw(ctx, "received-onu-loss-of-gem-channel-delineation-indication ", log.Fields{"alarm-ind": alarmInd}) |
| 197 | err = em.onuLossOfGEMChannelDelineationIndication(ctx, alarmInd.GetOnuLossGemDelineationInd(), deviceID, raisedTs) |
| Devmalya Paul | 41a762d | 2020-03-01 18:56:54 -0500 | [diff] [blame] | 198 | case *oop.AlarmIndication_OnuPhysicalEquipmentErrorInd: |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 199 | logger.Debugw(ctx, "received-onu-physical-equipment-error-indication ", log.Fields{"alarm-ind": alarmInd}) |
| 200 | err = em.onuPhysicalEquipmentErrorIndication(ctx, alarmInd.GetOnuPhysicalEquipmentErrorInd(), deviceID, raisedTs) |
| Devmalya Paul | 41a762d | 2020-03-01 18:56:54 -0500 | [diff] [blame] | 201 | case *oop.AlarmIndication_OnuLossOfAckInd: |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 202 | logger.Debugw(ctx, "received-onu-loss-of-acknowledgement-indication ", log.Fields{"alarm-ind": alarmInd}) |
| 203 | err = em.onuLossOfAcknowledgementIndication(ctx, alarmInd.GetOnuLossOfAckInd(), deviceID, raisedTs) |
| Devmalya Paul | eb5294e | 2020-03-19 03:01:39 -0400 | [diff] [blame] | 204 | case *oop.AlarmIndication_OnuDiffReachExceededInd: |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 205 | logger.Debugw(ctx, "received-onu-differential-reach-exceeded-indication ", log.Fields{"alarm-ind": alarmInd}) |
| 206 | err = em.onuDifferentialReachExceededIndication(ctx, alarmInd.GetOnuDiffReachExceededInd(), deviceID, raisedTs) |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 207 | default: |
| Thomas Lee S | 94109f1 | 2020-03-03 16:39:29 +0530 | [diff] [blame] | 208 | err = olterrors.NewErrInvalidValue(log.Fields{"indication-type": alarmInd}, nil) |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 209 | } |
| Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 210 | if err != nil { |
| Kent Hagerman | e6ff101 | 2020-07-14 15:07:53 -0400 | [diff] [blame] | 211 | _ = olterrors.NewErrCommunication("publish-message", log.Fields{"indication-type": alarmInd}, err).LogAt(log.WarnLevel) |
| Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 212 | } |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 213 | } |
| 214 | |
| Gamze Abaka | 07868a5 | 2020-12-17 14:19:28 +0000 | [diff] [blame] | 215 | func (em *OpenOltEventMgr) oltCommunicationEvent(ctx context.Context, device *voltha.Device, raisedTs int64) { |
| 216 | if device == nil { |
| 217 | logger.Warn(ctx, "device-is-nil-can't-send-olt-communication-failure-event") |
| 218 | return |
| 219 | } |
| 220 | var de voltha.DeviceEvent |
| 221 | context := make(map[string]string) |
| 222 | context[ContextOltOperState] = device.OperStatus.String() |
| 223 | context[ContextOltAdminState] = device.AdminState.String() |
| 224 | context[ContextOltVendor] = device.Vendor |
| 225 | context[ContextOltConnectState] = device.ConnectStatus.String() |
| 226 | context[ContextOltType] = device.Type |
| 227 | context[ContextOltParentID] = device.ParentId |
| 228 | context[ContextOltParentPortNo] = fmt.Sprintf("%d", device.ParentPortNo) |
| 229 | context[ContextDeviceID] = device.Id |
| 230 | context[ContextOltFirmwareVersion] = device.FirmwareVersion |
| 231 | context[ContextOltHardwareVersion] = device.HardwareVersion |
| 232 | context[ContextOltSerialNumber] = device.SerialNumber |
| 233 | context[ContextOltMacAddress] = device.MacAddress |
| 234 | de.Context = context |
| 235 | de.ResourceId = device.Id |
| 236 | |
| 237 | if device.ConnectStatus == voltha.ConnectStatus_UNREACHABLE { |
| 238 | de.DeviceEventName = fmt.Sprintf("%s_%s", oltCommFailure, "RAISE_EVENT") |
| 239 | } else { |
| 240 | de.DeviceEventName = fmt.Sprintf("%s_%s", oltCommFailure, "CLEAR_EVENT") |
| 241 | } |
| 242 | |
| 243 | if err := em.eventProxy.SendDeviceEvent(ctx, &de, voltha.EventCategory_COMMUNICATION, voltha.EventSubCategory_OLT, raisedTs); err != nil { |
| 244 | logger.Errorw(ctx, "failed-to-send-olt-comm-failure-event", log.Fields{"err": err}) |
| 245 | } |
| 246 | logger.Debugw(ctx, "olt-comm-failure-event-sent-to-kafka", |
| 247 | log.Fields{ |
| 248 | "device-id": device.Id, |
| 249 | "connect-status": device.ConnectStatus, |
| 250 | }) |
| 251 | } |
| 252 | |
| Daniele Rossi | 051466a | 2019-07-26 13:39:37 +0000 | [diff] [blame] | 253 | // oltUpDownIndication handles Up and Down state of an OLT |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 254 | func (em *OpenOltEventMgr) oltUpDownIndication(ctx context.Context, oltIndication *oop.OltIndication, deviceID string, raisedTs int64) error { |
| Daniele Rossi | 051466a | 2019-07-26 13:39:37 +0000 | [diff] [blame] | 255 | var de voltha.DeviceEvent |
| 256 | context := make(map[string]string) |
| 257 | /* Populating event context */ |
| Amit Ghosh | 502056b | 2020-07-15 09:15:48 +0100 | [diff] [blame] | 258 | context[ContextOltOperState] = oltIndication.OperState |
| Daniele Rossi | 051466a | 2019-07-26 13:39:37 +0000 | [diff] [blame] | 259 | /* Populating device event body */ |
| 260 | de.Context = context |
| 261 | de.ResourceId = deviceID |
| mgouda | 8654358 | 2025-10-29 20:58:16 +0530 | [diff] [blame] | 262 | switch oltIndication.OperState { |
| 263 | case operationStateDown: |
| Daniele Rossi | 051466a | 2019-07-26 13:39:37 +0000 | [diff] [blame] | 264 | de.DeviceEventName = fmt.Sprintf("%s_%s", oltIndicationDown, "RAISE_EVENT") |
| mgouda | 8654358 | 2025-10-29 20:58:16 +0530 | [diff] [blame] | 265 | case operationStateUp: |
| Daniele Rossi | 051466a | 2019-07-26 13:39:37 +0000 | [diff] [blame] | 266 | de.DeviceEventName = fmt.Sprintf("%s_%s", oltIndicationDown, "CLEAR_EVENT") |
| 267 | } |
| 268 | /* Send event to KAFKA */ |
| Kent Hagerman | e6ff101 | 2020-07-14 15:07:53 -0400 | [diff] [blame] | 269 | if err := em.eventProxy.SendDeviceEvent(ctx, &de, voltha.EventCategory_COMMUNICATION, voltha.EventSubCategory_OLT, raisedTs); err != nil { |
| Girish Kumar | f26e488 | 2020-03-05 06:49:10 +0000 | [diff] [blame] | 270 | return olterrors.NewErrCommunication("send-olt-event", log.Fields{"device-id": deviceID}, err) |
| Daniele Rossi | 051466a | 2019-07-26 13:39:37 +0000 | [diff] [blame] | 271 | } |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 272 | logger.Debugw(ctx, "olt-updown-event-sent-to-kafka", log.Fields{}) |
| Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 273 | return nil |
| Daniele Rossi | 051466a | 2019-07-26 13:39:37 +0000 | [diff] [blame] | 274 | } |
| 275 | |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 276 | // OnuDiscoveryIndication is an exported method to handle ONU discovery event |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 277 | func (em *OpenOltEventMgr) OnuDiscoveryIndication(ctx context.Context, onuDisc *oop.OnuDiscIndication, oltDeviceID string, onuDeviceID string, OnuID uint32, serialNumber string, raisedTs int64) error { |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 278 | var de voltha.DeviceEvent |
| 279 | context := make(map[string]string) |
| 280 | /* Populating event context */ |
| Amit Ghosh | 502056b | 2020-07-15 09:15:48 +0100 | [diff] [blame] | 281 | context[ContextOnuOnuID] = strconv.FormatUint(uint64(OnuID), base10) |
| 282 | context[ContextOnuPonIntfID] = strconv.FormatUint(uint64(onuDisc.IntfId), base10) |
| 283 | context[ContextOnuSerialNumber] = serialNumber |
| 284 | context[ContextOnuDeviceID] = onuDeviceID |
| ssiddiqui | 04386ee | 2021-08-23 21:58:25 +0530 | [diff] [blame] | 285 | context[ContextOltPonTechnology] = em.handler.getPonTechnology(onuDisc.IntfId) |
| 286 | context[ContextOltPortLabel], _ = GetportLabel(onuDisc.GetIntfId(), voltha.Port_PON_OLT) |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 287 | /* Populating device event body */ |
| 288 | de.Context = context |
| Amit Ghosh | 75f0e29 | 2020-05-14 11:31:54 +0100 | [diff] [blame] | 289 | de.ResourceId = oltDeviceID |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 290 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuDiscoveryEvent, "RAISE_EVENT") |
| 291 | /* Send event to KAFKA */ |
| kesavand | 0ef592c | 2022-03-16 12:34:24 +0530 | [diff] [blame] | 292 | if err := em.eventProxy.SendDeviceEventWithKey(ctx, &de, voltha.EventCategory_EQUIPMENT, voltha.EventSubCategory_PON, raisedTs, onuDeviceID); err != nil { |
| Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 293 | return olterrors.NewErrCommunication("send-onu-discovery-event", |
| 294 | log.Fields{ |
| 295 | "serial-number": serialNumber, |
| 296 | "intf-id": onuDisc.IntfId}, err) |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 297 | } |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 298 | logger.Debugw(ctx, "onu-discovery-event-sent-to-kafka", |
| Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 299 | log.Fields{ |
| 300 | "serial-number": serialNumber, |
| 301 | "intf-id": onuDisc.IntfId}) |
| Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 302 | return nil |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 303 | } |
| 304 | |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 305 | func (em *OpenOltEventMgr) oltLosIndication(ctx context.Context, oltLos *oop.LosIndication, deviceID string, raisedTs int64) error { |
| Thiyagarajan Subramani | 34a0028 | 2020-03-10 20:19:31 +0530 | [diff] [blame] | 306 | var err error = nil |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 307 | var de voltha.DeviceEvent |
| Thiyagarajan Subramani | 34a0028 | 2020-03-10 20:19:31 +0530 | [diff] [blame] | 308 | var alarmInd oop.OnuAlarmIndication |
| Mahir Gunyel | 85f61c1 | 2021-10-06 11:53:45 -0700 | [diff] [blame] | 309 | ponIntdID := plt.PortNoToIntfID(oltLos.IntfId, voltha.Port_PON_OLT) |
| Thiyagarajan Subramani | 34a0028 | 2020-03-10 20:19:31 +0530 | [diff] [blame] | 310 | |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 311 | context := make(map[string]string) |
| 312 | /* Populating event context */ |
| yasin sapli | 0b24294 | 2021-10-11 08:51:16 +0000 | [diff] [blame] | 313 | context[ContextOltPonIntfID] = strconv.FormatUint(uint64(ponIntdID), base10) |
| Abhilash Laxmeshwar | 42b5824 | 2021-11-24 19:27:25 +0530 | [diff] [blame] | 314 | context[ContextOltPortLabel], _ = GetportLabel(oltLos.IntfId, voltha.Port_PON_OLT) |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 315 | /* Populating device event body */ |
| 316 | de.Context = context |
| 317 | de.ResourceId = deviceID |
| Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 318 | if oltLos.Status == statusCheckOn { |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 319 | de.DeviceEventName = fmt.Sprintf("%s_%s", oltLosEvent, "RAISE_EVENT") |
| Thiyagarajan Subramani | 34a0028 | 2020-03-10 20:19:31 +0530 | [diff] [blame] | 320 | |
| 321 | /* When PON cable disconnected from OLT, it was expected OnuAlarmIndication |
| 322 | with "los_status: on" should be raised for each Onu connected to the PON |
| 323 | but BAL does not raise this Alarm hence manually sending OnuLosRaise event |
| 324 | for all the ONU's connected to PON on receiving LoSIndication for PON */ |
| 325 | em.handler.onus.Range(func(Onukey interface{}, onuInCache interface{}) bool { |
| 326 | if onuInCache.(*OnuDevice).intfID == ponIntdID { |
| 327 | alarmInd.IntfId = ponIntdID |
| 328 | alarmInd.OnuId = onuInCache.(*OnuDevice).onuID |
| 329 | alarmInd.LosStatus = statusCheckOn |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 330 | err = em.onuAlarmIndication(ctx, &alarmInd, deviceID, raisedTs) |
| Thiyagarajan Subramani | 34a0028 | 2020-03-10 20:19:31 +0530 | [diff] [blame] | 331 | } |
| 332 | return true |
| 333 | }) |
| 334 | if err != nil { |
| 335 | /* Return if any error encountered while processing ONU LoS Event*/ |
| 336 | return err |
| 337 | } |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 338 | } else { |
| 339 | de.DeviceEventName = fmt.Sprintf("%s_%s", oltLosEvent, "CLEAR_EVENT") |
| 340 | } |
| 341 | /* Send event to KAFKA */ |
| Andrea Campanella | 4dea631 | 2021-02-23 10:06:18 +0100 | [diff] [blame] | 342 | if err := em.eventProxy.SendDeviceEvent(ctx, &de, voltha.EventCategory_COMMUNICATION, voltha.EventSubCategory_PON, raisedTs); err != nil { |
| Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 343 | return err |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 344 | } |
| yasin sapli | 0b24294 | 2021-10-11 08:51:16 +0000 | [diff] [blame] | 345 | logger.Debugw(ctx, "olt-los-event-sent-to-kafka", log.Fields{"intf-id": ponIntdID}) |
| Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 346 | return nil |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 347 | } |
| Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame] | 348 | |
| Gustavo Silva | 41af912 | 2022-10-11 11:05:13 -0300 | [diff] [blame] | 349 | func (em *OpenOltEventMgr) oltRebootFailedEvent(ctx context.Context, deviceID string, reason string, raisedTs int64) error { |
| 350 | de := voltha.DeviceEvent{ |
| 351 | Context: map[string]string{ContextOltFailureReason: "olt-reboot-failed"}, |
| 352 | ResourceId: deviceID, |
| 353 | DeviceEventName: fmt.Sprintf("%s_%s", oltRebootFailedEvent, "RAISE_EVENT")} |
| 354 | if err := em.eventProxy.SendDeviceEvent(ctx, &de, voltha.EventCategory_COMMUNICATION, voltha.EventSubCategory_OLT, |
| 355 | raisedTs); err != nil { |
| 356 | return olterrors.NewErrCommunication("send-olt-reboot-failed-event", log.Fields{ |
| Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame] | 357 | "device-id": deviceID, "raised-ts": raisedTs, "reason": reason}, err) |
| Gustavo Silva | 41af912 | 2022-10-11 11:05:13 -0300 | [diff] [blame] | 358 | } |
| 359 | logger.Debugw(ctx, "olt-reboot-failed-event-sent-to-kafka", log.Fields{ |
| Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame] | 360 | "device-id": deviceID, "raised-ts": raisedTs, "reason": reason}) |
| Gustavo Silva | 41af912 | 2022-10-11 11:05:13 -0300 | [diff] [blame] | 361 | return nil |
| 362 | } |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 363 | |
| kesavand | 0ef592c | 2022-03-16 12:34:24 +0530 | [diff] [blame] | 364 | func (em *OpenOltEventMgr) populateContextWithSerialDeviceID(context map[string]string, intfID, onuID uint32) string { |
| Amit Ghosh | 502056b | 2020-07-15 09:15:48 +0100 | [diff] [blame] | 365 | var serialNumber = "" |
| 366 | var onuDeviceID = "" |
| 367 | onu := em.handler.formOnuKey(intfID, onuID) |
| Naga Manjunath | a8dc937 | 2019-10-31 23:01:18 +0530 | [diff] [blame] | 368 | if onu, ok := em.handler.onus.Load(onu); ok { |
| 369 | serialNumber = onu.(*OnuDevice).serialNumber |
| Amit Ghosh | 502056b | 2020-07-15 09:15:48 +0100 | [diff] [blame] | 370 | onuDeviceID = onu.(*OnuDevice).deviceID |
| Devmalya Paul | 90ca301 | 2019-09-02 21:55:45 -0400 | [diff] [blame] | 371 | } |
| Amit Ghosh | 502056b | 2020-07-15 09:15:48 +0100 | [diff] [blame] | 372 | |
| ssiddiqui | 04386ee | 2021-08-23 21:58:25 +0530 | [diff] [blame] | 373 | context[ContextOltPortLabel], _ = GetportLabel(intfID, voltha.Port_PON_OLT) |
| Amit Ghosh | 502056b | 2020-07-15 09:15:48 +0100 | [diff] [blame] | 374 | context[ContextOnuSerialNumber] = serialNumber |
| 375 | context[ContextOnuDeviceID] = onuDeviceID |
| kesavand | 0ef592c | 2022-03-16 12:34:24 +0530 | [diff] [blame] | 376 | return onuDeviceID |
| Amit Ghosh | 502056b | 2020-07-15 09:15:48 +0100 | [diff] [blame] | 377 | } |
| 378 | |
| balaji.nagarajan | 68f56e8 | 2025-07-04 15:16:01 +0530 | [diff] [blame] | 379 | func (em *OpenOltEventMgr) onuDisableIndication(ctx context.Context, onui *oop.OnuDisabledIndication, parentDeviceID string, onuDev *OnuDevice, raisedTs int64) error { |
| 380 | var de voltha.DeviceEvent |
| 381 | context := make(map[string]string) |
| 382 | /* Populating event context */ |
| 383 | onuDeviceID := em.populateContextWithSerialDeviceID(context, onui.IntfId, onui.OnuId) |
| 384 | |
| 385 | context[ContextOnuPonIntfID] = strconv.FormatUint(uint64(onui.IntfId), base10) |
| 386 | context[ContextOnuOnuID] = strconv.FormatUint(uint64(onui.OnuId), base10) |
| 387 | context[ContextDeviceID] = onuDev.deviceID |
| 388 | context[ContextOnuSerialNumber] = onuDev.serialNumber |
| 389 | /* Populating device event body */ |
| 390 | de.Context = context |
| 391 | de.ResourceId = parentDeviceID |
| 392 | de.DeviceEventName = onuDisableEvent |
| 393 | /* Send event to KAFKA */ |
| 394 | if err := em.eventProxy.SendDeviceEventWithKey(ctx, &de, voltha.EventCategory_COMMUNICATION, voltha.EventSubCategory_ONU, raisedTs, onuDeviceID); err != nil { |
| 395 | return err |
| 396 | } |
| 397 | logger.Debugw(ctx, "onu-disabled-event-sent-to-kafka", log.Fields{"intf-id": onui.IntfId, "onu_id": onui.OnuId}) |
| 398 | return nil |
| 399 | } |
| 400 | |
| 401 | func (em *OpenOltEventMgr) onuEnableIndication(ctx context.Context, onui *oop.OnuEnabledIndication, deviceID string, onuDev *OnuDevice, raisedTs int64) error { |
| 402 | var de voltha.DeviceEvent |
| 403 | context := make(map[string]string) |
| 404 | /* Populating event context */ |
| 405 | onuDeviceID := em.populateContextWithSerialDeviceID(context, onui.IntfId, onui.OnuId) |
| 406 | |
| 407 | context[ContextOnuPonIntfID] = strconv.FormatUint(uint64(onui.IntfId), base10) |
| 408 | context[ContextOnuOnuID] = strconv.FormatUint(uint64(onui.OnuId), base10) |
| 409 | context[ContextDeviceID] = onuDev.deviceID |
| 410 | context[ContextOnuSerialNumber] = onuDev.serialNumber |
| 411 | /* Populating device event body */ |
| 412 | de.Context = context |
| 413 | de.ResourceId = deviceID |
| 414 | de.DeviceEventName = onuEnableEvent |
| 415 | /* Send event to KAFKA */ |
| 416 | if err := em.eventProxy.SendDeviceEventWithKey(ctx, &de, voltha.EventCategory_COMMUNICATION, voltha.EventSubCategory_ONU, raisedTs, onuDeviceID); err != nil { |
| 417 | return err |
| 418 | } |
| 419 | logger.Debugw(ctx, "onu-enabled-event-sent-to-kafka", log.Fields{"intf-id": onui.IntfId, "onu_id": onui.OnuId}) |
| 420 | return nil |
| 421 | } |
| 422 | |
| Amit Ghosh | 502056b | 2020-07-15 09:15:48 +0100 | [diff] [blame] | 423 | func (em *OpenOltEventMgr) onuDyingGaspIndication(ctx context.Context, dgi *oop.DyingGaspIndication, deviceID string, raisedTs int64) error { |
| 424 | var de voltha.DeviceEvent |
| 425 | context := make(map[string]string) |
| 426 | /* Populating event context */ |
| kesavand | 0ef592c | 2022-03-16 12:34:24 +0530 | [diff] [blame] | 427 | onuDeviceID := em.populateContextWithSerialDeviceID(context, dgi.IntfId, dgi.OnuId) |
| Amit Ghosh | 502056b | 2020-07-15 09:15:48 +0100 | [diff] [blame] | 428 | |
| 429 | context[ContextOnuPonIntfID] = strconv.FormatUint(uint64(dgi.IntfId), base10) |
| 430 | context[ContextOnuOnuID] = strconv.FormatUint(uint64(dgi.OnuId), base10) |
| 431 | |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 432 | /* Populating device event body */ |
| 433 | de.Context = context |
| 434 | de.ResourceId = deviceID |
| Marcos Aurelio Carrero (Furukawa) | 1992f99 | 2023-11-14 14:31:40 -0300 | [diff] [blame] | 435 | |
| 436 | if dgi.Status == statusCheckOn { |
| 437 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuDyingGaspEvent, "RAISE_EVENT") |
| 438 | } else { |
| 439 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuDyingGaspEvent, "CLEAR_EVENT") |
| 440 | } |
| 441 | |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 442 | /* Send event to KAFKA */ |
| kesavand | 0ef592c | 2022-03-16 12:34:24 +0530 | [diff] [blame] | 443 | if err := em.eventProxy.SendDeviceEventWithKey(ctx, &de, voltha.EventCategory_COMMUNICATION, voltha.EventSubCategory_ONU, raisedTs, onuDeviceID); err != nil { |
| Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 444 | return err |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 445 | } |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 446 | logger.Debugw(ctx, "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] | 447 | return nil |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 448 | } |
| 449 | |
| Joey Armstrong | 3f0e242 | 2023-07-05 18:25:41 -0400 | [diff] [blame] | 450 | // wasLosRaised checks whether los raised already. If already raised returns true else false |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 451 | func (em *OpenOltEventMgr) wasLosRaised(ctx context.Context, onuAlarm *oop.OnuAlarmIndication) bool { |
| Thiyagarajan Subramani | 34a0028 | 2020-03-10 20:19:31 +0530 | [diff] [blame] | 452 | onuKey := em.handler.formOnuKey(onuAlarm.IntfId, onuAlarm.OnuId) |
| 453 | if onuInCache, ok := em.handler.onus.Load(onuKey); ok { |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 454 | logger.Debugw(ctx, "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] | 455 | |
| 456 | if onuAlarm.LosStatus == statusCheckOn { |
| 457 | if onuInCache.(*OnuDevice).losRaised { |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 458 | logger.Warnw(ctx, "onu-los-raised-already", log.Fields{"onu_id": onuAlarm.OnuId, |
| Thiyagarajan Subramani | 34a0028 | 2020-03-10 20:19:31 +0530 | [diff] [blame] | 459 | "intf_id": onuAlarm.IntfId, "LosStatus": onuAlarm.LosStatus}) |
| 460 | return true |
| 461 | } |
| 462 | return false |
| 463 | } |
| 464 | } |
| 465 | return true |
| 466 | } |
| 467 | |
| Joey Armstrong | 3f0e242 | 2023-07-05 18:25:41 -0400 | [diff] [blame] | 468 | // wasLosCleared checks whether los cleared already. If already cleared returns true else false |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 469 | func (em *OpenOltEventMgr) wasLosCleared(ctx context.Context, onuAlarm *oop.OnuAlarmIndication) bool { |
| Thiyagarajan Subramani | 34a0028 | 2020-03-10 20:19:31 +0530 | [diff] [blame] | 470 | onuKey := em.handler.formOnuKey(onuAlarm.IntfId, onuAlarm.OnuId) |
| 471 | if onuInCache, ok := em.handler.onus.Load(onuKey); ok { |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 472 | logger.Debugw(ctx, "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] | 473 | |
| 474 | if onuAlarm.LosStatus == statusCheckOff { |
| 475 | if !onuInCache.(*OnuDevice).losRaised { |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 476 | logger.Warnw(ctx, "onu-los-cleared-already", log.Fields{"onu_id": onuAlarm.OnuId, |
| Thiyagarajan Subramani | 34a0028 | 2020-03-10 20:19:31 +0530 | [diff] [blame] | 477 | "intf_id": onuAlarm.IntfId, "LosStatus": onuAlarm.LosStatus}) |
| 478 | return true |
| 479 | } |
| 480 | return false |
| 481 | } |
| 482 | } |
| 483 | return true |
| 484 | } |
| 485 | |
| 486 | func (em *OpenOltEventMgr) getDeviceEventName(onuAlarm *oop.OnuAlarmIndication) string { |
| 487 | var deviceEventName string |
| 488 | if onuAlarm.LosStatus == statusCheckOn { |
| 489 | deviceEventName = fmt.Sprintf("%s_%s", onuLosEvent, "RAISE_EVENT") |
| 490 | } else if onuAlarm.LosStatus == statusCheckOff { |
| 491 | deviceEventName = fmt.Sprintf("%s_%s", onuLosEvent, "CLEAR_EVENT") |
| 492 | } else if onuAlarm.LobStatus == statusCheckOn { |
| 493 | deviceEventName = fmt.Sprintf("%s_%s", onuLobEvent, "RAISE_EVENT") |
| 494 | } else if onuAlarm.LobStatus == statusCheckOff { |
| 495 | deviceEventName = fmt.Sprintf("%s_%s", onuLobEvent, "CLEAR_EVENT") |
| 496 | } else if onuAlarm.LopcMissStatus == statusCheckOn { |
| 497 | deviceEventName = fmt.Sprintf("%s_%s", onuLopcMissEvent, "RAISE_EVENT") |
| 498 | } else if onuAlarm.LopcMissStatus == statusCheckOff { |
| 499 | deviceEventName = fmt.Sprintf("%s_%s", onuLopcMissEvent, "CLEAR_EVENT") |
| 500 | } else if onuAlarm.LopcMicErrorStatus == statusCheckOn { |
| 501 | deviceEventName = fmt.Sprintf("%s_%s", onuLopcMicErrorEvent, "RAISE_EVENT") |
| 502 | } else if onuAlarm.LopcMicErrorStatus == statusCheckOff { |
| 503 | deviceEventName = fmt.Sprintf("%s_%s", onuLopcMicErrorEvent, "CLEAR_EVENT") |
| 504 | } else if onuAlarm.LofiStatus == statusCheckOn { |
| 505 | deviceEventName = fmt.Sprintf("%s_%s", onuLossOfFrameEvent, "RAISE_EVENT") |
| 506 | } else if onuAlarm.LofiStatus == statusCheckOff { |
| 507 | deviceEventName = fmt.Sprintf("%s_%s", onuLossOfFrameEvent, "CLEAR_EVENT") |
| 508 | } else if onuAlarm.LoamiStatus == statusCheckOn { |
| 509 | deviceEventName = fmt.Sprintf("%s_%s", onuLossOfPloamEvent, "RAISE_EVENT") |
| 510 | } else if onuAlarm.LoamiStatus == statusCheckOff { |
| 511 | deviceEventName = fmt.Sprintf("%s_%s", onuLossOfPloamEvent, "CLEAR_EVENT") |
| 512 | } |
| 513 | return deviceEventName |
| 514 | } |
| 515 | |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 516 | func (em *OpenOltEventMgr) onuAlarmIndication(ctx context.Context, onuAlarm *oop.OnuAlarmIndication, deviceID string, raisedTs int64) error { |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 517 | var de voltha.DeviceEvent |
| Amit Ghosh | 502056b | 2020-07-15 09:15:48 +0100 | [diff] [blame] | 518 | |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 519 | context := make(map[string]string) |
| 520 | /* Populating event context */ |
| Amit Ghosh | 502056b | 2020-07-15 09:15:48 +0100 | [diff] [blame] | 521 | context[ContextOnuPonIntfID] = strconv.FormatUint(uint64(onuAlarm.IntfId), base10) |
| 522 | context[ContextOnuOnuID] = strconv.FormatUint(uint64(onuAlarm.OnuId), base10) |
| kesavand | 0ef592c | 2022-03-16 12:34:24 +0530 | [diff] [blame] | 523 | onuDeviceID := em.populateContextWithSerialDeviceID(context, onuAlarm.IntfId, onuAlarm.OnuId) |
| Thiyagarajan Subramani | 34a0028 | 2020-03-10 20:19:31 +0530 | [diff] [blame] | 524 | |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 525 | /* Populating device event body */ |
| 526 | de.Context = context |
| 527 | de.ResourceId = deviceID |
| Thiyagarajan Subramani | 34a0028 | 2020-03-10 20:19:31 +0530 | [diff] [blame] | 528 | de.DeviceEventName = em.getDeviceEventName(onuAlarm) |
| 529 | |
| 530 | switch onuAlarm.LosStatus { |
| 531 | case statusCheckOn: |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 532 | if em.wasLosRaised(ctx, onuAlarm) { |
| Thiyagarajan Subramani | 34a0028 | 2020-03-10 20:19:31 +0530 | [diff] [blame] | 533 | /* No need to raise Onu Los Event as it might have already raised |
| 534 | or Onu might have deleted */ |
| 535 | return nil |
| 536 | } |
| 537 | onuKey := em.handler.formOnuKey(onuAlarm.IntfId, onuAlarm.OnuId) |
| 538 | if onuInCache, ok := em.handler.onus.Load(onuKey); ok { |
| 539 | /* Update onu device with LoS raised state as true */ |
| 540 | em.handler.onus.Store(onuKey, NewOnuDevice(onuInCache.(*OnuDevice).deviceID, onuInCache.(*OnuDevice).deviceType, |
| 541 | onuInCache.(*OnuDevice).serialNumber, onuInCache.(*OnuDevice).onuID, onuInCache.(*OnuDevice).intfID, |
| khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 542 | onuInCache.(*OnuDevice).proxyDeviceID, true, onuInCache.(*OnuDevice).adapterEndpoint)) |
| Thiyagarajan Subramani | 34a0028 | 2020-03-10 20:19:31 +0530 | [diff] [blame] | 543 | } |
| 544 | case statusCheckOff: |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 545 | if em.wasLosCleared(ctx, onuAlarm) { |
| Thiyagarajan Subramani | 34a0028 | 2020-03-10 20:19:31 +0530 | [diff] [blame] | 546 | /* No need to clear Onu Los Event as it might have already cleared |
| 547 | or Onu might have deleted */ |
| 548 | return nil |
| 549 | } |
| 550 | onuKey := em.handler.formOnuKey(onuAlarm.IntfId, onuAlarm.OnuId) |
| 551 | if onuInCache, ok := em.handler.onus.Load(onuKey); ok { |
| 552 | /* Update onu device with LoS raised state as false */ |
| 553 | em.handler.onus.Store(onuKey, NewOnuDevice(onuInCache.(*OnuDevice).deviceID, onuInCache.(*OnuDevice).deviceType, |
| 554 | onuInCache.(*OnuDevice).serialNumber, onuInCache.(*OnuDevice).onuID, onuInCache.(*OnuDevice).intfID, |
| khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 555 | onuInCache.(*OnuDevice).proxyDeviceID, false, onuInCache.(*OnuDevice).adapterEndpoint)) |
| Thiyagarajan Subramani | 34a0028 | 2020-03-10 20:19:31 +0530 | [diff] [blame] | 556 | } |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 557 | } |
| Thiyagarajan Subramani | 34a0028 | 2020-03-10 20:19:31 +0530 | [diff] [blame] | 558 | |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 559 | /* Send event to KAFKA */ |
| kesavand | 0ef592c | 2022-03-16 12:34:24 +0530 | [diff] [blame] | 560 | if err := em.eventProxy.SendDeviceEventWithKey(ctx, &de, voltha.EventCategory_COMMUNICATION, voltha.EventSubCategory_ONU, raisedTs, onuDeviceID); err != nil { |
| Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 561 | return err |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 562 | } |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 563 | logger.Debugw(ctx, "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] | 564 | return nil |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 565 | } |
| 566 | |
| kesavand | 7cf3a05 | 2020-08-28 12:49:18 +0530 | [diff] [blame] | 567 | func (em *OpenOltEventMgr) onuActivationIndication(ctx context.Context, eventName string, onuInd *oop.OnuIndication, deviceID string, raisedTs int64) error { |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 568 | var de voltha.DeviceEvent |
| 569 | context := make(map[string]string) |
| 570 | /* Populating event context */ |
| kesavand | 7cf3a05 | 2020-08-28 12:49:18 +0530 | [diff] [blame] | 571 | context[ContextOnuPonIntfID] = strconv.FormatUint(uint64(onuInd.IntfId), base10) |
| 572 | context[ContextOnuOnuID] = strconv.FormatUint(uint64(onuInd.OnuId), base10) |
| 573 | context[ContextOnuFailureReaseon] = onuInd.FailReason.String() |
| Amit Ghosh | 502056b | 2020-07-15 09:15:48 +0100 | [diff] [blame] | 574 | |
| kesavand | 0ef592c | 2022-03-16 12:34:24 +0530 | [diff] [blame] | 575 | onuDeviceID := em.populateContextWithSerialDeviceID(context, onuInd.IntfId, onuInd.OnuId) |
| Amit Ghosh | 502056b | 2020-07-15 09:15:48 +0100 | [diff] [blame] | 576 | |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 577 | /* Populating device event body */ |
| 578 | de.Context = context |
| 579 | de.ResourceId = deviceID |
| kesavand | 7cf3a05 | 2020-08-28 12:49:18 +0530 | [diff] [blame] | 580 | de.DeviceEventName = eventName |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 581 | /* Send event to KAFKA */ |
| kesavand | 0ef592c | 2022-03-16 12:34:24 +0530 | [diff] [blame] | 582 | if err := em.eventProxy.SendDeviceEventWithKey(ctx, &de, voltha.EventCategory_EQUIPMENT, voltha.EventSubCategory_PON, raisedTs, onuDeviceID); err != nil { |
| Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 583 | return err |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 584 | } |
| kesavand | 7cf3a05 | 2020-08-28 12:49:18 +0530 | [diff] [blame] | 585 | logger.Debugw(ctx, "onu-activation-failure-event-sent-to-kafka", log.Fields{"onu-id": onuInd.OnuId, "intf-id": onuInd.IntfId}) |
| Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 586 | return nil |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 587 | } |
| 588 | |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 589 | func (em *OpenOltEventMgr) onuLossOmciIndication(ctx context.Context, onuLossOmci *oop.OnuLossOfOmciChannelIndication, deviceID string, raisedTs int64) error { |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 590 | var de voltha.DeviceEvent |
| 591 | context := make(map[string]string) |
| 592 | /* Populating event context */ |
| Amit Ghosh | 502056b | 2020-07-15 09:15:48 +0100 | [diff] [blame] | 593 | context[ContextOnuPonIntfID] = strconv.FormatUint(uint64(onuLossOmci.IntfId), base10) |
| 594 | context[ContextOnuOnuID] = strconv.FormatUint(uint64(onuLossOmci.OnuId), base10) |
| 595 | |
| kesavand | 0ef592c | 2022-03-16 12:34:24 +0530 | [diff] [blame] | 596 | onuDeviceID := em.populateContextWithSerialDeviceID(context, onuLossOmci.IntfId, onuLossOmci.OnuId) |
| Amit Ghosh | 502056b | 2020-07-15 09:15:48 +0100 | [diff] [blame] | 597 | |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 598 | /* Populating device event body */ |
| 599 | de.Context = context |
| 600 | de.ResourceId = deviceID |
| Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 601 | if onuLossOmci.Status == statusCheckOn { |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 602 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuLossOmciEvent, "RAISE_EVENT") |
| 603 | } else { |
| 604 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuLossOmciEvent, "CLEAR_EVENT") |
| 605 | } |
| 606 | /* Send event to KAFKA */ |
| kesavand | 0ef592c | 2022-03-16 12:34:24 +0530 | [diff] [blame] | 607 | if err := em.eventProxy.SendDeviceEventWithKey(ctx, &de, voltha.EventCategory_COMMUNICATION, voltha.EventSubCategory_ONU, raisedTs, onuDeviceID); err != nil { |
| Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 608 | return err |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 609 | } |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 610 | logger.Debugw(ctx, "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] | 611 | return nil |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 612 | } |
| 613 | |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 614 | func (em *OpenOltEventMgr) onuDriftOfWindowIndication(ctx context.Context, onuDriftWindow *oop.OnuDriftOfWindowIndication, deviceID string, raisedTs int64) error { |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 615 | var de voltha.DeviceEvent |
| 616 | context := make(map[string]string) |
| 617 | /* Populating event context */ |
| Amit Ghosh | 502056b | 2020-07-15 09:15:48 +0100 | [diff] [blame] | 618 | context[ContextOnuPonIntfID] = strconv.FormatUint(uint64(onuDriftWindow.IntfId), base10) |
| 619 | context[ContextOnuOnuID] = strconv.FormatUint(uint64(onuDriftWindow.OnuId), base10) |
| 620 | context[ContextOnuDrift] = strconv.FormatUint(uint64(onuDriftWindow.Drift), base10) |
| 621 | context[ContextOnuNewEqd] = strconv.FormatUint(uint64(onuDriftWindow.NewEqd), base10) |
| 622 | |
| kesavand | 0ef592c | 2022-03-16 12:34:24 +0530 | [diff] [blame] | 623 | onuDeviceID := em.populateContextWithSerialDeviceID(context, onuDriftWindow.IntfId, onuDriftWindow.OnuId) |
| Amit Ghosh | 502056b | 2020-07-15 09:15:48 +0100 | [diff] [blame] | 624 | |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 625 | /* Populating device event body */ |
| 626 | de.Context = context |
| 627 | de.ResourceId = deviceID |
| Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 628 | if onuDriftWindow.Status == statusCheckOn { |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 629 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuDriftOfWindowEvent, "RAISE_EVENT") |
| 630 | } else { |
| 631 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuDriftOfWindowEvent, "CLEAR_EVENT") |
| 632 | } |
| 633 | /* Send event to KAFKA */ |
| kesavand | 0ef592c | 2022-03-16 12:34:24 +0530 | [diff] [blame] | 634 | if err := em.eventProxy.SendDeviceEventWithKey(ctx, &de, voltha.EventCategory_COMMUNICATION, voltha.EventSubCategory_ONU, raisedTs, onuDeviceID); err != nil { |
| Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 635 | return err |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 636 | } |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 637 | logger.Debugw(ctx, "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] | 638 | return nil |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 639 | } |
| 640 | |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 641 | func (em *OpenOltEventMgr) onuSignalDegradeIndication(ctx context.Context, onuSignalDegrade *oop.OnuSignalDegradeIndication, deviceID string, raisedTs int64) error { |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 642 | var de voltha.DeviceEvent |
| 643 | context := make(map[string]string) |
| 644 | /* Populating event context */ |
| Amit Ghosh | 502056b | 2020-07-15 09:15:48 +0100 | [diff] [blame] | 645 | context[ContextOnuPonIntfID] = strconv.FormatUint(uint64(onuSignalDegrade.IntfId), base10) |
| 646 | context[ContextOnuOnuID] = strconv.FormatUint(uint64(onuSignalDegrade.OnuId), base10) |
| 647 | context[ContextOnuInverseBitErrorRate] = strconv.FormatUint(uint64(onuSignalDegrade.InverseBitErrorRate), base10) |
| 648 | |
| kesavand | 0ef592c | 2022-03-16 12:34:24 +0530 | [diff] [blame] | 649 | onuDeviceID := em.populateContextWithSerialDeviceID(context, onuSignalDegrade.IntfId, onuSignalDegrade.OnuId) |
| Amit Ghosh | 502056b | 2020-07-15 09:15:48 +0100 | [diff] [blame] | 650 | |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 651 | /* Populating device event body */ |
| 652 | de.Context = context |
| 653 | de.ResourceId = deviceID |
| Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 654 | if onuSignalDegrade.Status == statusCheckOn { |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 655 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuSignalDegradeEvent, "RAISE_EVENT") |
| 656 | } else { |
| 657 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuSignalDegradeEvent, "CLEAR_EVENT") |
| 658 | } |
| 659 | /* Send event to KAFKA */ |
| kesavand | 0ef592c | 2022-03-16 12:34:24 +0530 | [diff] [blame] | 660 | if err := em.eventProxy.SendDeviceEventWithKey(ctx, &de, voltha.EventCategory_COMMUNICATION, voltha.EventSubCategory_ONU, raisedTs, onuDeviceID); err != nil { |
| Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 661 | return err |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 662 | } |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 663 | logger.Debugw(ctx, "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] | 664 | return nil |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 665 | } |
| 666 | |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 667 | func (em *OpenOltEventMgr) onuSignalsFailIndication(ctx context.Context, onuSignalsFail *oop.OnuSignalsFailureIndication, deviceID string, raisedTs int64) error { |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 668 | var de voltha.DeviceEvent |
| 669 | context := make(map[string]string) |
| 670 | /* Populating event context */ |
| kesavand | 0ef592c | 2022-03-16 12:34:24 +0530 | [diff] [blame] | 671 | onuDeviceID := em.populateContextWithSerialDeviceID(context, onuSignalsFail.IntfId, onuSignalsFail.OnuId) |
| Amit Ghosh | 502056b | 2020-07-15 09:15:48 +0100 | [diff] [blame] | 672 | |
| 673 | context[ContextOnuOnuID] = strconv.FormatUint(uint64(onuSignalsFail.OnuId), base10) |
| 674 | context[ContextOnuPonIntfID] = strconv.FormatUint(uint64(onuSignalsFail.IntfId), base10) |
| 675 | context[ContextOnuInverseBitErrorRate] = strconv.FormatUint(uint64(onuSignalsFail.InverseBitErrorRate), base10) |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 676 | /* Populating device event body */ |
| 677 | de.Context = context |
| 678 | de.ResourceId = deviceID |
| Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 679 | if onuSignalsFail.Status == statusCheckOn { |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 680 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuSignalsFailEvent, "RAISE_EVENT") |
| 681 | } else { |
| 682 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuSignalsFailEvent, "CLEAR_EVENT") |
| 683 | } |
| 684 | /* Send event to KAFKA */ |
| kesavand | 0ef592c | 2022-03-16 12:34:24 +0530 | [diff] [blame] | 685 | if err := em.eventProxy.SendDeviceEventWithKey(ctx, &de, voltha.EventCategory_COMMUNICATION, voltha.EventSubCategory_ONU, raisedTs, onuDeviceID); err != nil { |
| Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 686 | return err |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 687 | } |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 688 | logger.Debugw(ctx, "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] | 689 | return nil |
| 690 | } |
| 691 | |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 692 | func (em *OpenOltEventMgr) onuStartupFailedIndication(ctx context.Context, onuStartupFail *oop.OnuStartupFailureIndication, deviceID string, raisedTs int64) error { |
| Naga Manjunath | f6f7464 | 2020-01-13 21:37:28 +0530 | [diff] [blame] | 693 | var de voltha.DeviceEvent |
| 694 | context := make(map[string]string) |
| 695 | /* Populating event context */ |
| kesavand | 0ef592c | 2022-03-16 12:34:24 +0530 | [diff] [blame] | 696 | onuDeviceID := em.populateContextWithSerialDeviceID(context, onuStartupFail.IntfId, onuStartupFail.OnuId) |
| Amit Ghosh | 502056b | 2020-07-15 09:15:48 +0100 | [diff] [blame] | 697 | |
| 698 | context[ContextOnuOnuID] = strconv.FormatUint(uint64(onuStartupFail.OnuId), base10) |
| 699 | context[ContextOnuPonIntfID] = strconv.FormatUint(uint64(onuStartupFail.IntfId), base10) |
| Naga Manjunath | f6f7464 | 2020-01-13 21:37:28 +0530 | [diff] [blame] | 700 | |
| 701 | /* Populating device event body */ |
| 702 | de.Context = context |
| 703 | de.ResourceId = deviceID |
| 704 | if onuStartupFail.Status == statusCheckOn { |
| 705 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuStartupFailEvent, "RAISE_EVENT") |
| 706 | } else { |
| 707 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuStartupFailEvent, "CLEAR_EVENT") |
| 708 | } |
| 709 | /* Send event to KAFKA */ |
| kesavand | 0ef592c | 2022-03-16 12:34:24 +0530 | [diff] [blame] | 710 | if err := em.eventProxy.SendDeviceEventWithKey(ctx, &de, voltha.EventCategory_COMMUNICATION, voltha.EventSubCategory_PON, raisedTs, onuDeviceID); err != nil { |
| Naga Manjunath | f6f7464 | 2020-01-13 21:37:28 +0530 | [diff] [blame] | 711 | return err |
| 712 | } |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 713 | logger.Debugw(ctx, "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] | 714 | return nil |
| 715 | } |
| 716 | |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 717 | func (em *OpenOltEventMgr) onuLossOfSyncIndication(ctx context.Context, onuLOKI *oop.OnuLossOfKeySyncFailureIndication, deviceID string, raisedTs int64) error { |
| Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 718 | var de voltha.DeviceEvent |
| 719 | context := make(map[string]string) |
| 720 | /* Populating event context */ |
| kesavand | 0ef592c | 2022-03-16 12:34:24 +0530 | [diff] [blame] | 721 | onuDeviceID := em.populateContextWithSerialDeviceID(context, onuLOKI.IntfId, onuLOKI.OnuId) |
| Amit Ghosh | 502056b | 2020-07-15 09:15:48 +0100 | [diff] [blame] | 722 | |
| 723 | context[ContextOnuOnuID] = strconv.FormatUint(uint64(onuLOKI.OnuId), base10) |
| 724 | context[ContextOnuPonIntfID] = strconv.FormatUint(uint64(onuLOKI.IntfId), base10) |
| Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 725 | /* Populating device event body */ |
| 726 | de.Context = context |
| 727 | de.ResourceId = deviceID |
| 728 | if onuLOKI.Status == statusCheckOn { |
| 729 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuLossOfKeySyncEvent, "RAISE_EVENT") |
| 730 | } else { |
| 731 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuLossOfKeySyncEvent, "CLEAR_EVENT") |
| 732 | } |
| 733 | |
| 734 | /* Send event to KAFKA */ |
| kesavand | 0ef592c | 2022-03-16 12:34:24 +0530 | [diff] [blame] | 735 | if err := em.eventProxy.SendDeviceEventWithKey(ctx, &de, voltha.EventCategory_SECURITY, voltha.EventSubCategory_ONU, raisedTs, onuDeviceID); err != nil { |
| Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 736 | return err |
| 737 | } |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 738 | logger.Debugw(ctx, "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] | 739 | return nil |
| Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 740 | } |
| kesavand | 39e0aa3 | 2020-01-28 20:58:50 -0500 | [diff] [blame] | 741 | |
| 742 | // oltIntfOperIndication handles Up and Down state of an OLT PON ports |
| Kent Hagerman | e6ff101 | 2020-07-14 15:07:53 -0400 | [diff] [blame] | 743 | func (em *OpenOltEventMgr) oltIntfOperIndication(ctx context.Context, ifindication *oop.IntfOperIndication, deviceID string, raisedTs int64) { |
| Mahir Gunyel | 85f61c1 | 2021-10-06 11:53:45 -0700 | [diff] [blame] | 744 | portNo := plt.IntfIDToPortNo(ifindication.IntfId, voltha.Port_PON_OLT) |
| khenaidoo | dc2116e | 2021-10-19 17:33:19 -0400 | [diff] [blame] | 745 | if port, err := em.handler.getPortFromCore(ctx, &ca.PortFilter{ |
| khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 746 | DeviceId: deviceID, |
| 747 | Port: portNo, |
| 748 | }); err != nil { |
| Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 749 | logger.Warnw(ctx, "Error while fetching port object", log.Fields{"device-id": deviceID, "err": err}) |
| Kent Hagerman | f1db18b | 2020-07-08 13:38:15 -0400 | [diff] [blame] | 750 | } else if port.AdminState != common.AdminState_ENABLED { |
| 751 | logger.Debugw(ctx, "port-disable/enable-event-not-generated--the-port-is-not-enabled-by-operator", log.Fields{"device-id": deviceID, "port": port}) |
| Kent Hagerman | e6ff101 | 2020-07-14 15:07:53 -0400 | [diff] [blame] | 752 | return |
| kesavand | 39e0aa3 | 2020-01-28 20:58:50 -0500 | [diff] [blame] | 753 | } |
| 754 | /* Populating event context */ |
| Kent Hagerman | f1db18b | 2020-07-08 13:38:15 -0400 | [diff] [blame] | 755 | context := map[string]string{ContextOltPonIntfOperState: ifindication.GetOperState()} |
| kesavand | 39e0aa3 | 2020-01-28 20:58:50 -0500 | [diff] [blame] | 756 | /* Populating device event body */ |
| Kent Hagerman | f1db18b | 2020-07-08 13:38:15 -0400 | [diff] [blame] | 757 | var de voltha.DeviceEvent |
| kesavand | 39e0aa3 | 2020-01-28 20:58:50 -0500 | [diff] [blame] | 758 | de.Context = context |
| 759 | de.ResourceId = deviceID |
| 760 | |
| 761 | if ifindication.GetOperState() == operationStateDown { |
| 762 | de.DeviceEventName = fmt.Sprintf("%s_%s", ponIntfDownIndiction, "RAISE_EVENT") |
| 763 | } else if ifindication.OperState == operationStateUp { |
| 764 | de.DeviceEventName = fmt.Sprintf("%s_%s", ponIntfDownIndiction, "CLEAR_EVENT") |
| 765 | } |
| 766 | /* Send event to KAFKA */ |
| Kent Hagerman | e6ff101 | 2020-07-14 15:07:53 -0400 | [diff] [blame] | 767 | if err := em.eventProxy.SendDeviceEvent(ctx, &de, voltha.EventCategory_COMMUNICATION, voltha.EventSubCategory_OLT, raisedTs); err != nil { |
| 768 | _ = olterrors.NewErrCommunication("send-olt-intf-oper-status-event", log.Fields{"device-id": deviceID, "intf-id": ifindication.IntfId, "oper-state": ifindication.OperState}, err).LogAt(log.WarnLevel) |
| 769 | return |
| kesavand | 39e0aa3 | 2020-01-28 20:58:50 -0500 | [diff] [blame] | 770 | } |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 771 | logger.Debug(ctx, "sent-olt-intf-oper-status-event-to-kafka") |
| kesavand | 39e0aa3 | 2020-01-28 20:58:50 -0500 | [diff] [blame] | 772 | } |
| Devmalya Paul | 1abc34e | 2020-02-04 20:48:06 -0500 | [diff] [blame] | 773 | |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 774 | func (em *OpenOltEventMgr) onuDeactivationFailureIndication(ctx context.Context, onuDFI *oop.OnuDeactivationFailureIndication, deviceID string, raisedTs int64) error { |
| Devmalya Paul | 1abc34e | 2020-02-04 20:48:06 -0500 | [diff] [blame] | 775 | var de voltha.DeviceEvent |
| 776 | context := make(map[string]string) |
| 777 | /* Populating event context */ |
| kesavand | 0ef592c | 2022-03-16 12:34:24 +0530 | [diff] [blame] | 778 | onuDeviceID := em.populateContextWithSerialDeviceID(context, onuDFI.IntfId, onuDFI.OnuId) |
| Amit Ghosh | 502056b | 2020-07-15 09:15:48 +0100 | [diff] [blame] | 779 | |
| 780 | context[ContextOnuOnuID] = strconv.FormatUint(uint64(onuDFI.OnuId), base10) |
| 781 | context[ContextOnuPonIntfID] = strconv.FormatUint(uint64(onuDFI.IntfId), base10) |
| Devmalya Paul | 1abc34e | 2020-02-04 20:48:06 -0500 | [diff] [blame] | 782 | /* Populating device event body */ |
| 783 | de.Context = context |
| 784 | de.ResourceId = deviceID |
| Devmalya Paul | a1efa64 | 2020-04-20 01:36:43 -0400 | [diff] [blame] | 785 | if onuDFI.Status == statusCheckOn { |
| 786 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuDeactivationFailureEvent, "RAISE_EVENT") |
| 787 | } else { |
| 788 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuDeactivationFailureEvent, "CLEAR_EVENT") |
| 789 | } |
| Devmalya Paul | 1abc34e | 2020-02-04 20:48:06 -0500 | [diff] [blame] | 790 | /* Send event to KAFKA */ |
| kesavand | 0ef592c | 2022-03-16 12:34:24 +0530 | [diff] [blame] | 791 | if err := em.eventProxy.SendDeviceEventWithKey(ctx, &de, voltha.EventCategory_EQUIPMENT, voltha.EventSubCategory_ONU, raisedTs, onuDeviceID); err != nil { |
| Devmalya Paul | 1abc34e | 2020-02-04 20:48:06 -0500 | [diff] [blame] | 792 | return err |
| 793 | } |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 794 | logger.Debugw(ctx, "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] | 795 | return nil |
| 796 | } |
| Amit Ghosh | 502056b | 2020-07-15 09:15:48 +0100 | [diff] [blame] | 797 | |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 798 | func (em *OpenOltEventMgr) onuRemoteDefectIndication(ctx context.Context, onuID uint32, intfID uint32, rdiCount uint64, status string, deviceID string, raisedTs int64) error { |
| Devmalya Paul | 6f063a6 | 2020-02-19 19:19:06 -0500 | [diff] [blame] | 799 | /* Populating event context */ |
| 800 | context := map[string]string{ |
| Amit Ghosh | 502056b | 2020-07-15 09:15:48 +0100 | [diff] [blame] | 801 | ContextOnuOnuID: strconv.FormatUint(uint64(onuID), base10), |
| 802 | ContextOnuPonIntfID: strconv.FormatUint(uint64(intfID), base10), |
| 803 | ContextOnuRemoteDefectIndicatorCount: strconv.FormatUint(rdiCount, base10), |
| Devmalya Paul | 6f063a6 | 2020-02-19 19:19:06 -0500 | [diff] [blame] | 804 | } |
| kesavand | 0ef592c | 2022-03-16 12:34:24 +0530 | [diff] [blame] | 805 | onuDeviceID := em.populateContextWithSerialDeviceID(context, intfID, onuID) |
| Amit Ghosh | 502056b | 2020-07-15 09:15:48 +0100 | [diff] [blame] | 806 | |
| Devmalya Paul | 6f063a6 | 2020-02-19 19:19:06 -0500 | [diff] [blame] | 807 | /* Populating device event body */ |
| 808 | de := &voltha.DeviceEvent{ |
| Devmalya Paul | a1efa64 | 2020-04-20 01:36:43 -0400 | [diff] [blame] | 809 | Context: context, |
| 810 | ResourceId: deviceID, |
| 811 | } |
| 812 | if status == statusCheckOn { |
| 813 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuRemoteDefectIndication, "RAISE_EVENT") |
| 814 | } else { |
| 815 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuRemoteDefectIndication, "CLEAR_EVENT") |
| Devmalya Paul | 6f063a6 | 2020-02-19 19:19:06 -0500 | [diff] [blame] | 816 | } |
| 817 | /* Send event to KAFKA */ |
| kesavand | 0ef592c | 2022-03-16 12:34:24 +0530 | [diff] [blame] | 818 | if err := em.eventProxy.SendDeviceEventWithKey(ctx, de, voltha.EventCategory_EQUIPMENT, voltha.EventSubCategory_ONU, raisedTs, onuDeviceID); err != nil { |
| Devmalya Paul | 6f063a6 | 2020-02-19 19:19:06 -0500 | [diff] [blame] | 819 | return err |
| 820 | } |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 821 | logger.Debugw(ctx, "onu-remote-defect-event-sent-to-kafka", log.Fields{"onu-id": onuID, "intf-id": intfID}) |
| Devmalya Paul | a1efa64 | 2020-04-20 01:36:43 -0400 | [diff] [blame] | 822 | return nil |
| 823 | } |
| 824 | |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 825 | func (em *OpenOltEventMgr) onuItuPonStatsIndication(ctx context.Context, onuIPS *oop.OnuItuPonStatsIndication, deviceID string, raisedTs int64) error { |
| Devmalya Paul | a1efa64 | 2020-04-20 01:36:43 -0400 | [diff] [blame] | 826 | onuDevice, found := em.handler.onus.Load(em.handler.formOnuKey(onuIPS.IntfId, onuIPS.OnuId)) |
| 827 | if !found { |
| 828 | return errors.New("unknown-onu-device") |
| 829 | } |
| 830 | if onuIPS.GetRdiErrorInd().Status == statusCheckOn { |
| 831 | if !onuDevice.(*OnuDevice).rdiRaised { |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 832 | if err := em.onuRemoteDefectIndication(ctx, onuIPS.OnuId, onuIPS.IntfId, onuIPS.GetRdiErrorInd().RdiErrorCount, statusCheckOn, deviceID, raisedTs); err != nil { |
| Devmalya Paul | a1efa64 | 2020-04-20 01:36:43 -0400 | [diff] [blame] | 833 | return err |
| 834 | } |
| 835 | onuDevice.(*OnuDevice).rdiRaised = true |
| 836 | return nil |
| 837 | } |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 838 | logger.Debugw(ctx, "onu-remote-defect-already-raised", log.Fields{"onu-id": onuIPS.OnuId, "intf-id": onuIPS.IntfId}) |
| Devmalya Paul | a1efa64 | 2020-04-20 01:36:43 -0400 | [diff] [blame] | 839 | } else { |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 840 | if err := em.onuRemoteDefectIndication(ctx, onuIPS.OnuId, onuIPS.IntfId, onuIPS.GetRdiErrorInd().RdiErrorCount, statusCheckOff, deviceID, raisedTs); err != nil { |
| Devmalya Paul | a1efa64 | 2020-04-20 01:36:43 -0400 | [diff] [blame] | 841 | return err |
| 842 | } |
| 843 | onuDevice.(*OnuDevice).rdiRaised = false |
| 844 | } |
| Devmalya Paul | 41a762d | 2020-03-01 18:56:54 -0500 | [diff] [blame] | 845 | return nil |
| 846 | } |
| 847 | |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 848 | func (em *OpenOltEventMgr) onuLossOfGEMChannelDelineationIndication(ctx context.Context, onuGCD *oop.OnuLossOfGEMChannelDelineationIndication, deviceID string, raisedTs int64) error { |
| Devmalya Paul | 41a762d | 2020-03-01 18:56:54 -0500 | [diff] [blame] | 849 | /* Populating event context */ |
| 850 | context := map[string]string{ |
| Amit Ghosh | 502056b | 2020-07-15 09:15:48 +0100 | [diff] [blame] | 851 | ContextOnuOnuID: strconv.FormatUint(uint64(onuGCD.OnuId), base10), |
| 852 | ContextOnuPonIntfID: strconv.FormatUint(uint64(onuGCD.IntfId), base10), |
| 853 | ContextOnuDelineationErrors: strconv.FormatUint(uint64(onuGCD.DelineationErrors), base10), |
| Devmalya Paul | 41a762d | 2020-03-01 18:56:54 -0500 | [diff] [blame] | 854 | } |
| kesavand | 0ef592c | 2022-03-16 12:34:24 +0530 | [diff] [blame] | 855 | onuDeviceID := em.populateContextWithSerialDeviceID(context, onuGCD.IntfId, onuGCD.OnuId) |
| Amit Ghosh | 502056b | 2020-07-15 09:15:48 +0100 | [diff] [blame] | 856 | |
| Devmalya Paul | 41a762d | 2020-03-01 18:56:54 -0500 | [diff] [blame] | 857 | /* Populating device event body */ |
| 858 | de := &voltha.DeviceEvent{ |
| 859 | Context: context, |
| 860 | ResourceId: deviceID, |
| 861 | } |
| 862 | if onuGCD.Status == statusCheckOn { |
| 863 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuLossOfGEMChannelDelineationEvent, "RAISE_EVENT") |
| 864 | } else { |
| 865 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuLossOfGEMChannelDelineationEvent, "CLEAR_EVENT") |
| 866 | } |
| 867 | /* Send event to KAFKA */ |
| kesavand | 0ef592c | 2022-03-16 12:34:24 +0530 | [diff] [blame] | 868 | if err := em.eventProxy.SendDeviceEventWithKey(ctx, de, voltha.EventCategory_COMMUNICATION, voltha.EventSubCategory_ONU, raisedTs, onuDeviceID); err != nil { |
| Devmalya Paul | 41a762d | 2020-03-01 18:56:54 -0500 | [diff] [blame] | 869 | return err |
| 870 | } |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 871 | logger.Debugw(ctx, "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] | 872 | return nil |
| 873 | } |
| 874 | |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 875 | func (em *OpenOltEventMgr) onuPhysicalEquipmentErrorIndication(ctx context.Context, onuErr *oop.OnuPhysicalEquipmentErrorIndication, deviceID string, raisedTs int64) error { |
| Devmalya Paul | 41a762d | 2020-03-01 18:56:54 -0500 | [diff] [blame] | 876 | /* Populating event context */ |
| 877 | context := map[string]string{ |
| Amit Ghosh | 502056b | 2020-07-15 09:15:48 +0100 | [diff] [blame] | 878 | ContextOnuOnuID: strconv.FormatUint(uint64(onuErr.OnuId), base10), |
| 879 | ContextOnuPonIntfID: strconv.FormatUint(uint64(onuErr.IntfId), base10), |
| Devmalya Paul | 41a762d | 2020-03-01 18:56:54 -0500 | [diff] [blame] | 880 | } |
| kesavand | 0ef592c | 2022-03-16 12:34:24 +0530 | [diff] [blame] | 881 | onuDeviceID := em.populateContextWithSerialDeviceID(context, onuErr.IntfId, onuErr.OnuId) |
| Devmalya Paul | 41a762d | 2020-03-01 18:56:54 -0500 | [diff] [blame] | 882 | /* Populating device event body */ |
| 883 | de := &voltha.DeviceEvent{ |
| 884 | Context: context, |
| 885 | ResourceId: deviceID, |
| 886 | } |
| 887 | if onuErr.Status == statusCheckOn { |
| 888 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuPhysicalEquipmentErrorEvent, "RAISE_EVENT") |
| 889 | } else { |
| 890 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuPhysicalEquipmentErrorEvent, "CLEAR_EVENT") |
| 891 | } |
| 892 | /* Send event to KAFKA */ |
| kesavand | 0ef592c | 2022-03-16 12:34:24 +0530 | [diff] [blame] | 893 | if err := em.eventProxy.SendDeviceEventWithKey(ctx, de, voltha.EventCategory_EQUIPMENT, voltha.EventSubCategory_ONU, raisedTs, onuDeviceID); err != nil { |
| Devmalya Paul | 41a762d | 2020-03-01 18:56:54 -0500 | [diff] [blame] | 894 | return err |
| 895 | } |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 896 | logger.Debugw(ctx, "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] | 897 | return nil |
| 898 | } |
| 899 | |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 900 | func (em *OpenOltEventMgr) onuLossOfAcknowledgementIndication(ctx context.Context, onuLOA *oop.OnuLossOfAcknowledgementIndication, deviceID string, raisedTs int64) error { |
| Devmalya Paul | 41a762d | 2020-03-01 18:56:54 -0500 | [diff] [blame] | 901 | /* Populating event context */ |
| 902 | context := map[string]string{ |
| Amit Ghosh | 502056b | 2020-07-15 09:15:48 +0100 | [diff] [blame] | 903 | ContextOnuOnuID: strconv.FormatUint(uint64(onuLOA.OnuId), base10), |
| 904 | ContextOnuPonIntfID: strconv.FormatUint(uint64(onuLOA.IntfId), base10), |
| Devmalya Paul | 41a762d | 2020-03-01 18:56:54 -0500 | [diff] [blame] | 905 | } |
| kesavand | 0ef592c | 2022-03-16 12:34:24 +0530 | [diff] [blame] | 906 | onuDeviceID := em.populateContextWithSerialDeviceID(context, onuLOA.IntfId, onuLOA.OnuId) |
| Amit Ghosh | 502056b | 2020-07-15 09:15:48 +0100 | [diff] [blame] | 907 | |
| Devmalya Paul | 41a762d | 2020-03-01 18:56:54 -0500 | [diff] [blame] | 908 | /* Populating device event body */ |
| 909 | de := &voltha.DeviceEvent{ |
| 910 | Context: context, |
| 911 | ResourceId: deviceID, |
| 912 | } |
| 913 | if onuLOA.Status == statusCheckOn { |
| 914 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuLossOfAcknowledgementEvent, "RAISE_EVENT") |
| 915 | } else { |
| 916 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuLossOfAcknowledgementEvent, "CLEAR_EVENT") |
| 917 | } |
| 918 | /* Send event to KAFKA */ |
| kesavand | 0ef592c | 2022-03-16 12:34:24 +0530 | [diff] [blame] | 919 | if err := em.eventProxy.SendDeviceEventWithKey(ctx, de, voltha.EventCategory_EQUIPMENT, voltha.EventSubCategory_ONU, raisedTs, onuDeviceID); err != nil { |
| Devmalya Paul | 41a762d | 2020-03-01 18:56:54 -0500 | [diff] [blame] | 920 | return err |
| 921 | } |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 922 | logger.Debugw(ctx, "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] | 923 | return nil |
| 924 | } |
| Devmalya Paul | eb5294e | 2020-03-19 03:01:39 -0400 | [diff] [blame] | 925 | |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 926 | func (em *OpenOltEventMgr) onuDifferentialReachExceededIndication(ctx context.Context, onuDRE *oop.OnuDifferentialReachExceededIndication, deviceID string, raisedTs int64) error { |
| Devmalya Paul | eb5294e | 2020-03-19 03:01:39 -0400 | [diff] [blame] | 927 | /* Populating event context */ |
| 928 | context := map[string]string{ |
| Amit Ghosh | 502056b | 2020-07-15 09:15:48 +0100 | [diff] [blame] | 929 | ContextOnuOnuID: strconv.FormatUint(uint64(onuDRE.OnuId), base10), |
| 930 | ContextOnuPonIntfID: strconv.FormatUint(uint64(onuDRE.IntfId), base10), |
| 931 | ContextOnuDifferentialDistance: strconv.FormatUint(uint64(onuDRE.Distance), base10), |
| Devmalya Paul | eb5294e | 2020-03-19 03:01:39 -0400 | [diff] [blame] | 932 | } |
| kesavand | 0ef592c | 2022-03-16 12:34:24 +0530 | [diff] [blame] | 933 | onuDeviceID := em.populateContextWithSerialDeviceID(context, onuDRE.IntfId, onuDRE.OnuId) |
| Amit Ghosh | 502056b | 2020-07-15 09:15:48 +0100 | [diff] [blame] | 934 | |
| Devmalya Paul | eb5294e | 2020-03-19 03:01:39 -0400 | [diff] [blame] | 935 | /* Populating device event body */ |
| 936 | de := &voltha.DeviceEvent{ |
| 937 | Context: context, |
| 938 | ResourceId: deviceID, |
| 939 | } |
| 940 | if onuDRE.Status == statusCheckOn { |
| 941 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuDifferentialReachExceededEvent, "RAISE_EVENT") |
| 942 | } else { |
| 943 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuDifferentialReachExceededEvent, "CLEAR_EVENT") |
| 944 | } |
| 945 | /* Send event to KAFKA */ |
| kesavand | 0ef592c | 2022-03-16 12:34:24 +0530 | [diff] [blame] | 946 | if err := em.eventProxy.SendDeviceEventWithKey(ctx, de, voltha.EventCategory_EQUIPMENT, voltha.EventSubCategory_ONU, raisedTs, onuDeviceID); err != nil { |
| Devmalya Paul | eb5294e | 2020-03-19 03:01:39 -0400 | [diff] [blame] | 947 | return err |
| 948 | } |
| Girish Kumar | a1ea2aa | 2020-08-19 18:14:22 +0000 | [diff] [blame] | 949 | logger.Debugw(ctx, "onu-differential-reach-exceeded–event-sent-to-kafka", log.Fields{"onu-id": onuDRE.OnuId, "intf-id": onuDRE.IntfId}) |
| Devmalya Paul | eb5294e | 2020-03-19 03:01:39 -0400 | [diff] [blame] | 950 | return nil |
| 951 | } |