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