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 |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 194 | func (em *OpenOltEventMgr) OnuDiscoveryIndication(onuDisc *oop.OnuDiscIndication, deviceID string, OnuID uint32, serialNumber string, raisedTs int64) error { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 195 | var de voltha.DeviceEvent |
| 196 | context := make(map[string]string) |
| 197 | /* Populating event context */ |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 198 | context["onu-id"] = strconv.FormatUint(uint64(OnuID), base10) |
| 199 | context["intf-id"] = strconv.FormatUint(uint64(onuDisc.IntfId), base10) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 200 | context["serial-number"] = serialNumber |
| 201 | /* Populating device event body */ |
| 202 | de.Context = context |
| 203 | de.ResourceId = deviceID |
| 204 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuDiscoveryEvent, "RAISE_EVENT") |
| 205 | /* Send event to KAFKA */ |
| 206 | if err := em.eventProxy.SendDeviceEvent(&de, equipment, pon, raisedTs); err != nil { |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame^] | 207 | return olterrors.NewErrCommunication("send-onu-discovery-event", |
| 208 | log.Fields{ |
| 209 | "serial-number": serialNumber, |
| 210 | "intf-id": onuDisc.IntfId}, err) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 211 | } |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame^] | 212 | logger.Debugw("onu-discovery-event-sent-to-kafka", |
| 213 | log.Fields{ |
| 214 | "serial-number": serialNumber, |
| 215 | "intf-id": onuDisc.IntfId}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 216 | return nil |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 217 | } |
| 218 | |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 219 | func (em *OpenOltEventMgr) oltLosIndication(oltLos *oop.LosIndication, deviceID string, raisedTs int64) error { |
Thiyagarajan Subramani | 34a0028 | 2020-03-10 20:19:31 +0530 | [diff] [blame] | 220 | var err error = nil |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 221 | var de voltha.DeviceEvent |
Thiyagarajan Subramani | 34a0028 | 2020-03-10 20:19:31 +0530 | [diff] [blame] | 222 | var alarmInd oop.OnuAlarmIndication |
| 223 | ponIntdID := PortNoToIntfID(oltLos.IntfId, voltha.Port_PON_OLT) |
| 224 | |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 225 | context := make(map[string]string) |
| 226 | /* Populating event context */ |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 227 | context["intf-id"] = strconv.FormatUint(uint64(oltLos.IntfId), base10) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 228 | /* Populating device event body */ |
| 229 | de.Context = context |
| 230 | de.ResourceId = deviceID |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 231 | if oltLos.Status == statusCheckOn { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 232 | de.DeviceEventName = fmt.Sprintf("%s_%s", oltLosEvent, "RAISE_EVENT") |
Thiyagarajan Subramani | 34a0028 | 2020-03-10 20:19:31 +0530 | [diff] [blame] | 233 | |
| 234 | /* When PON cable disconnected from OLT, it was expected OnuAlarmIndication |
| 235 | with "los_status: on" should be raised for each Onu connected to the PON |
| 236 | but BAL does not raise this Alarm hence manually sending OnuLosRaise event |
| 237 | for all the ONU's connected to PON on receiving LoSIndication for PON */ |
| 238 | em.handler.onus.Range(func(Onukey interface{}, onuInCache interface{}) bool { |
| 239 | if onuInCache.(*OnuDevice).intfID == ponIntdID { |
| 240 | alarmInd.IntfId = ponIntdID |
| 241 | alarmInd.OnuId = onuInCache.(*OnuDevice).onuID |
| 242 | alarmInd.LosStatus = statusCheckOn |
| 243 | err = em.onuAlarmIndication(&alarmInd, deviceID, raisedTs) |
| 244 | } |
| 245 | return true |
| 246 | }) |
| 247 | if err != nil { |
| 248 | /* Return if any error encountered while processing ONU LoS Event*/ |
| 249 | return err |
| 250 | } |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 251 | } else { |
| 252 | de.DeviceEventName = fmt.Sprintf("%s_%s", oltLosEvent, "CLEAR_EVENT") |
| 253 | } |
| 254 | /* Send event to KAFKA */ |
| 255 | if err := em.eventProxy.SendDeviceEvent(&de, communication, olt, raisedTs); err != nil { |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 256 | return err |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 257 | } |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame^] | 258 | 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] | 259 | return nil |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 260 | } |
| 261 | |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 262 | func (em *OpenOltEventMgr) onuDyingGaspIndication(dgi *oop.DyingGaspIndication, deviceID string, raisedTs int64) error { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 263 | var de voltha.DeviceEvent |
Devmalya Paul | 90ca301 | 2019-09-02 21:55:45 -0400 | [diff] [blame] | 264 | var serialNumber string |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 265 | context := make(map[string]string) |
| 266 | /* Populating event context */ |
Devmalya Paul | 90ca301 | 2019-09-02 21:55:45 -0400 | [diff] [blame] | 267 | serialNumber = "" |
Naga Manjunath | a8dc937 | 2019-10-31 23:01:18 +0530 | [diff] [blame] | 268 | onu := em.handler.formOnuKey(dgi.IntfId, dgi.OnuId) |
| 269 | if onu, ok := em.handler.onus.Load(onu); ok { |
| 270 | serialNumber = onu.(*OnuDevice).serialNumber |
Devmalya Paul | 90ca301 | 2019-09-02 21:55:45 -0400 | [diff] [blame] | 271 | } |
| 272 | context["serial-number"] = serialNumber |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 273 | context["intf-id"] = strconv.FormatUint(uint64(dgi.IntfId), base10) |
| 274 | context["onu-id"] = strconv.FormatUint(uint64(dgi.OnuId), base10) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 275 | /* Populating device event body */ |
| 276 | de.Context = context |
| 277 | de.ResourceId = deviceID |
Thomas Lee S | f68399e | 2020-02-11 15:41:38 +0530 | [diff] [blame] | 278 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuDyingGaspEvent, "EVENT") |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 279 | /* Send event to KAFKA */ |
| 280 | if err := em.eventProxy.SendDeviceEvent(&de, communication, pon, raisedTs); err != nil { |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 281 | return err |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 282 | } |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame^] | 283 | 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] | 284 | return nil |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 285 | } |
| 286 | |
Thiyagarajan Subramani | 34a0028 | 2020-03-10 20:19:31 +0530 | [diff] [blame] | 287 | //wasLosRaised checks whether los raised already. If already raised returns true else false |
| 288 | func (em *OpenOltEventMgr) wasLosRaised(onuAlarm *oop.OnuAlarmIndication) bool { |
| 289 | onuKey := em.handler.formOnuKey(onuAlarm.IntfId, onuAlarm.OnuId) |
| 290 | if onuInCache, ok := em.handler.onus.Load(onuKey); ok { |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 291 | 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] | 292 | |
| 293 | if onuAlarm.LosStatus == statusCheckOn { |
| 294 | if onuInCache.(*OnuDevice).losRaised { |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 295 | logger.Warnw("onu-los-raised-already", log.Fields{"onu_id": onuAlarm.OnuId, |
Thiyagarajan Subramani | 34a0028 | 2020-03-10 20:19:31 +0530 | [diff] [blame] | 296 | "intf_id": onuAlarm.IntfId, "LosStatus": onuAlarm.LosStatus}) |
| 297 | return true |
| 298 | } |
| 299 | return false |
| 300 | } |
| 301 | } |
| 302 | return true |
| 303 | } |
| 304 | |
| 305 | //wasLosCleared checks whether los cleared already. If already cleared returns true else false |
| 306 | func (em *OpenOltEventMgr) wasLosCleared(onuAlarm *oop.OnuAlarmIndication) bool { |
| 307 | onuKey := em.handler.formOnuKey(onuAlarm.IntfId, onuAlarm.OnuId) |
| 308 | if onuInCache, ok := em.handler.onus.Load(onuKey); ok { |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 309 | 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] | 310 | |
| 311 | if onuAlarm.LosStatus == statusCheckOff { |
| 312 | if !onuInCache.(*OnuDevice).losRaised { |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 313 | logger.Warnw("onu-los-cleared-already", log.Fields{"onu_id": onuAlarm.OnuId, |
Thiyagarajan Subramani | 34a0028 | 2020-03-10 20:19:31 +0530 | [diff] [blame] | 314 | "intf_id": onuAlarm.IntfId, "LosStatus": onuAlarm.LosStatus}) |
| 315 | return true |
| 316 | } |
| 317 | return false |
| 318 | } |
| 319 | } |
| 320 | return true |
| 321 | } |
| 322 | |
| 323 | func (em *OpenOltEventMgr) getDeviceEventName(onuAlarm *oop.OnuAlarmIndication) string { |
| 324 | var deviceEventName string |
| 325 | if onuAlarm.LosStatus == statusCheckOn { |
| 326 | deviceEventName = fmt.Sprintf("%s_%s", onuLosEvent, "RAISE_EVENT") |
| 327 | } else if onuAlarm.LosStatus == statusCheckOff { |
| 328 | deviceEventName = fmt.Sprintf("%s_%s", onuLosEvent, "CLEAR_EVENT") |
| 329 | } else if onuAlarm.LobStatus == statusCheckOn { |
| 330 | deviceEventName = fmt.Sprintf("%s_%s", onuLobEvent, "RAISE_EVENT") |
| 331 | } else if onuAlarm.LobStatus == statusCheckOff { |
| 332 | deviceEventName = fmt.Sprintf("%s_%s", onuLobEvent, "CLEAR_EVENT") |
| 333 | } else if onuAlarm.LopcMissStatus == statusCheckOn { |
| 334 | deviceEventName = fmt.Sprintf("%s_%s", onuLopcMissEvent, "RAISE_EVENT") |
| 335 | } else if onuAlarm.LopcMissStatus == statusCheckOff { |
| 336 | deviceEventName = fmt.Sprintf("%s_%s", onuLopcMissEvent, "CLEAR_EVENT") |
| 337 | } else if onuAlarm.LopcMicErrorStatus == statusCheckOn { |
| 338 | deviceEventName = fmt.Sprintf("%s_%s", onuLopcMicErrorEvent, "RAISE_EVENT") |
| 339 | } else if onuAlarm.LopcMicErrorStatus == statusCheckOff { |
| 340 | deviceEventName = fmt.Sprintf("%s_%s", onuLopcMicErrorEvent, "CLEAR_EVENT") |
| 341 | } else if onuAlarm.LofiStatus == statusCheckOn { |
| 342 | deviceEventName = fmt.Sprintf("%s_%s", onuLossOfFrameEvent, "RAISE_EVENT") |
| 343 | } else if onuAlarm.LofiStatus == statusCheckOff { |
| 344 | deviceEventName = fmt.Sprintf("%s_%s", onuLossOfFrameEvent, "CLEAR_EVENT") |
| 345 | } else if onuAlarm.LoamiStatus == statusCheckOn { |
| 346 | deviceEventName = fmt.Sprintf("%s_%s", onuLossOfPloamEvent, "RAISE_EVENT") |
| 347 | } else if onuAlarm.LoamiStatus == statusCheckOff { |
| 348 | deviceEventName = fmt.Sprintf("%s_%s", onuLossOfPloamEvent, "CLEAR_EVENT") |
| 349 | } |
| 350 | return deviceEventName |
| 351 | } |
| 352 | |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 353 | func (em *OpenOltEventMgr) onuAlarmIndication(onuAlarm *oop.OnuAlarmIndication, deviceID string, raisedTs int64) error { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 354 | var de voltha.DeviceEvent |
Thiyagarajan Subramani | 34a0028 | 2020-03-10 20:19:31 +0530 | [diff] [blame] | 355 | var serialNumber string |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 356 | context := make(map[string]string) |
| 357 | /* Populating event context */ |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 358 | context["intf-id"] = strconv.FormatUint(uint64(onuAlarm.IntfId), base10) |
| 359 | context["onu-id"] = strconv.FormatUint(uint64(onuAlarm.OnuId), base10) |
Thiyagarajan Subramani | 34a0028 | 2020-03-10 20:19:31 +0530 | [diff] [blame] | 360 | serialNumber = "" |
| 361 | onuKey := em.handler.formOnuKey(onuAlarm.IntfId, onuAlarm.OnuId) |
| 362 | if onu, ok := em.handler.onus.Load(onuKey); ok { |
| 363 | serialNumber = onu.(*OnuDevice).serialNumber |
| 364 | } |
| 365 | context["serial-number"] = serialNumber |
| 366 | |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 367 | /* Populating device event body */ |
| 368 | de.Context = context |
| 369 | de.ResourceId = deviceID |
Thiyagarajan Subramani | 34a0028 | 2020-03-10 20:19:31 +0530 | [diff] [blame] | 370 | de.DeviceEventName = em.getDeviceEventName(onuAlarm) |
| 371 | |
| 372 | switch onuAlarm.LosStatus { |
| 373 | case statusCheckOn: |
| 374 | if em.wasLosRaised(onuAlarm) { |
| 375 | /* No need to raise Onu Los Event as it might have already raised |
| 376 | or Onu might have deleted */ |
| 377 | return nil |
| 378 | } |
| 379 | onuKey := em.handler.formOnuKey(onuAlarm.IntfId, onuAlarm.OnuId) |
| 380 | if onuInCache, ok := em.handler.onus.Load(onuKey); ok { |
| 381 | /* Update onu device with LoS raised state as true */ |
| 382 | em.handler.onus.Store(onuKey, NewOnuDevice(onuInCache.(*OnuDevice).deviceID, onuInCache.(*OnuDevice).deviceType, |
| 383 | onuInCache.(*OnuDevice).serialNumber, onuInCache.(*OnuDevice).onuID, onuInCache.(*OnuDevice).intfID, |
| 384 | onuInCache.(*OnuDevice).proxyDeviceID, true)) |
| 385 | } |
| 386 | case statusCheckOff: |
| 387 | if em.wasLosCleared(onuAlarm) { |
| 388 | /* No need to clear Onu Los Event as it might have already cleared |
| 389 | or Onu might have deleted */ |
| 390 | return nil |
| 391 | } |
| 392 | onuKey := em.handler.formOnuKey(onuAlarm.IntfId, onuAlarm.OnuId) |
| 393 | if onuInCache, ok := em.handler.onus.Load(onuKey); ok { |
| 394 | /* Update onu device with LoS raised state as false */ |
| 395 | em.handler.onus.Store(onuKey, NewOnuDevice(onuInCache.(*OnuDevice).deviceID, onuInCache.(*OnuDevice).deviceType, |
| 396 | onuInCache.(*OnuDevice).serialNumber, onuInCache.(*OnuDevice).onuID, onuInCache.(*OnuDevice).intfID, |
| 397 | onuInCache.(*OnuDevice).proxyDeviceID, false)) |
| 398 | } |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 399 | } |
Thiyagarajan Subramani | 34a0028 | 2020-03-10 20:19:31 +0530 | [diff] [blame] | 400 | |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 401 | /* Send event to KAFKA */ |
| 402 | if err := em.eventProxy.SendDeviceEvent(&de, communication, onu, raisedTs); err != nil { |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 403 | return err |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 404 | } |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame^] | 405 | 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] | 406 | return nil |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 407 | } |
| 408 | |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 409 | func (em *OpenOltEventMgr) onuActivationFailIndication(oaf *oop.OnuActivationFailureIndication, deviceID string, raisedTs int64) error { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 410 | var de voltha.DeviceEvent |
| 411 | context := make(map[string]string) |
| 412 | /* Populating event context */ |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 413 | context["intf-id"] = strconv.FormatUint(uint64(oaf.IntfId), base10) |
| 414 | context["onu-id"] = strconv.FormatUint(uint64(oaf.OnuId), base10) |
Scott Baker | d4df118 | 2020-02-05 11:38:42 -0800 | [diff] [blame] | 415 | context["fail-reason"] = strconv.FormatUint(uint64(oaf.FailReason), base10) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 416 | /* Populating device event body */ |
| 417 | de.Context = context |
| 418 | de.ResourceId = deviceID |
| 419 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuActivationFailEvent, "RAISE_EVENT") |
| 420 | /* Send event to KAFKA */ |
| 421 | if err := em.eventProxy.SendDeviceEvent(&de, equipment, pon, raisedTs); err != nil { |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 422 | return err |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 423 | } |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame^] | 424 | 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] | 425 | return nil |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 426 | } |
| 427 | |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 428 | func (em *OpenOltEventMgr) onuLossOmciIndication(onuLossOmci *oop.OnuLossOfOmciChannelIndication, deviceID string, raisedTs int64) error { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 429 | var de voltha.DeviceEvent |
| 430 | context := make(map[string]string) |
| 431 | /* Populating event context */ |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 432 | context["intf-id"] = strconv.FormatUint(uint64(onuLossOmci.IntfId), base10) |
| 433 | context["onu-id"] = strconv.FormatUint(uint64(onuLossOmci.OnuId), base10) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 434 | /* Populating device event body */ |
| 435 | de.Context = context |
| 436 | de.ResourceId = deviceID |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 437 | if onuLossOmci.Status == statusCheckOn { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 438 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuLossOmciEvent, "RAISE_EVENT") |
| 439 | } else { |
| 440 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuLossOmciEvent, "CLEAR_EVENT") |
| 441 | } |
| 442 | /* Send event to KAFKA */ |
| 443 | if err := em.eventProxy.SendDeviceEvent(&de, communication, pon, raisedTs); err != nil { |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 444 | return err |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 445 | } |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame^] | 446 | 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] | 447 | return nil |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 448 | } |
| 449 | |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 450 | func (em *OpenOltEventMgr) onuDriftOfWindowIndication(onuDriftWindow *oop.OnuDriftOfWindowIndication, deviceID string, raisedTs int64) error { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 451 | var de voltha.DeviceEvent |
| 452 | context := make(map[string]string) |
| 453 | /* Populating event context */ |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 454 | context["intf-id"] = strconv.FormatUint(uint64(onuDriftWindow.IntfId), base10) |
| 455 | context["onu-id"] = strconv.FormatUint(uint64(onuDriftWindow.OnuId), base10) |
Scott Baker | d4df118 | 2020-02-05 11:38:42 -0800 | [diff] [blame] | 456 | context["drift"] = strconv.FormatUint(uint64(onuDriftWindow.Drift), base10) |
| 457 | context["new-eqd"] = strconv.FormatUint(uint64(onuDriftWindow.NewEqd), base10) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 458 | /* Populating device event body */ |
| 459 | de.Context = context |
| 460 | de.ResourceId = deviceID |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 461 | if onuDriftWindow.Status == statusCheckOn { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 462 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuDriftOfWindowEvent, "RAISE_EVENT") |
| 463 | } else { |
| 464 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuDriftOfWindowEvent, "CLEAR_EVENT") |
| 465 | } |
| 466 | /* Send event to KAFKA */ |
| 467 | if err := em.eventProxy.SendDeviceEvent(&de, communication, pon, raisedTs); err != nil { |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 468 | return err |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 469 | } |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame^] | 470 | 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] | 471 | return nil |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 472 | } |
| 473 | |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 474 | func (em *OpenOltEventMgr) onuSignalDegradeIndication(onuSignalDegrade *oop.OnuSignalDegradeIndication, deviceID string, raisedTs int64) error { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 475 | var de voltha.DeviceEvent |
| 476 | context := make(map[string]string) |
| 477 | /* Populating event context */ |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 478 | context["intf-id"] = strconv.FormatUint(uint64(onuSignalDegrade.IntfId), base10) |
| 479 | context["onu-id"] = strconv.FormatUint(uint64(onuSignalDegrade.OnuId), base10) |
Scott Baker | d4df118 | 2020-02-05 11:38:42 -0800 | [diff] [blame] | 480 | context["inverse-bit-error-rate"] = strconv.FormatUint(uint64(onuSignalDegrade.InverseBitErrorRate), base10) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 481 | /* Populating device event body */ |
| 482 | de.Context = context |
| 483 | de.ResourceId = deviceID |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 484 | if onuSignalDegrade.Status == statusCheckOn { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 485 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuSignalDegradeEvent, "RAISE_EVENT") |
| 486 | } else { |
| 487 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuSignalDegradeEvent, "CLEAR_EVENT") |
| 488 | } |
| 489 | /* Send event to KAFKA */ |
| 490 | if err := em.eventProxy.SendDeviceEvent(&de, communication, pon, raisedTs); err != nil { |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 491 | return err |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 492 | } |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame^] | 493 | 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] | 494 | return nil |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 495 | } |
| 496 | |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 497 | func (em *OpenOltEventMgr) onuSignalsFailIndication(onuSignalsFail *oop.OnuSignalsFailureIndication, deviceID string, raisedTs int64) error { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 498 | var de voltha.DeviceEvent |
| 499 | context := make(map[string]string) |
| 500 | /* Populating event context */ |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 501 | context["onu-id"] = strconv.FormatUint(uint64(onuSignalsFail.OnuId), base10) |
| 502 | context["intf-id"] = strconv.FormatUint(uint64(onuSignalsFail.IntfId), base10) |
| 503 | context["inverse-bit-error-rate"] = strconv.FormatUint(uint64(onuSignalsFail.InverseBitErrorRate), base10) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 504 | /* Populating device event body */ |
| 505 | de.Context = context |
| 506 | de.ResourceId = deviceID |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 507 | if onuSignalsFail.Status == statusCheckOn { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 508 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuSignalsFailEvent, "RAISE_EVENT") |
| 509 | } else { |
| 510 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuSignalsFailEvent, "CLEAR_EVENT") |
| 511 | } |
| 512 | /* Send event to KAFKA */ |
| 513 | if err := em.eventProxy.SendDeviceEvent(&de, communication, pon, raisedTs); err != nil { |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 514 | return err |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 515 | } |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame^] | 516 | 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] | 517 | return nil |
| 518 | } |
| 519 | |
Naga Manjunath | f6f7464 | 2020-01-13 21:37:28 +0530 | [diff] [blame] | 520 | func (em *OpenOltEventMgr) onuStartupFailedIndication(onuStartupFail *oop.OnuStartupFailureIndication, deviceID string, raisedTs int64) error { |
| 521 | var de voltha.DeviceEvent |
| 522 | context := make(map[string]string) |
| 523 | /* Populating event context */ |
| 524 | context["onu-id"] = strconv.FormatUint(uint64(onuStartupFail.OnuId), base10) |
| 525 | context["intf-id"] = strconv.FormatUint(uint64(onuStartupFail.IntfId), base10) |
| 526 | |
| 527 | /* Populating device event body */ |
| 528 | de.Context = context |
| 529 | de.ResourceId = deviceID |
| 530 | if onuStartupFail.Status == statusCheckOn { |
| 531 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuStartupFailEvent, "RAISE_EVENT") |
| 532 | } else { |
| 533 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuStartupFailEvent, "CLEAR_EVENT") |
| 534 | } |
| 535 | /* Send event to KAFKA */ |
| 536 | if err := em.eventProxy.SendDeviceEvent(&de, communication, pon, raisedTs); err != nil { |
Naga Manjunath | f6f7464 | 2020-01-13 21:37:28 +0530 | [diff] [blame] | 537 | return err |
| 538 | } |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame^] | 539 | 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] | 540 | return nil |
| 541 | } |
| 542 | |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 543 | func (em *OpenOltEventMgr) onuLossOfSyncIndication(onuLOKI *oop.OnuLossOfKeySyncFailureIndication, deviceID string, raisedTs int64) error { |
| 544 | var de voltha.DeviceEvent |
| 545 | context := make(map[string]string) |
| 546 | /* Populating event context */ |
| 547 | context["onu-id"] = strconv.FormatUint(uint64(onuLOKI.OnuId), base10) |
| 548 | context["intf-id"] = strconv.FormatUint(uint64(onuLOKI.IntfId), base10) |
| 549 | /* Populating device event body */ |
| 550 | de.Context = context |
| 551 | de.ResourceId = deviceID |
| 552 | if onuLOKI.Status == statusCheckOn { |
| 553 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuLossOfKeySyncEvent, "RAISE_EVENT") |
| 554 | } else { |
| 555 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuLossOfKeySyncEvent, "CLEAR_EVENT") |
| 556 | } |
| 557 | |
| 558 | /* Send event to KAFKA */ |
| 559 | if err := em.eventProxy.SendDeviceEvent(&de, security, onu, raisedTs); err != nil { |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 560 | return err |
| 561 | } |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame^] | 562 | 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] | 563 | return nil |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 564 | } |
kesavand | 39e0aa3 | 2020-01-28 20:58:50 -0500 | [diff] [blame] | 565 | |
| 566 | // oltIntfOperIndication handles Up and Down state of an OLT PON ports |
Devmalya Paul | 2440047 | 2020-03-12 19:26:02 -0400 | [diff] [blame] | 567 | func (em *OpenOltEventMgr) oltIntfOperIndication(ifindication *oop.IntfOperIndication, deviceID string, raisedTs int64) error { |
kesavand | 39e0aa3 | 2020-01-28 20:58:50 -0500 | [diff] [blame] | 568 | var de voltha.DeviceEvent |
| 569 | context := make(map[string]string) |
| 570 | portID := IntfIDToPortNo(ifindication.IntfId, voltha.Port_PON_OLT) |
| 571 | device, err := em.handler.coreProxy.GetDevice(ctx.Background(), deviceID, deviceID) |
| 572 | if err != nil { |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame^] | 573 | return olterrors.NewErrAdapter("error-while-fetching-device-object", log.Fields{"DeviceId": deviceID}, err) |
kesavand | 39e0aa3 | 2020-01-28 20:58:50 -0500 | [diff] [blame] | 574 | } |
| 575 | for _, port := range device.Ports { |
| 576 | if port.PortNo == portID { |
| 577 | // Events are suppressed if the Port Adminstate is not enabled. |
| 578 | if port.AdminState != common.AdminState_ENABLED { |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame^] | 579 | 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] | 580 | return nil |
kesavand | 39e0aa3 | 2020-01-28 20:58:50 -0500 | [diff] [blame] | 581 | } |
| 582 | break |
| 583 | } |
| 584 | } |
| 585 | /* Populating event context */ |
| 586 | context["oper-state"] = ifindication.GetOperState() |
| 587 | /* Populating device event body */ |
| 588 | de.Context = context |
| 589 | de.ResourceId = deviceID |
| 590 | |
| 591 | if ifindication.GetOperState() == operationStateDown { |
| 592 | de.DeviceEventName = fmt.Sprintf("%s_%s", ponIntfDownIndiction, "RAISE_EVENT") |
| 593 | } else if ifindication.OperState == operationStateUp { |
| 594 | de.DeviceEventName = fmt.Sprintf("%s_%s", ponIntfDownIndiction, "CLEAR_EVENT") |
| 595 | } |
| 596 | /* Send event to KAFKA */ |
| 597 | if err := em.eventProxy.SendDeviceEvent(&de, communication, olt, raisedTs); err != nil { |
Devmalya Paul | 2440047 | 2020-03-12 19:26:02 -0400 | [diff] [blame] | 598 | 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] | 599 | } |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 600 | logger.Debug("sent-olt-intf-oper-status-event-to-kafka") |
Devmalya Paul | 2440047 | 2020-03-12 19:26:02 -0400 | [diff] [blame] | 601 | return nil |
kesavand | 39e0aa3 | 2020-01-28 20:58:50 -0500 | [diff] [blame] | 602 | } |
Devmalya Paul | 1abc34e | 2020-02-04 20:48:06 -0500 | [diff] [blame] | 603 | |
| 604 | func (em *OpenOltEventMgr) onuDeactivationFailureIndication(onuDFI *oop.OnuDeactivationFailureIndication, deviceID string, raisedTs int64) error { |
| 605 | var de voltha.DeviceEvent |
| 606 | context := make(map[string]string) |
| 607 | /* Populating event context */ |
| 608 | context["onu-id"] = strconv.FormatUint(uint64(onuDFI.OnuId), base10) |
| 609 | context["intf-id"] = strconv.FormatUint(uint64(onuDFI.IntfId), base10) |
| 610 | context["failure-reason"] = strconv.FormatUint(uint64(onuDFI.FailReason), base10) |
| 611 | /* Populating device event body */ |
| 612 | de.Context = context |
| 613 | de.ResourceId = deviceID |
| 614 | de.DeviceEventName = onuDeactivationFailureEvent |
| 615 | |
| 616 | /* Send event to KAFKA */ |
| 617 | if err := em.eventProxy.SendDeviceEvent(&de, equipment, onu, raisedTs); err != nil { |
Devmalya Paul | 1abc34e | 2020-02-04 20:48:06 -0500 | [diff] [blame] | 618 | return err |
| 619 | } |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame^] | 620 | 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] | 621 | return nil |
| 622 | } |
Devmalya Paul | 6f063a6 | 2020-02-19 19:19:06 -0500 | [diff] [blame] | 623 | |
| 624 | func (em *OpenOltEventMgr) onuRemoteDefectIndication(onuRDI *oop.OnuRemoteDefectIndication, deviceID string, raisedTs int64) error { |
| 625 | /* Populating event context */ |
| 626 | context := map[string]string{ |
| 627 | "onu-id": strconv.FormatUint(uint64(onuRDI.OnuId), base10), |
| 628 | "intf-id": strconv.FormatUint(uint64(onuRDI.IntfId), base10), |
| 629 | "rdi-errors": strconv.FormatUint(uint64(onuRDI.RdiErrors), base10), |
| 630 | } |
| 631 | /* Populating device event body */ |
| 632 | de := &voltha.DeviceEvent{ |
| 633 | Context: context, |
| 634 | ResourceId: deviceID, |
| 635 | DeviceEventName: onuRemoteDefectIndication, |
| 636 | } |
| 637 | /* Send event to KAFKA */ |
| 638 | if err := em.eventProxy.SendDeviceEvent(de, equipment, onu, raisedTs); err != nil { |
Devmalya Paul | 6f063a6 | 2020-02-19 19:19:06 -0500 | [diff] [blame] | 639 | return err |
| 640 | } |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame^] | 641 | 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] | 642 | return nil |
| 643 | } |
| 644 | |
| 645 | func (em *OpenOltEventMgr) onuLossOfGEMChannelDelineationIndication(onuGCD *oop.OnuLossOfGEMChannelDelineationIndication, deviceID string, raisedTs int64) error { |
| 646 | /* Populating event context */ |
| 647 | context := map[string]string{ |
| 648 | "onu-id": strconv.FormatUint(uint64(onuGCD.OnuId), base10), |
| 649 | "intf-id": strconv.FormatUint(uint64(onuGCD.IntfId), base10), |
| 650 | "delineation-errors": strconv.FormatUint(uint64(onuGCD.DelineationErrors), base10), |
| 651 | } |
| 652 | /* Populating device event body */ |
| 653 | de := &voltha.DeviceEvent{ |
| 654 | Context: context, |
| 655 | ResourceId: deviceID, |
| 656 | } |
| 657 | if onuGCD.Status == statusCheckOn { |
| 658 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuLossOfGEMChannelDelineationEvent, "RAISE_EVENT") |
| 659 | } else { |
| 660 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuLossOfGEMChannelDelineationEvent, "CLEAR_EVENT") |
| 661 | } |
| 662 | /* Send event to KAFKA */ |
| 663 | if err := em.eventProxy.SendDeviceEvent(de, communication, onu, raisedTs); err != nil { |
| 664 | return err |
| 665 | } |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame^] | 666 | 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] | 667 | return nil |
| 668 | } |
| 669 | |
| 670 | func (em *OpenOltEventMgr) onuPhysicalEquipmentErrorIndication(onuErr *oop.OnuPhysicalEquipmentErrorIndication, deviceID string, raisedTs int64) error { |
| 671 | /* Populating event context */ |
| 672 | context := map[string]string{ |
| 673 | "onu-id": strconv.FormatUint(uint64(onuErr.OnuId), base10), |
| 674 | "intf-id": strconv.FormatUint(uint64(onuErr.IntfId), base10), |
| 675 | } |
| 676 | /* Populating device event body */ |
| 677 | de := &voltha.DeviceEvent{ |
| 678 | Context: context, |
| 679 | ResourceId: deviceID, |
| 680 | } |
| 681 | if onuErr.Status == statusCheckOn { |
| 682 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuPhysicalEquipmentErrorEvent, "RAISE_EVENT") |
| 683 | } else { |
| 684 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuPhysicalEquipmentErrorEvent, "CLEAR_EVENT") |
| 685 | } |
| 686 | /* Send event to KAFKA */ |
| 687 | if err := em.eventProxy.SendDeviceEvent(de, equipment, onu, raisedTs); err != nil { |
| 688 | return err |
| 689 | } |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame^] | 690 | 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] | 691 | return nil |
| 692 | } |
| 693 | |
| 694 | func (em *OpenOltEventMgr) onuLossOfAcknowledgementIndication(onuLOA *oop.OnuLossOfAcknowledgementIndication, deviceID string, raisedTs int64) error { |
| 695 | /* Populating event context */ |
| 696 | context := map[string]string{ |
| 697 | "onu-id": strconv.FormatUint(uint64(onuLOA.OnuId), base10), |
| 698 | "intf-id": strconv.FormatUint(uint64(onuLOA.IntfId), base10), |
| 699 | } |
| 700 | /* Populating device event body */ |
| 701 | de := &voltha.DeviceEvent{ |
| 702 | Context: context, |
| 703 | ResourceId: deviceID, |
| 704 | } |
| 705 | if onuLOA.Status == statusCheckOn { |
| 706 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuLossOfAcknowledgementEvent, "RAISE_EVENT") |
| 707 | } else { |
| 708 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuLossOfAcknowledgementEvent, "CLEAR_EVENT") |
| 709 | } |
| 710 | /* Send event to KAFKA */ |
| 711 | if err := em.eventProxy.SendDeviceEvent(de, equipment, onu, raisedTs); err != nil { |
| 712 | return err |
| 713 | } |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame^] | 714 | 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] | 715 | return nil |
| 716 | } |
Devmalya Paul | eb5294e | 2020-03-19 03:01:39 -0400 | [diff] [blame] | 717 | |
| 718 | func (em *OpenOltEventMgr) onuDifferentialReachExceededIndication(onuDRE *oop.OnuDifferentialReachExceededIndication, deviceID string, raisedTs int64) error { |
| 719 | /* Populating event context */ |
| 720 | context := map[string]string{ |
| 721 | "onu-id": strconv.FormatUint(uint64(onuDRE.OnuId), base10), |
| 722 | "intf-id": strconv.FormatUint(uint64(onuDRE.IntfId), base10), |
| 723 | "differential-distance": strconv.FormatUint(uint64(onuDRE.Distance), base10), |
| 724 | } |
| 725 | /* Populating device event body */ |
| 726 | de := &voltha.DeviceEvent{ |
| 727 | Context: context, |
| 728 | ResourceId: deviceID, |
| 729 | } |
| 730 | if onuDRE.Status == statusCheckOn { |
| 731 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuDifferentialReachExceededEvent, "RAISE_EVENT") |
| 732 | } else { |
| 733 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuDifferentialReachExceededEvent, "CLEAR_EVENT") |
| 734 | } |
| 735 | /* Send event to KAFKA */ |
| 736 | if err := em.eventProxy.SendDeviceEvent(de, equipment, onu, raisedTs); err != nil { |
| 737 | return err |
| 738 | } |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame^] | 739 | 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] | 740 | return nil |
| 741 | } |