blob: 84bd7b8395d6b0cca942f35439ec21f748ebe97a [file] [log] [blame]
William Kurkian6f436d02019-02-06 16:25:01 -05001#
2# Copyright 2018 the original author or authors.
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
17import arrow
William Kurkian44cd7bb2019-02-11 16:39:12 -050018from pyvoltha.adapters.extensions.alarms.adapter_alarms import AdapterAlarms
19from pyvoltha.adapters.extensions.alarms.simulator.simulate_alarms import AdapterAlarmSimulator
20from pyvoltha.adapters.extensions.alarms.olt.olt_los_alarm import OltLosAlarm
21from pyvoltha.adapters.extensions.alarms.onu.onu_dying_gasp_alarm import OnuDyingGaspAlarm
22from pyvoltha.adapters.extensions.alarms.onu.onu_los_alarm import OnuLosAlarm
23from pyvoltha.adapters.extensions.alarms.onu.onu_lopc_miss_alarm import OnuLopcMissAlarm
24from pyvoltha.adapters.extensions.alarms.onu.onu_lopc_mic_error_alarm import OnuLopcMicErrorAlarm
25from pyvoltha.adapters.extensions.alarms.onu.onu_lob_alarm import OnuLobAlarm
William Kurkian6f436d02019-02-06 16:25:01 -050026
William Kurkian44cd7bb2019-02-11 16:39:12 -050027from pyvoltha.adapters.extensions.alarms.onu.onu_startup_alarm import OnuStartupAlarm
28from pyvoltha.adapters.extensions.alarms.onu.onu_signal_degrade_alarm import OnuSignalDegradeAlarm
29from pyvoltha.adapters.extensions.alarms.onu.onu_signal_fail_alarm import OnuSignalFailAlarm
30from pyvoltha.adapters.extensions.alarms.onu.onu_window_drift_alarm import OnuWindowDriftAlarm
31from pyvoltha.adapters.extensions.alarms.onu.onu_activation_fail_alarm import OnuActivationFailAlarm
William Kurkian6f436d02019-02-06 16:25:01 -050032
William Kurkian8b1690c2019-03-04 16:53:22 -050033import voltha_protos.openolt_pb2 as openolt_pb2
34import voltha_protos.device_pb2 as device_pb2
William Kurkian6f436d02019-02-06 16:25:01 -050035
36
37class OpenOltAlarmMgr(object):
38 def __init__(self, log, adapter_agent, device_id, logical_device_id,
serkant.uluderyadcfc74d2019-03-17 23:41:42 -070039 platform, serial_number):
William Kurkian6f436d02019-02-06 16:25:01 -050040 """
41 20180711 - Addition of adapter_agent and device_id
42 to facilitate alarm processing and kafka posting
43 :param log:
44 :param adapter_agent:
45 :param device_id:
46 """
47 self.log = log
48 self.adapter_agent = adapter_agent
49 self.device_id = device_id
50 self.logical_device_id = logical_device_id
51 self.platform = platform
serkant.uluderyadcfc74d2019-03-17 23:41:42 -070052 self.serial_number = serial_number
William Kurkian6f436d02019-02-06 16:25:01 -050053 """
54 The following is added to reduce the continual posting of OLT LOS alarming
55 to Kafka. Set enable_alarm_suppress = true to enable otherwise the
56 current openolt bal will send continuous olt los alarm cleared messages
57 ONU disc raised counter is place holder for a future addition
58 """
59 self.enable_alarm_suppress = True
60 self.alarm_suppress = {"olt_los_clear": 0, "onu_disc_raised": []} # Keep count of alarms to limit.
61 try:
serkant.uluderyadcfc74d2019-03-17 23:41:42 -070062 self.alarms = AdapterAlarms(self.adapter_agent, self.device_id, self.logical_device_id, self.serial_number)
William Kurkian6f436d02019-02-06 16:25:01 -050063 self.simulator = AdapterAlarmSimulator(self.alarms)
64 except Exception as initerr:
65 self.log.exception("alarmhandler-init-error", errmsg=initerr.message)
66 raise Exception(initerr)
67
68 def process_alarms(self, alarm_ind):
69 try:
70 self.log.debug('alarm-indication', alarm=alarm_ind, device_id=self.device_id)
71 if alarm_ind.HasField('los_ind'):
72 self.los_indication(alarm_ind.los_ind)
73 elif alarm_ind.HasField('dying_gasp_ind'):
74 self.dying_gasp_indication(alarm_ind.dying_gasp_ind)
75 elif alarm_ind.HasField('onu_alarm_ind'):
76 self.onu_alarm_indication(alarm_ind.onu_alarm_ind)
77 elif alarm_ind.HasField('onu_startup_fail_ind'):
78 self.onu_startup_failure_indication(
79 alarm_ind.onu_startup_fail_ind)
80 elif alarm_ind.HasField('onu_signal_degrade_ind'):
81 self.onu_signal_degrade_indication(
82 alarm_ind.onu_signal_degrade_ind)
83 elif alarm_ind.HasField('onu_drift_of_window_ind'):
84 self.onu_drift_of_window_indication(
85 alarm_ind.onu_drift_of_window_ind)
86 elif alarm_ind.HasField('onu_loss_omci_ind'):
87 self.onu_loss_omci_indication(alarm_ind.onu_loss_omci_ind)
88 elif alarm_ind.HasField('onu_signals_fail_ind'):
89 self.onu_signals_failure_indication(
90 alarm_ind.onu_signals_fail_ind)
91 elif alarm_ind.HasField('onu_tiwi_ind'):
92 self.onu_transmission_interference_warning(
93 alarm_ind.onu_tiwi_ind)
94 elif alarm_ind.HasField('onu_activation_fail_ind'):
95 self.onu_activation_failure_indication(
96 alarm_ind.onu_activation_fail_ind)
97 elif alarm_ind.HasField('onu_processing_error_ind'):
98 self.onu_processing_error_indication(
99 alarm_ind.onu_processing_error_ind)
100 else:
101 self.log.warn('unknown alarm type', alarm=alarm_ind)
102
103 except Exception as e:
104 self.log.error('sorting of alarm went wrong', error=e,
105 alarm=alarm_ind)
106
107 def simulate_alarm(self, alarm):
108 self.simulator.simulate_alarm(alarm)
109
110 def los_indication(self, los_ind):
111
112 try:
113 self.log.debug('los indication received', los_ind=los_ind,
114 int_id=los_ind.intf_id, status=los_ind.status)
115 try:
116 port_type_name = self.platform.intf_id_to_port_type_name(los_ind.intf_id)
117 if los_ind.status == 1 or los_ind.status == "on":
118 # Zero out the suppression counter on OLT_LOS raise
119 self.alarm_suppress['olt_los_clear'] = 0
120 OltLosAlarm(self.alarms, intf_id=los_ind.intf_id, port_type_name=port_type_name).raise_alarm()
121 else:
122 """
123 Check if there has been more that one los clear following a previous los
124 """
125 if self.alarm_suppress['olt_los_clear'] == 0 and self.enable_alarm_suppress:
126 OltLosAlarm(self.alarms, intf_id=los_ind.intf_id, port_type_name=port_type_name).clear_alarm()
127 self.alarm_suppress['olt_los_clear'] += 1
128
129 except Exception as alarm_err:
130 self.log.error('los-indication', errmsg=alarm_err.message)
131 except Exception as e:
132 self.log.error('los-indication', errmsg=e.message)
133
134 def dying_gasp_indication(self, dying_gasp_ind):
135 try:
136 alarm_dgi = dying_gasp_ind
137 onu_id = alarm_dgi.onu_id
138 self.log.debug('openolt-alarmindication-dispatch-dying-gasp', int_id=alarm_dgi.intf_id,
139 onu_id=alarm_dgi.onu_id, status=alarm_dgi.status)
140 try:
141 """
142 Get the specific onu device information for the onu generating the alarm.
serkant.uluderyadcfc74d2019-03-17 23:41:42 -0700143 Extract the id.
William Kurkian6f436d02019-02-06 16:25:01 -0500144 """
145 onu_device_id = "unresolved"
146 onu_serial_number = "unresolved"
147 onu_device = self.resolve_onu_id(onu_id, port_intf_id=alarm_dgi.intf_id)
148 if onu_device != None:
149 onu_device_id = onu_device.id
150 onu_serial_number = onu_device.serial_number
151
152 if dying_gasp_ind.status == 1 or dying_gasp_ind.status == "on":
153 OnuDyingGaspAlarm(self.alarms, dying_gasp_ind.intf_id,
serkant.uluderyadcfc74d2019-03-17 23:41:42 -0700154 onu_device_id, serial_number=onu_serial_number).raise_alarm()
William Kurkian6f436d02019-02-06 16:25:01 -0500155 else:
156 OnuDyingGaspAlarm(self.alarms, dying_gasp_ind.intf_id,
serkant.uluderyadcfc74d2019-03-17 23:41:42 -0700157 onu_device_id, serial_number=onu_serial_number).clear_alarm()
William Kurkian6f436d02019-02-06 16:25:01 -0500158 except Exception as alarm_err:
159 self.log.exception('dying-gasp-indication', errmsg=alarm_err.message)
160
161 except Exception as e:
162 self.log.error('dying_gasp_indication', error=e)
163
164 def onu_alarm_indication(self, onu_alarm_ind):
165 """
166 LOB = Los of burst
167 LOPC = Loss of PLOAM miss channel
168
169 :param onu_alarm_ind: Alarm indication which currently contains
170 onu_id:
171 los_status:
172 lob_status:
173 lopc_miss_status:
174 lopc_mic_error_status:
175 :return:
176 """
177 self.log.info('onu-alarm-indication')
178
179 try:
180 self.log.debug('onu alarm indication received', los_status=onu_alarm_ind.los_status,
181 onu_intf_id=onu_alarm_ind.onu_id,
182 lob_status=onu_alarm_ind.lob_status,
183 lopc_miss_status=onu_alarm_ind.lopc_miss_status,
184 lopc_mic_error_status=onu_alarm_ind.lopc_mic_error_status,
185 intf_id=onu_alarm_ind.intf_id
186 )
187
188 try:
189 """
190 Get the specific onu device information for the onu generating the alarm.
serkant.uluderyadcfc74d2019-03-17 23:41:42 -0700191 Extract the id.
William Kurkian6f436d02019-02-06 16:25:01 -0500192 """
193 onu_device_id = "unresolved"
194 serial_number = "unresolved"
195 onu_device = self.resolve_onu_id(onu_alarm_ind.onu_id, port_intf_id=onu_alarm_ind.intf_id)
196 if onu_device != None:
197 onu_device_id = onu_device.id
198 serial_number = onu_device.serial_number
199
200 if onu_alarm_ind.los_status == 1 or onu_alarm_ind.los_status == "on":
serkant.uluderyadcfc74d2019-03-17 23:41:42 -0700201 OnuLosAlarm(self.alarms, onu_id=onu_device_id, intf_id=onu_alarm_ind.intf_id, serial_number=serial_number).raise_alarm()
William Kurkian6f436d02019-02-06 16:25:01 -0500202 elif onu_alarm_ind.los_status == 0 or onu_alarm_ind.los_status == "off":
serkant.uluderyadcfc74d2019-03-17 23:41:42 -0700203 OnuLosAlarm(self.alarms, onu_id=onu_device_id, intf_id=onu_alarm_ind.intf_id, serial_number=serial_number).clear_alarm()
William Kurkian6f436d02019-02-06 16:25:01 -0500204 else: # No Change
205 pass
206
207 if onu_alarm_ind.lopc_miss_status == 1 or onu_alarm_ind.lopc_miss_status == "on":
serkant.uluderyadcfc74d2019-03-17 23:41:42 -0700208 OnuLopcMissAlarm(self.alarms, onu_id=onu_device_id, intf_id=onu_alarm_ind.intf_id, serial_number=serial_number).raise_alarm()
William Kurkian6f436d02019-02-06 16:25:01 -0500209 elif (onu_alarm_ind.lopc_miss_status == 0 or onu_alarm_ind.lopc_miss_status == "off"):
serkant.uluderyadcfc74d2019-03-17 23:41:42 -0700210 OnuLopcMissAlarm(self.alarms, onu_id=onu_device_id, intf_id=onu_alarm_ind.intf_id, serial_number=serial_number).clear_alarm()
William Kurkian6f436d02019-02-06 16:25:01 -0500211 else: # No Change
212 pass
213
214 if onu_alarm_ind.lopc_mic_error_status == 1 or onu_alarm_ind.lopc_mic_error_status == "on":
serkant.uluderyadcfc74d2019-03-17 23:41:42 -0700215 OnuLopcMicErrorAlarm(self.alarms, onu_id=onu_device_id, intf_id=onu_alarm_ind.intf_id, serial_number=serial_number).raise_alarm()
William Kurkian6f436d02019-02-06 16:25:01 -0500216 elif onu_alarm_ind.lopc_mic_error_status == 0 or onu_alarm_ind.lopc_mic_error_status == "off":
serkant.uluderyadcfc74d2019-03-17 23:41:42 -0700217 OnuLopcMicErrorAlarm(self.alarms, onu_id=onu_device_id, intf_id=onu_alarm_ind.intf_id, serial_number=serial_number).clear_alarm()
William Kurkian6f436d02019-02-06 16:25:01 -0500218 else: # No Change
219 pass
220
221 if onu_alarm_ind.lob_status == 1 or onu_alarm_ind.lob_status == "on":
serkant.uluderyadcfc74d2019-03-17 23:41:42 -0700222 OnuLobAlarm(self.alarms, onu_id=onu_device_id, intf_id=onu_alarm_ind.intf_id, serial_number=serial_number).raise_alarm()
William Kurkian6f436d02019-02-06 16:25:01 -0500223 elif onu_alarm_ind.lob_status == 0 or onu_alarm_ind.lob_status == "off":
serkant.uluderyadcfc74d2019-03-17 23:41:42 -0700224 OnuLobAlarm(self.alarms, onu_id=onu_device_id, intf_id=onu_alarm_ind.intf_id, serial_number=serial_number).clear_alarm()
William Kurkian6f436d02019-02-06 16:25:01 -0500225 else: # No Change
226 pass
227 except Exception as alarm_err:
228 self.log.exception('onu-alarm-indication', errmsg=alarm_err.message)
229
230 except Exception as e:
231 self.log.exception('onu-alarm-indication', errmsg=e.message)
232
233 def onu_startup_failure_indication(self, onu_startup_fail_ind):
234 """
235 Current protobuf indicator:
236 message OnuStartupFailureIndication {
237 fixed32 intf_id = 1;
238 fixed32 onu_id = 2;
239 string status = 3;
240 }
241
242 :param onu_startup_fail_ind:
243 :return:
244 """
245 try:
246 ind = onu_startup_fail_ind
247 label = "onu-startup-failure-indication"
248 self.log.debug(label + " received", onu_startup_fail_ind=ind, int_id=ind.intf_id, onu_id=ind.onu_id, status=ind.status)
249 try:
serkant.uluderyadcfc74d2019-03-17 23:41:42 -0700250 """
251 Get the specific onu device information for the onu generating the alarm.
252 """
253 serial_number = "unresolved"
254 onu_device = self.resolve_onu_id(ind.onu_id, port_intf_id=ind.intf_id)
255 if onu_device != None:
256 serial_number = onu_device.serial_number
257
William Kurkian6f436d02019-02-06 16:25:01 -0500258 if ind.status == 1 or ind.status == "on":
serkant.uluderyadcfc74d2019-03-17 23:41:42 -0700259 OnuStartupAlarm(self.alarms, intf_id=ind.intf_id,onu_id=ind.onu_id, serial_number=serial_number).raise_alarm()
William Kurkian6f436d02019-02-06 16:25:01 -0500260 else:
serkant.uluderyadcfc74d2019-03-17 23:41:42 -0700261 OnuStartupAlarm(self.alarms, intf_id=ind.intf_id, onu_id=ind.onu_id, serial_number=serial_number).clear_alarm()
William Kurkian6f436d02019-02-06 16:25:01 -0500262 except Exception as alarm_err:
263 self.log.exception(label, errmsg=alarm_err.message)
264
265 except Exception as e:
266 self.log.exception(label, errmsg=e.message)
267
268 def onu_signal_degrade_indication(self, onu_signal_degrade_ind):
269 """
270 Current protobuf indicator:
271 OnuSignalDegradeIndication {
272 fixed32 intf_id = 1;
273 fixed32 onu_id = 2;
274 string status = 3;
275 fixed32 inverse_bit_error_rate = 4;
276 }
277 :param onu_signal_degrade_ind:
278 :return:
279 """
280 try:
281 ind = onu_signal_degrade_ind
282 label = "onu-signal-degrade-indication"
283 self.log.debug(label + ' received',
284 onu_startup_fail_ind=ind,
285 int_id=ind.intf_id,
286 onu_id=ind.onu_id,
287 inverse_bit_error_rate=ind.inverse_bit_error_rate,
288 status=ind.status)
289 try:
serkant.uluderyadcfc74d2019-03-17 23:41:42 -0700290 """
291 Get the specific onu device information for the onu generating the alarm.
292 Extract the id. In the future extract the serial number as well
293 """
294 serial_number = "unresolved"
295 onu_device = self.resolve_onu_id(ind.onu_id, port_intf_id=ind.intf_id)
296 if onu_device != None:
297 serial_number = onu_device.serial_number
298
William Kurkian6f436d02019-02-06 16:25:01 -0500299 if ind.status == 1 or ind.status == "on":
300 OnuSignalDegradeAlarm(self.alarms, intf_id=ind.intf_id, onu_id=ind.onu_id,
serkant.uluderyadcfc74d2019-03-17 23:41:42 -0700301 inverse_bit_error_rate=ind.inverse_bit_error_rate, serial_number=serial_number).raise_alarm()
William Kurkian6f436d02019-02-06 16:25:01 -0500302 else:
303 OnuSignalDegradeAlarm(self.alarms, intf_id=ind.intf_id, onu_id=ind.onu_id,
serkant.uluderyadcfc74d2019-03-17 23:41:42 -0700304 inverse_bit_error_rate=ind.inverse_bit_error_rate, serial_number=serial_number).clear_alarm()
William Kurkian6f436d02019-02-06 16:25:01 -0500305 except Exception as alarm_err:
306 self.log.exception(label, errmsg=alarm_err.message)
307
308 except Exception as e:
309 self.log.exception(label, errmsg=e.message)
310
311 def onu_drift_of_window_indication(self, onu_drift_of_window_ind):
312 """
313 Current protobuf indicator:
314 OnuDriftOfWindowIndication {
315 fixed32 intf_id = 1;
316 fixed32 onu_id = 2;
317 string status = 3;
318 fixed32 drift = 4;
319 fixed32 new_eqd = 5;
320 }
321
322 :param onu_drift_of_window_ind:
323 :return:
324 """
325 try:
326 ind = onu_drift_of_window_ind
327 label = "onu-window-drift-indication"
328
329 onu_device_id, onu_serial_number = self.resolve_onudev_id_onudev_serialnum(
330 self.resolve_onu_id(ind.onu_id, port_intf_id=ind.intf_id))
331
332 self.log.debug(label + ' received',
333 onu_drift_of_window_ind=ind,
334 int_id=ind.intf_id,
335 onu_id=ind.onu_id,
336 onu_device_id=onu_device_id,
337 drift=ind.drift,
338 new_eqd=ind.new_eqd,
339 status=ind.status)
340 try:
341 if ind.status == 1 or ind.status == "on":
342 OnuWindowDriftAlarm(self.alarms, intf_id=ind.intf_id,
343 onu_id=onu_device_id,
344 drift=ind.drift,
serkant.uluderyadcfc74d2019-03-17 23:41:42 -0700345 new_eqd=ind.new_eqd,
346 serial_number=onu_serial_number).raise_alarm()
William Kurkian6f436d02019-02-06 16:25:01 -0500347 else:
348 OnuWindowDriftAlarm(self.alarms, intf_id=ind.intf_id,
349 onu_id=onu_device_id,
350 drift=ind.drift,
serkant.uluderyadcfc74d2019-03-17 23:41:42 -0700351 new_eqd=ind.new_eqd,
352 serial_number=onu_serial_number).clear_alarm()
William Kurkian6f436d02019-02-06 16:25:01 -0500353 except Exception as alarm_err:
354 self.log.exception(label, errmsg=alarm_err.message)
355
356 except Exception as e:
357 self.log.exception(label, errmsg=e.message)
358
359 def onu_loss_omci_indication(self, onu_loss_omci_ind):
360 self.log.info('not implemented yet')
361
362 def onu_signals_failure_indication(self, onu_signals_fail_ind):
363 """
364 Current protobuf indicator:
365 OnuSignalsFailureIndication {
366 fixed32 intf_id = 1;
367 fixed32 onu_id = 2;
368 string status = 3;
369 fixed32 inverse_bit_error_rate = 4;
370 }
371
372 :param onu_signals_fail_ind:
373 :return:
374 """
375 try:
376 ind = onu_signals_fail_ind
377 label = "onu-signal-failure-indication"
378
379 onu_device_id, onu_serial_number = self.resolve_onudev_id_onudev_serialnum(
380 self.resolve_onu_id(ind.onu_id, port_intf_id=ind.intf_id))
381
382 self.log.debug(label + ' received',
383 onu_startup_fail_ind=ind,
384 int_id=ind.intf_id,
385 onu_id=ind.onu_id,
386 onu_device_id=onu_device_id,
387 onu_serial_number=onu_serial_number,
388 inverse_bit_error_rate=ind.inverse_bit_error_rate,
389 status=ind.status)
390 try:
391 if ind.status == 1 or ind.status == "on":
392 OnuSignalFailAlarm(self.alarms, intf_id=ind.intf_id,
393 onu_id=onu_device_id,
serkant.uluderyadcfc74d2019-03-17 23:41:42 -0700394 inverse_bit_error_rate=ind.inverse_bit_error_rate,
395 serial_number=onu_serial_number).raise_alarm()
William Kurkian6f436d02019-02-06 16:25:01 -0500396 else:
397 OnuSignalFailAlarm(self.alarms, intf_id=ind.intf_id,
398 onu_id=onu_device_id,
serkant.uluderyadcfc74d2019-03-17 23:41:42 -0700399 inverse_bit_error_rate=ind.inverse_bit_error_rate,
400 serial_number=onu_serial_number).clear_alarm()
William Kurkian6f436d02019-02-06 16:25:01 -0500401 except Exception as alarm_err:
402 self.log.exception(label, errmsg=alarm_err.message)
403
404 except Exception as e:
405 self.log.exception(label, errmsg=e.message)
406
407
408 def onu_transmission_interference_warning(self, onu_tiwi_ind):
409 self.log.info('not implemented yet')
410
411 def onu_activation_failure_indication(self, onu_activation_fail_ind):
412 """
413
414 No status is currently passed with this alarm. Consequently it will always just raise
415 :param onu_activation_fail_ind:
416 :return:
417 """
418 try:
419 ind = onu_activation_fail_ind
420 label = "onu-activation-failure-indication"
421
422 onu_device_id, onu_serial_number = self.resolve_onudev_id_onudev_serialnum(
423 self.resolve_onu_id(ind.onu_id, port_intf_id=ind.intf_id))
424
425 self.log.debug(label + ' received',
426 onu_startup_fail_ind=ind,
427 int_id=ind.intf_id,
428 onu_id=ind.onu_id,
429 onu_device_id=onu_device_id,
430 onu_serial_number=onu_serial_number)
431 try:
432
433 OnuActivationFailAlarm(self.alarms, intf_id=ind.intf_id,
serkant.uluderyadcfc74d2019-03-17 23:41:42 -0700434 onu_id=onu_device_id, serial_number=onu_serial_number).raise_alarm()
William Kurkian6f436d02019-02-06 16:25:01 -0500435 except Exception as alarm_err:
436 self.log.exception(label, errmsg=alarm_err.message)
437
438 except Exception as e:
439 self.log.exception(label, errmsg=e.message)
440
441 def onu_processing_error_indication(self, onu_processing_error_ind):
442 self.log.info('not implemented yet')
443
444 """
445 Helper Methods
446 """
447
448 def resolve_onudev_id_onudev_serialnum(self,onu_device):
449 """
450 Convenience wrapper to resolve device_id and serial number
451 :param onu_device:
452 :return: tuple: onu_device_id, onu_serial_number
453 """
454 try:
455 onu_device_id = "unresolved"
456 onu_serial_number = "unresolved"
457 if onu_device != None:
458 onu_device_id = onu_device.id
459 onu_serial_number = onu_device.serial_number
460 except Exception as err:
461 self.log.exception("openolt-alarms-resolve-onudev-id ", errmsg=err.message)
462 raise Exception(err)
463 return onu_device_id, onu_serial_number
464
465 def resolve_onu_id(self, onu_id, port_intf_id):
466 """
467 Resolve the onu_device from the intf_id value and port. Uses the adapter agent to
468 resolve this..
469
470 Returns None if not found. Caller will have to test for None and act accordingly.
471 :param onu_id:
472 :param port_intf_id:
473 :return:
474 """
475
476 try:
477 onu_device = None
478 onu_device = self.adapter_agent.get_child_device(
479 self.device_id,
480 parent_port_no=self.platform.intf_id_to_port_no(
481 port_intf_id, device_pb2.Port.PON_OLT),
482 onu_id=onu_id)
William Kurkian6f436d02019-02-06 16:25:01 -0500483 except Exception as inner:
484 self.log.exception('resolve-onu-id', errmsg=inner.message)
485
486 return onu_device
487