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 | |
| 17 | // Package adaptercore provides APIs for the openOLT adapter |
| 18 | package adaptercore |
| 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" |
kesavand | 39e0aa3 | 2020-01-28 20:58:50 -0500 | [diff] [blame] | 27 | "github.com/opencord/voltha-protos/v3/go/common" |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 28 | oop "github.com/opencord/voltha-protos/v3/go/openolt" |
| 29 | "github.com/opencord/voltha-protos/v3/go/voltha" |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 30 | ) |
| 31 | |
| 32 | const ( |
| 33 | onuDiscoveryEvent = "ONU_DISCOVERY" |
| 34 | onuLosEvent = "ONU_LOSS_OF_SIGNAL" |
| 35 | onuLobEvent = "ONU_LOSS_OF_BURST" |
| 36 | onuLopcMissEvent = "ONU_LOPC_MISS" |
| 37 | onuLopcMicErrorEvent = "ONU_LOPC_MIC_ERROR" |
| 38 | oltLosEvent = "OLT_LOSS_OF_SIGNAL" |
Daniele Rossi | 051466a | 2019-07-26 13:39:37 +0000 | [diff] [blame] | 39 | oltIndicationDown = "OLT_DOWN_INDICATION" |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 40 | onuDyingGaspEvent = "ONU_DYING_GASP" |
| 41 | onuSignalsFailEvent = "ONU_SIGNALS_FAIL" |
| 42 | onuStartupFailEvent = "ONU_STARTUP_FAIL" |
| 43 | onuSignalDegradeEvent = "ONU_SIGNAL_DEGRADE" |
| 44 | onuDriftOfWindowEvent = "ONU_DRIFT_OF_WINDOW" |
| 45 | onuActivationFailEvent = "ONU_ACTIVATION_FAIL" |
| 46 | onuProcessingErrorEvent = "ONU_PROCESSING_ERROR" |
| 47 | onuTiwiEvent = "ONU_TRANSMISSION_WARNING" |
| 48 | onuLossOmciEvent = "ONU_LOSS_OF_OMCI_CHANNEL" |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 49 | onuLossOfKeySyncEvent = "ONU_LOSS_OF_KEY_SYNC" |
| 50 | onuLossOfFrameEvent = "ONU_LOSS_OF_FRAME" |
Naga Manjunath | ffa5c21 | 2019-12-06 15:15:04 +0530 | [diff] [blame] | 51 | onuLossOfPloamEvent = "ONU_LOSS_OF_PLOAM" |
kesavand | 39e0aa3 | 2020-01-28 20:58:50 -0500 | [diff] [blame] | 52 | ponIntfDownIndiction = "OLT_PON_INTERFACE_DOWN" |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 53 | ) |
| 54 | |
| 55 | const ( |
| 56 | pon = voltha.EventSubCategory_PON |
| 57 | olt = voltha.EventSubCategory_OLT |
| 58 | ont = voltha.EventSubCategory_ONT |
| 59 | onu = voltha.EventSubCategory_ONU |
| 60 | nni = voltha.EventSubCategory_NNI |
| 61 | service = voltha.EventCategory_SERVICE |
| 62 | security = voltha.EventCategory_SECURITY |
| 63 | equipment = voltha.EventCategory_EQUIPMENT |
| 64 | processing = voltha.EventCategory_PROCESSING |
| 65 | environment = voltha.EventCategory_ENVIRONMENT |
| 66 | communication = voltha.EventCategory_COMMUNICATION |
| 67 | ) |
| 68 | |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 69 | const ( |
| 70 | // statusCheckOn represents status check On |
| 71 | statusCheckOn = "on" |
| 72 | // statusCheckOff represents status check Off |
| 73 | statusCheckOff = "off" |
| 74 | // operationStateUp represents operation state Up |
| 75 | operationStateUp = "up" |
| 76 | // operationStateDown represents operation state Down |
| 77 | operationStateDown = "down" |
| 78 | // base10 represents base 10 conversion |
| 79 | base10 = 10 |
| 80 | ) |
| 81 | |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 82 | // OpenOltEventMgr struct contains |
| 83 | type OpenOltEventMgr struct { |
kdarapu | 381c690 | 2019-07-31 18:23:16 +0530 | [diff] [blame] | 84 | eventProxy adapterif.EventProxy |
Devmalya Paul | 90ca301 | 2019-09-02 21:55:45 -0400 | [diff] [blame] | 85 | handler *DeviceHandler |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | // 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] | 89 | func NewEventMgr(eventProxy adapterif.EventProxy, handler *DeviceHandler) *OpenOltEventMgr { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 90 | var em OpenOltEventMgr |
| 91 | em.eventProxy = eventProxy |
Devmalya Paul | 90ca301 | 2019-09-02 21:55:45 -0400 | [diff] [blame] | 92 | em.handler = handler |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 93 | return &em |
| 94 | } |
| 95 | |
| 96 | // ProcessEvents is function to process and publish OpenOLT event |
| 97 | func (em *OpenOltEventMgr) ProcessEvents(alarmInd *oop.AlarmIndication, deviceID string, raisedTs int64) { |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 98 | var err error |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 99 | switch alarmInd.Data.(type) { |
| 100 | case *oop.AlarmIndication_LosInd: |
| 101 | log.Infow("Received LOS indication", log.Fields{"alarm_ind": alarmInd}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 102 | err = em.oltLosIndication(alarmInd.GetLosInd(), deviceID, raisedTs) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 103 | |
| 104 | case *oop.AlarmIndication_OnuAlarmInd: |
| 105 | log.Infow("Received onu alarm indication ", log.Fields{"alarm_ind": alarmInd}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 106 | err = em.onuAlarmIndication(alarmInd.GetOnuAlarmInd(), deviceID, raisedTs) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 107 | |
| 108 | case *oop.AlarmIndication_DyingGaspInd: |
| 109 | log.Infow("Received dying gasp indication", log.Fields{"alarm_ind": alarmInd}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 110 | err = em.onuDyingGaspIndication(alarmInd.GetDyingGaspInd(), deviceID, raisedTs) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 111 | case *oop.AlarmIndication_OnuActivationFailInd: |
| 112 | log.Infow("Received onu activation fail indication ", log.Fields{"alarm_ind": alarmInd}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 113 | err = em.onuActivationFailIndication(alarmInd.GetOnuActivationFailInd(), deviceID, raisedTs) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 114 | |
| 115 | case *oop.AlarmIndication_OnuLossOmciInd: |
| 116 | log.Infow("Received onu loss omci indication ", log.Fields{"alarm_ind": alarmInd}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 117 | err = em.onuLossOmciIndication(alarmInd.GetOnuLossOmciInd(), deviceID, raisedTs) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 118 | |
| 119 | case *oop.AlarmIndication_OnuDriftOfWindowInd: |
| 120 | log.Infow("Received onu drift of window indication ", log.Fields{"alarm_ind": alarmInd}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 121 | err = em.onuDriftOfWindowIndication(alarmInd.GetOnuDriftOfWindowInd(), deviceID, raisedTs) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 122 | |
| 123 | case *oop.AlarmIndication_OnuSignalDegradeInd: |
| 124 | log.Infow("Received onu signal degrade indication ", log.Fields{"alarm_ind": alarmInd}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 125 | err = em.onuSignalDegradeIndication(alarmInd.GetOnuSignalDegradeInd(), deviceID, raisedTs) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 126 | |
| 127 | case *oop.AlarmIndication_OnuSignalsFailInd: |
| 128 | log.Infow("Received onu signal fail indication ", log.Fields{"alarm_ind": alarmInd}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 129 | err = em.onuSignalsFailIndication(alarmInd.GetOnuSignalsFailInd(), deviceID, raisedTs) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 130 | |
Naga Manjunath | f6f7464 | 2020-01-13 21:37:28 +0530 | [diff] [blame] | 131 | case *oop.AlarmIndication_OnuStartupFailInd: |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 132 | log.Infow("Received onu startup fail indication ", log.Fields{"alarm_ind": alarmInd}) |
Naga Manjunath | f6f7464 | 2020-01-13 21:37:28 +0530 | [diff] [blame] | 133 | err = em.onuStartupFailedIndication(alarmInd.GetOnuStartupFailInd(), deviceID, raisedTs) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 134 | case *oop.AlarmIndication_OnuTiwiInd: |
| 135 | log.Infow("Received onu transmission warning indication ", log.Fields{"alarm_ind": alarmInd}) |
| 136 | log.Infow("Not implemented yet", log.Fields{"alarm_ind": "Onu-Transmission-indication"}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 137 | case *oop.AlarmIndication_OnuLossOfSyncFailInd: |
| 138 | log.Infow("Received onu Loss of Sync Fail indication ", log.Fields{"alarm_ind": alarmInd}) |
| 139 | err = em.onuLossOfSyncIndication(alarmInd.GetOnuLossOfSyncFailInd(), deviceID, raisedTs) |
| 140 | case *oop.AlarmIndication_OnuItuPonStatsInd: |
| 141 | log.Infow("Received onu Itu Pon Stats indication ", log.Fields{"alarm_ind": alarmInd}) |
| 142 | log.Infow("Not implemented yet", log.Fields{"alarm_ind": alarmInd}) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 143 | default: |
| 144 | log.Errorw("Received unknown indication type", log.Fields{"alarm_ind": alarmInd}) |
| 145 | |
| 146 | } |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 147 | if err != nil { |
| 148 | log.Errorw("Failed to publish message to KAFKA", log.Fields{"error": err}) |
| 149 | } |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 150 | } |
| 151 | |
Daniele Rossi | 051466a | 2019-07-26 13:39:37 +0000 | [diff] [blame] | 152 | // oltUpDownIndication handles Up and Down state of an OLT |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 153 | func (em *OpenOltEventMgr) oltUpDownIndication(oltIndication *oop.OltIndication, deviceID string, raisedTs int64) error { |
Daniele Rossi | 051466a | 2019-07-26 13:39:37 +0000 | [diff] [blame] | 154 | var de voltha.DeviceEvent |
| 155 | context := make(map[string]string) |
| 156 | /* Populating event context */ |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 157 | context["oper-state"] = oltIndication.OperState |
Daniele Rossi | 051466a | 2019-07-26 13:39:37 +0000 | [diff] [blame] | 158 | /* Populating device event body */ |
| 159 | de.Context = context |
| 160 | de.ResourceId = deviceID |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 161 | if oltIndication.OperState == operationStateDown { |
Daniele Rossi | 051466a | 2019-07-26 13:39:37 +0000 | [diff] [blame] | 162 | de.DeviceEventName = fmt.Sprintf("%s_%s", oltIndicationDown, "RAISE_EVENT") |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 163 | } else if oltIndication.OperState == operationStateUp { |
Daniele Rossi | 051466a | 2019-07-26 13:39:37 +0000 | [diff] [blame] | 164 | de.DeviceEventName = fmt.Sprintf("%s_%s", oltIndicationDown, "CLEAR_EVENT") |
| 165 | } |
| 166 | /* Send event to KAFKA */ |
| 167 | if err := em.eventProxy.SendDeviceEvent(&de, communication, olt, raisedTs); err != nil { |
| 168 | log.Errorw("Failed to send OLT event", log.Fields{"err": err}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 169 | return err |
Daniele Rossi | 051466a | 2019-07-26 13:39:37 +0000 | [diff] [blame] | 170 | } |
| 171 | log.Infow("OLT UpDown event sent to KAFKA", log.Fields{}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 172 | return nil |
Daniele Rossi | 051466a | 2019-07-26 13:39:37 +0000 | [diff] [blame] | 173 | } |
| 174 | |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 175 | // OnuDiscoveryIndication is an exported method to handle ONU discovery event |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 176 | 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] | 177 | var de voltha.DeviceEvent |
| 178 | context := make(map[string]string) |
| 179 | /* Populating event context */ |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 180 | context["onu-id"] = strconv.FormatUint(uint64(OnuID), base10) |
| 181 | context["intf-id"] = strconv.FormatUint(uint64(onuDisc.IntfId), base10) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 182 | context["serial-number"] = serialNumber |
| 183 | /* Populating device event body */ |
| 184 | de.Context = context |
| 185 | de.ResourceId = deviceID |
| 186 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuDiscoveryEvent, "RAISE_EVENT") |
| 187 | /* Send event to KAFKA */ |
| 188 | if err := em.eventProxy.SendDeviceEvent(&de, equipment, pon, raisedTs); err != nil { |
| 189 | log.Errorw("Failed to send ONU discovery event", log.Fields{"serial-number": serialNumber, "intf-id": onuDisc.IntfId}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 190 | return err |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 191 | } |
| 192 | log.Infow("ONU discovery event sent to KAFKA", log.Fields{"serial-number": serialNumber, "intf-id": onuDisc.IntfId}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 193 | return nil |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 194 | } |
| 195 | |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 196 | func (em *OpenOltEventMgr) oltLosIndication(oltLos *oop.LosIndication, deviceID string, raisedTs int64) error { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 197 | var de voltha.DeviceEvent |
| 198 | context := make(map[string]string) |
| 199 | /* Populating event context */ |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 200 | context["intf-id"] = strconv.FormatUint(uint64(oltLos.IntfId), base10) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 201 | /* Populating device event body */ |
| 202 | de.Context = context |
| 203 | de.ResourceId = deviceID |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 204 | if oltLos.Status == statusCheckOn { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 205 | de.DeviceEventName = fmt.Sprintf("%s_%s", oltLosEvent, "RAISE_EVENT") |
| 206 | } else { |
| 207 | de.DeviceEventName = fmt.Sprintf("%s_%s", oltLosEvent, "CLEAR_EVENT") |
| 208 | } |
| 209 | /* Send event to KAFKA */ |
| 210 | if err := em.eventProxy.SendDeviceEvent(&de, communication, olt, raisedTs); err != nil { |
| 211 | log.Errorw("Failed to send OLT loss of signal event", log.Fields{"intf-id": oltLos.IntfId}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 212 | return err |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 213 | } |
| 214 | log.Infow("OLT LOS event sent to KAFKA", log.Fields{"intf-id": oltLos.IntfId}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 215 | return nil |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 216 | } |
| 217 | |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 218 | func (em *OpenOltEventMgr) onuDyingGaspIndication(dgi *oop.DyingGaspIndication, deviceID string, raisedTs int64) error { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 219 | var de voltha.DeviceEvent |
Devmalya Paul | 90ca301 | 2019-09-02 21:55:45 -0400 | [diff] [blame] | 220 | var serialNumber string |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 221 | context := make(map[string]string) |
| 222 | /* Populating event context */ |
Devmalya Paul | 90ca301 | 2019-09-02 21:55:45 -0400 | [diff] [blame] | 223 | serialNumber = "" |
Naga Manjunath | a8dc937 | 2019-10-31 23:01:18 +0530 | [diff] [blame] | 224 | onu := em.handler.formOnuKey(dgi.IntfId, dgi.OnuId) |
| 225 | if onu, ok := em.handler.onus.Load(onu); ok { |
| 226 | serialNumber = onu.(*OnuDevice).serialNumber |
Devmalya Paul | 90ca301 | 2019-09-02 21:55:45 -0400 | [diff] [blame] | 227 | } |
| 228 | context["serial-number"] = serialNumber |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 229 | context["intf-id"] = strconv.FormatUint(uint64(dgi.IntfId), base10) |
| 230 | context["onu-id"] = strconv.FormatUint(uint64(dgi.OnuId), base10) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 231 | /* Populating device event body */ |
| 232 | de.Context = context |
| 233 | de.ResourceId = deviceID |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 234 | if dgi.Status == statusCheckOn { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 235 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuDyingGaspEvent, "RAISE_EVENT") |
| 236 | } else { |
| 237 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuDyingGaspEvent, "CLEAR_EVENT") |
| 238 | } |
| 239 | /* Send event to KAFKA */ |
| 240 | if err := em.eventProxy.SendDeviceEvent(&de, communication, pon, raisedTs); err != nil { |
| 241 | log.Errorw("Failed to send ONU Dying gasp event", log.Fields{"intf-id": dgi.IntfId, "onu-id": dgi.OnuId}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 242 | return err |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 243 | } |
| 244 | log.Infow("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] | 245 | return nil |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 246 | } |
| 247 | |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 248 | func (em *OpenOltEventMgr) onuAlarmIndication(onuAlarm *oop.OnuAlarmIndication, deviceID string, raisedTs int64) error { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 249 | var de voltha.DeviceEvent |
| 250 | context := make(map[string]string) |
| 251 | /* Populating event context */ |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 252 | context["intf-id"] = strconv.FormatUint(uint64(onuAlarm.IntfId), base10) |
| 253 | context["onu-id"] = strconv.FormatUint(uint64(onuAlarm.OnuId), base10) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 254 | /* Populating device event body */ |
| 255 | de.Context = context |
| 256 | de.ResourceId = deviceID |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 257 | if onuAlarm.LosStatus == statusCheckOn { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 258 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuLosEvent, "RAISE_EVENT") |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 259 | } else if onuAlarm.LosStatus == statusCheckOff { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 260 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuLosEvent, "CLEAR_EVENT") |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 261 | } else if onuAlarm.LobStatus == statusCheckOn { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 262 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuLobEvent, "RAISE_EVENT") |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 263 | } else if onuAlarm.LobStatus == statusCheckOff { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 264 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuLobEvent, "CLEAR_EVENT") |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 265 | } else if onuAlarm.LopcMissStatus == statusCheckOn { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 266 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuLopcMissEvent, "RAISE_EVENT") |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 267 | } else if onuAlarm.LopcMissStatus == statusCheckOff { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 268 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuLopcMissEvent, "CLEAR_EVENT") |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 269 | } else if onuAlarm.LopcMicErrorStatus == statusCheckOn { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 270 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuLopcMicErrorEvent, "RAISE_EVENT") |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 271 | } else if onuAlarm.LopcMicErrorStatus == statusCheckOff { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 272 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuLopcMicErrorEvent, "CLEAR_EVENT") |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 273 | } else if onuAlarm.LofiStatus == statusCheckOn { |
| 274 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuLossOfFrameEvent, "RAISE_EVENT") |
| 275 | } else if onuAlarm.LofiStatus == statusCheckOff { |
| 276 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuLossOfFrameEvent, "CLEAR_EVENT") |
Naga Manjunath | ffa5c21 | 2019-12-06 15:15:04 +0530 | [diff] [blame] | 277 | } else if onuAlarm.LoamiStatus == statusCheckOn { |
| 278 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuLossOfPloamEvent, "RAISE_EVENT") |
| 279 | } else if onuAlarm.LoamiStatus == statusCheckOff { |
| 280 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuLossOfPloamEvent, "CLEAR_EVENT") |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 281 | } |
| 282 | /* Send event to KAFKA */ |
| 283 | if err := em.eventProxy.SendDeviceEvent(&de, communication, onu, raisedTs); err != nil { |
| 284 | log.Errorw("Failed to send ONU Los event", log.Fields{"onu-id": onuAlarm.OnuId, "intf-id": onuAlarm.IntfId}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 285 | return err |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 286 | } |
| 287 | log.Infow("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] | 288 | return nil |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 289 | } |
| 290 | |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 291 | func (em *OpenOltEventMgr) onuActivationFailIndication(oaf *oop.OnuActivationFailureIndication, deviceID string, raisedTs int64) error { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 292 | var de voltha.DeviceEvent |
| 293 | context := make(map[string]string) |
| 294 | /* Populating event context */ |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 295 | context["intf-id"] = strconv.FormatUint(uint64(oaf.IntfId), base10) |
| 296 | context["onu-id"] = strconv.FormatUint(uint64(oaf.OnuId), base10) |
Scott Baker | d4df118 | 2020-02-05 11:38:42 -0800 | [diff] [blame^] | 297 | context["fail-reason"] = strconv.FormatUint(uint64(oaf.FailReason), base10) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 298 | /* Populating device event body */ |
| 299 | de.Context = context |
| 300 | de.ResourceId = deviceID |
| 301 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuActivationFailEvent, "RAISE_EVENT") |
| 302 | /* Send event to KAFKA */ |
| 303 | if err := em.eventProxy.SendDeviceEvent(&de, equipment, pon, raisedTs); err != nil { |
| 304 | log.Errorw("Failed to send ONU activation failure event", log.Fields{"onu-id": oaf.OnuId, "intf-id": oaf.IntfId}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 305 | return err |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 306 | } |
| 307 | log.Infow("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] | 308 | return nil |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 309 | } |
| 310 | |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 311 | func (em *OpenOltEventMgr) onuLossOmciIndication(onuLossOmci *oop.OnuLossOfOmciChannelIndication, deviceID string, raisedTs int64) error { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 312 | var de voltha.DeviceEvent |
| 313 | context := make(map[string]string) |
| 314 | /* Populating event context */ |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 315 | context["intf-id"] = strconv.FormatUint(uint64(onuLossOmci.IntfId), base10) |
| 316 | context["onu-id"] = strconv.FormatUint(uint64(onuLossOmci.OnuId), base10) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 317 | /* Populating device event body */ |
| 318 | de.Context = context |
| 319 | de.ResourceId = deviceID |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 320 | if onuLossOmci.Status == statusCheckOn { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 321 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuLossOmciEvent, "RAISE_EVENT") |
| 322 | } else { |
| 323 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuLossOmciEvent, "CLEAR_EVENT") |
| 324 | } |
| 325 | /* Send event to KAFKA */ |
| 326 | if err := em.eventProxy.SendDeviceEvent(&de, communication, pon, raisedTs); err != nil { |
| 327 | log.Errorw("Failed to send ONU loss of OMCI channel event", log.Fields{"onu-id": onuLossOmci.OnuId, "intf-id": onuLossOmci.IntfId}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 328 | return err |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 329 | } |
| 330 | log.Infow("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] | 331 | return nil |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 332 | } |
| 333 | |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 334 | func (em *OpenOltEventMgr) onuDriftOfWindowIndication(onuDriftWindow *oop.OnuDriftOfWindowIndication, deviceID string, raisedTs int64) error { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 335 | var de voltha.DeviceEvent |
| 336 | context := make(map[string]string) |
| 337 | /* Populating event context */ |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 338 | context["intf-id"] = strconv.FormatUint(uint64(onuDriftWindow.IntfId), base10) |
| 339 | context["onu-id"] = strconv.FormatUint(uint64(onuDriftWindow.OnuId), base10) |
Scott Baker | d4df118 | 2020-02-05 11:38:42 -0800 | [diff] [blame^] | 340 | context["drift"] = strconv.FormatUint(uint64(onuDriftWindow.Drift), base10) |
| 341 | context["new-eqd"] = strconv.FormatUint(uint64(onuDriftWindow.NewEqd), base10) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 342 | /* Populating device event body */ |
| 343 | de.Context = context |
| 344 | de.ResourceId = deviceID |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 345 | if onuDriftWindow.Status == statusCheckOn { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 346 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuDriftOfWindowEvent, "RAISE_EVENT") |
| 347 | } else { |
| 348 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuDriftOfWindowEvent, "CLEAR_EVENT") |
| 349 | } |
| 350 | /* Send event to KAFKA */ |
| 351 | if err := em.eventProxy.SendDeviceEvent(&de, communication, pon, raisedTs); err != nil { |
| 352 | log.Errorw("Failed to send ONU drift of window event", log.Fields{"onu-id": onuDriftWindow.OnuId, "intf-id": onuDriftWindow.IntfId}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 353 | return err |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 354 | } |
| 355 | log.Infow("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] | 356 | return nil |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 357 | } |
| 358 | |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 359 | func (em *OpenOltEventMgr) onuSignalDegradeIndication(onuSignalDegrade *oop.OnuSignalDegradeIndication, deviceID string, raisedTs int64) error { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 360 | var de voltha.DeviceEvent |
| 361 | context := make(map[string]string) |
| 362 | /* Populating event context */ |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 363 | context["intf-id"] = strconv.FormatUint(uint64(onuSignalDegrade.IntfId), base10) |
| 364 | context["onu-id"] = strconv.FormatUint(uint64(onuSignalDegrade.OnuId), base10) |
Scott Baker | d4df118 | 2020-02-05 11:38:42 -0800 | [diff] [blame^] | 365 | context["inverse-bit-error-rate"] = strconv.FormatUint(uint64(onuSignalDegrade.InverseBitErrorRate), base10) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 366 | /* Populating device event body */ |
| 367 | de.Context = context |
| 368 | de.ResourceId = deviceID |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 369 | if onuSignalDegrade.Status == statusCheckOn { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 370 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuSignalDegradeEvent, "RAISE_EVENT") |
| 371 | } else { |
| 372 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuSignalDegradeEvent, "CLEAR_EVENT") |
| 373 | } |
| 374 | /* Send event to KAFKA */ |
| 375 | if err := em.eventProxy.SendDeviceEvent(&de, communication, pon, raisedTs); err != nil { |
| 376 | log.Errorw("Failed to send ONU signals degrade event", log.Fields{"onu-id": onuSignalDegrade.OnuId, "intf-id": onuSignalDegrade.IntfId}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 377 | return err |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 378 | } |
| 379 | log.Infow("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] | 380 | return nil |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 381 | } |
| 382 | |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 383 | func (em *OpenOltEventMgr) onuSignalsFailIndication(onuSignalsFail *oop.OnuSignalsFailureIndication, deviceID string, raisedTs int64) error { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 384 | var de voltha.DeviceEvent |
| 385 | context := make(map[string]string) |
| 386 | /* Populating event context */ |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 387 | context["onu-id"] = strconv.FormatUint(uint64(onuSignalsFail.OnuId), base10) |
| 388 | context["intf-id"] = strconv.FormatUint(uint64(onuSignalsFail.IntfId), base10) |
| 389 | context["inverse-bit-error-rate"] = strconv.FormatUint(uint64(onuSignalsFail.InverseBitErrorRate), base10) |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 390 | /* Populating device event body */ |
| 391 | de.Context = context |
| 392 | de.ResourceId = deviceID |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 393 | if onuSignalsFail.Status == statusCheckOn { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 394 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuSignalsFailEvent, "RAISE_EVENT") |
| 395 | } else { |
| 396 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuSignalsFailEvent, "CLEAR_EVENT") |
| 397 | } |
| 398 | /* Send event to KAFKA */ |
| 399 | if err := em.eventProxy.SendDeviceEvent(&de, communication, pon, raisedTs); err != nil { |
| 400 | log.Errorw("Failed to send ONU signals fail event", log.Fields{"onu-id": onuSignalsFail.OnuId, "intf-id": onuSignalsFail.IntfId}) |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 401 | return err |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 402 | } |
| 403 | log.Infow("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] | 404 | return nil |
| 405 | } |
| 406 | |
Naga Manjunath | f6f7464 | 2020-01-13 21:37:28 +0530 | [diff] [blame] | 407 | func (em *OpenOltEventMgr) onuStartupFailedIndication(onuStartupFail *oop.OnuStartupFailureIndication, deviceID string, raisedTs int64) error { |
| 408 | var de voltha.DeviceEvent |
| 409 | context := make(map[string]string) |
| 410 | /* Populating event context */ |
| 411 | context["onu-id"] = strconv.FormatUint(uint64(onuStartupFail.OnuId), base10) |
| 412 | context["intf-id"] = strconv.FormatUint(uint64(onuStartupFail.IntfId), base10) |
| 413 | |
| 414 | /* Populating device event body */ |
| 415 | de.Context = context |
| 416 | de.ResourceId = deviceID |
| 417 | if onuStartupFail.Status == statusCheckOn { |
| 418 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuStartupFailEvent, "RAISE_EVENT") |
| 419 | } else { |
| 420 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuStartupFailEvent, "CLEAR_EVENT") |
| 421 | } |
| 422 | /* Send event to KAFKA */ |
| 423 | if err := em.eventProxy.SendDeviceEvent(&de, communication, pon, raisedTs); err != nil { |
| 424 | log.Errorw("Failed to send ONU startup fail event", log.Fields{"onu-id": onuStartupFail.OnuId, "intf-id": onuStartupFail.IntfId}) |
| 425 | return err |
| 426 | } |
| 427 | log.Infow("ONU startup fail event sent to KAFKA", log.Fields{"onu-id": onuStartupFail.OnuId, "intf-id": onuStartupFail.IntfId}) |
| 428 | return nil |
| 429 | } |
| 430 | |
Naga Manjunath | 9546b91 | 2019-11-28 20:56:20 +0530 | [diff] [blame] | 431 | func (em *OpenOltEventMgr) onuLossOfSyncIndication(onuLOKI *oop.OnuLossOfKeySyncFailureIndication, deviceID string, raisedTs int64) error { |
| 432 | var de voltha.DeviceEvent |
| 433 | context := make(map[string]string) |
| 434 | /* Populating event context */ |
| 435 | context["onu-id"] = strconv.FormatUint(uint64(onuLOKI.OnuId), base10) |
| 436 | context["intf-id"] = strconv.FormatUint(uint64(onuLOKI.IntfId), base10) |
| 437 | /* Populating device event body */ |
| 438 | de.Context = context |
| 439 | de.ResourceId = deviceID |
| 440 | if onuLOKI.Status == statusCheckOn { |
| 441 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuLossOfKeySyncEvent, "RAISE_EVENT") |
| 442 | } else { |
| 443 | de.DeviceEventName = fmt.Sprintf("%s_%s", onuLossOfKeySyncEvent, "CLEAR_EVENT") |
| 444 | } |
| 445 | |
| 446 | /* Send event to KAFKA */ |
| 447 | if err := em.eventProxy.SendDeviceEvent(&de, security, onu, raisedTs); err != nil { |
| 448 | log.Errorw("Failed to send ONU loss of key sync event", log.Fields{"onu-id": onuLOKI.OnuId, "intf-id": onuLOKI.IntfId}) |
| 449 | return err |
| 450 | } |
| 451 | log.Infow("ONU loss of key sync event sent to KAFKA", log.Fields{"onu-id": onuLOKI.OnuId, "intf-id": onuLOKI.IntfId}) |
| 452 | return nil |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 453 | } |
kesavand | 39e0aa3 | 2020-01-28 20:58:50 -0500 | [diff] [blame] | 454 | |
| 455 | // oltIntfOperIndication handles Up and Down state of an OLT PON ports |
| 456 | func (em *OpenOltEventMgr) oltIntfOperIndication(ifindication *oop.IntfOperIndication, deviceID string, raisedTs int64) { |
| 457 | var de voltha.DeviceEvent |
| 458 | context := make(map[string]string) |
| 459 | portID := IntfIDToPortNo(ifindication.IntfId, voltha.Port_PON_OLT) |
| 460 | device, err := em.handler.coreProxy.GetDevice(ctx.Background(), deviceID, deviceID) |
| 461 | if err != nil { |
| 462 | log.Errorw("Error while fetching Device object", log.Fields{"DeviceId": deviceID}) |
| 463 | } |
| 464 | for _, port := range device.Ports { |
| 465 | if port.PortNo == portID { |
| 466 | // Events are suppressed if the Port Adminstate is not enabled. |
| 467 | if port.AdminState != common.AdminState_ENABLED { |
| 468 | log.Infow("Port disable/enable event not generated because, The port is not enabled by operator", log.Fields{"deviceId": deviceID, "port": port}) |
| 469 | return |
| 470 | } |
| 471 | break |
| 472 | } |
| 473 | } |
| 474 | /* Populating event context */ |
| 475 | context["oper-state"] = ifindication.GetOperState() |
| 476 | /* Populating device event body */ |
| 477 | de.Context = context |
| 478 | de.ResourceId = deviceID |
| 479 | |
| 480 | if ifindication.GetOperState() == operationStateDown { |
| 481 | de.DeviceEventName = fmt.Sprintf("%s_%s", ponIntfDownIndiction, "RAISE_EVENT") |
| 482 | } else if ifindication.OperState == operationStateUp { |
| 483 | de.DeviceEventName = fmt.Sprintf("%s_%s", ponIntfDownIndiction, "CLEAR_EVENT") |
| 484 | } |
| 485 | /* Send event to KAFKA */ |
| 486 | if err := em.eventProxy.SendDeviceEvent(&de, communication, olt, raisedTs); err != nil { |
| 487 | log.Errorw("failed-to-send-olt-intf-oper-status-event", log.Fields{"err": err}) |
| 488 | } |
| 489 | log.Info("sent-olt-intf-oper-status-event-to-kafka") |
| 490 | } |