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