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