VOL-1125 , VOL-893
Modified openolt_alarms to reference the voltha/extension/alarms templates/classes
Added intf_id to OltLosAlarm initialized and context setting
Added object_type= to the initializers of the alarms classes for clarification.
- added changes per reviews. Removed onu_id from OltLosAlarm class.
- added port_type_name to OltLosAlarm class in extensions
- added methods to resolve port type naming in openolt_platform.py
- added corresponding changes to openolt_alarms.py
- corrected reference from VOL-899 to VOL-893
- Pushed again since Jenkins did not run on the previous correction
for changing vol-899 to vol-893
- Corrected intf_id reference in openold_alarms where the indicator and not
indicator.inf_d was being passed to the alarm. (this shoiuld also
force Jenkins to verify properly)
Change-Id: I15ddcd8e58805b3190ccd9bf8704a55972224757
diff --git a/voltha/adapters/openolt/openolt_alarms.py b/voltha/adapters/openolt/openolt_alarms.py
index 74f34c3..1a33ae3 100644
--- a/voltha/adapters/openolt/openolt_alarms.py
+++ b/voltha/adapters/openolt/openolt_alarms.py
@@ -15,13 +15,18 @@
#
import arrow
-from voltha.protos.events_pb2 import AlarmEventType, \
- AlarmEventSeverity, AlarmEventState, AlarmEventCategory
import voltha.adapters.openolt.openolt_platform as platform
-from voltha.protos.device_pb2 import Port
-from voltha.adapters.openolt.alarms.adapter_alarms import AdapterAlarms
-from voltha.adapters.openolt.alarms.olt_los_alarm import OltLosAlarm
-from voltha.adapters.openolt.alarms.onu_dying_gasp_alarm import OnuDyingGaspAlarm
+# from voltha.protos.device_pb2 import Port
+from voltha.extensions.alarms.adapter_alarms import AdapterAlarms
+from voltha.extensions.alarms.olt.olt_los_alarm import OltLosAlarm
+from voltha.extensions.alarms.onu.onu_dying_gasp_alarm import OnuDyingGaspAlarm
+from voltha.extensions.alarms.onu.onu_los_alarm import OnuLosAlarm
+from voltha.extensions.alarms.onu.onu_lopc_miss_alarm import OnuLopcMissAlarm
+from voltha.extensions.alarms.onu.onu_lopc_mic_error_alarm import OnuLopcMicErrorAlarm
+from voltha.extensions.alarms.onu.onu_lob_alarm import OnuLobAlarm
+
+import protos.openolt_pb2 as openolt_pb2
+import voltha.protos.device_pb2 as device_pb2
class OpenOltAlarmMgr(object):
@@ -76,7 +81,7 @@
self.onu_processing_error_indication(
alarm_ind.onu_processing_error_ind)
else:
- self.log.warn('unknow alarm type', alarm=alarm_ind)
+ self.log.warn('unknown alarm type', alarm=alarm_ind)
except Exception as e:
self.log.error('sorting of alarm went wrong', error=e,
@@ -87,16 +92,14 @@
try:
self.log.debug('los indication received', los_ind=los_ind,
int_id=los_ind.intf_id, status=los_ind.status)
-
try:
-
- if (los_ind.status == 1 or los_ind.status == "on"):
- OltLosAlarm(self.alarms, alarm_indication=los_ind).raise_alarm()
+ port_type_name = platform.intf_id_to_port_type_name(los_ind.intf_id)
+ if los_ind.status == 1 or los_ind.status == "on":
+ OltLosAlarm(self.alarms, intf_id=los_ind.intf_id, port_type_name=port_type_name).raise_alarm()
else:
- OltLosAlarm(self.alarms, alarm_indication=los_ind).clear_alarm()
+ OltLosAlarm(self.alarms, intf_id=los_ind.intf_id, port_type_name=port_type_name).clear_alarm()
except Exception as alarm_err:
self.log.error('los-indication', errmsg=alarm_err.message)
-
except Exception as e:
self.log.error('los-indication', errmsg=e.message)
@@ -108,24 +111,22 @@
onu_id=alarm_dgi.onu_id, status=alarm_dgi.status)
try:
"""
- Get the ONU ID. This isw necessary since the dirvers are
- not passing the id. They are using a placeholder
+ Get the specific onu device information for the onu generating the alarm.
+ Extract the id. In the future extract the serial number as well
"""
- onu_device_id = "place_holder"
- try:
- ind_onu_id = dying_gasp_ind.onu_id
- onu_device = self.adapter_agent.get_child_device(
- self.device_id,
- parent_port_no=platform.intf_id_to_port_no(
- dying_gasp_ind.intf_id, Port.PON_OLT),
- onu_id=dying_gasp_ind.onu_id)
+ onu_device_id = "unresolved"
+ onu_serial_number = "unresolved"
+ onu_device = self.resolve_onu_id(onu_id, port_intf_id=alarm_dgi.intf_id)
+ if onu_device != None:
onu_device_id = onu_device.id
- except Exception as inner:
- self.log.exception('dying-gasp-indication-resolve_onu-id', errmsg=inner.message)
- if (dying_gasp_ind.status == 1 or dying_gasp_ind.status == "on"):
- OnuDyingGaspAlarm(self.alarms, dying_gasp_ind, onu_device_id).raise_alarm()
+ onu_serial_number = onu_device.serial_number
+
+ if dying_gasp_ind.status == 1 or dying_gasp_ind.status == "on":
+ OnuDyingGaspAlarm(self.alarms, dying_gasp_ind.intf_id,
+ onu_device_id).raise_alarm()
else:
- OnuDyingGaspAlarm(self.alarms, dying_gasp_ind, onu_device_id).clear_alarm()
+ OnuDyingGaspAlarm(self.alarms, dying_gasp_ind.intf_id,
+ onu_device_id).clear_alarm()
except Exception as alarm_err:
self.log.exception('dying-gasp-indication', errmsg=alarm_err.message)
@@ -133,7 +134,75 @@
self.log.error('dying_gasp_indication', error=e)
def onu_alarm_indication(self, onu_alarm_ind):
- self.log.info('not implemented yet')
+ """
+ LOB = Los of burst
+ LOPC = Loss of PLOAM miss channel
+
+ :param onu_alarm_ind: Alarm indication which currently contains
+ onu_id:
+ los_status:
+ lob_status:
+ lopc_miss_status:
+ lopc_mic_error_status:
+ :return:
+ """
+ self.log.info('onu-alarm-indication')
+
+ try:
+ self.log.debug('onu alarm indication received', los_status=onu_alarm_ind.los_status,
+ onu_intf_id=onu_alarm_ind.onu_id,
+ lob_status=onu_alarm_ind.lob_status,
+ lopc_miss_status=onu_alarm_ind.lopc_miss_status,
+ lopc_mic_error_status=onu_alarm_ind.lopc_mic_error_status,
+ intf_id=onu_alarm_ind.intf_id
+ )
+
+ try:
+ """
+ Get the specific onu device information for the onu generating the alarm.
+ Extract the id. In the future extract the serial number as well
+ """
+ onu_device_id = "unresolved"
+ serial_number = "unresolved"
+ onu_device = self.resolve_onu_id(onu_alarm_ind.onu_id, port_intf_id=onu_alarm_ind.intf_id)
+ if onu_device != None:
+ onu_device_id = onu_device.id
+ serial_number = onu_device.serial_number
+
+ if onu_alarm_ind.los_status == 1 or onu_alarm_ind.los_status == "on":
+ OnuLosAlarm(self.alarms, onu_id=onu_device_id, intf_id=onu_alarm_ind.intf_id).raise_alarm()
+ # remove the discovered flag
+ self.alarm_suppress['onu_disc_raised'].remove(serial_number)
+ elif onu_alarm_ind.los_status == 0 or onu_alarm_ind.los_status == "off":
+ OnuLosAlarm(self.alarms, onu_id=onu_device_id, intf_id=onu_alarm_ind.intf_id).clear_alarm()
+ else: # No Change
+ pass
+
+ if onu_alarm_ind.lopc_miss_status == 1 or onu_alarm_ind.lopc_miss_status == "on":
+ OnuLopcMissAlarm(self.alarms, onu_id=onu_device_id, intf_id=onu_alarm_ind.intf_id).raise_alarm()
+ elif (onu_alarm_ind.lopc_miss_status == 0 or onu_alarm_ind.lopc_miss_status == "off"):
+ OnuLopcMissAlarm(self.alarms, onu_id=onu_device_id, intf_id=onu_alarm_ind.intf_id).clear_alarm()
+ else: # No Change
+ pass
+
+ if onu_alarm_ind.lopc_mic_error_status == 1 or onu_alarm_ind.lopc_mic_error_status == "on":
+ OnuLopcMicErrorAlarm(self.alarms, onu_id=onu_device_id, intf_id=onu_alarm_ind.intf_id).raise_alarm()
+ elif onu_alarm_ind.lopc_mic_error_status == 0 or onu_alarm_ind.lopc_mic_error_status == "off":
+ OnuLopcMicErrorAlarm(self.alarms, onu_id=onu_device_id, intf_id=onu_alarm_ind.intf_id).clear_alarm()
+ else: # No Change
+ pass
+
+ if onu_alarm_ind.lob_status == 1 or onu_alarm_ind.lob_status == "on":
+ OnuLobAlarm(self.alarms, onu_id=onu_device_id, intf_id=onu_alarm_ind.intf_id).raise_alarm()
+ elif onu_alarm_ind.lob_status == 0 or onu_alarm_ind.lob_status == "off":
+ OnuLobAlarm(self.alarms, onu_id=onu_device_id, intf_id=onu_alarm_ind.intf_id).clear_alarm()
+ else: # No Change
+ pass
+ except Exception as alarm_err:
+ self.log.error('onu-alarm-indication', errmsg=alarm_err.message)
+
+ except Exception as e:
+ self.log.error('onu-alarm-indication', errmsg=e.message)
def onu_startup_failure_indication(self, onu_startup_fail_ind):
self.log.info('not implemented yet')
@@ -158,3 +227,29 @@
def onu_processing_error_indication(self, onu_processing_error_ind):
self.log.info('not implemented yet')
+
+ def resolve_onu_id(self, onu_id, port_intf_id):
+ """
+ Resolve the onu_device from the intf_id value and port. Uses the adapter agent to
+ resolve this..
+
+ Returns None if not found. Caller will have to test for None and act accordingly.
+ :param onu_id:
+ :param port_intf_id:
+ :return:
+ """
+
+ try:
+ onu_device = None
+ onu_device = self.adapter_agent.get_child_device(
+ self.device_id,
+ parent_port_no=platform.intf_id_to_port_no(
+ port_intf_id, device_pb2.Port.PON_OLT),
+ onu_id=onu_id)
+ onu_device_id = onu_device.id
+ except Exception as inner:
+ self.log.exception('resolve-onu-id', errmsg=inner.message)
+
+ return onu_device
+
+
diff --git a/voltha/adapters/openolt/openolt_platform.py b/voltha/adapters/openolt/openolt_platform.py
index d1d7c92..fc5756e 100644
--- a/voltha/adapters/openolt/openolt_platform.py
+++ b/voltha/adapters/openolt/openolt_platform.py
@@ -15,6 +15,7 @@
#
from voltha.protos.device_pb2 import Port
+import voltha.protos.device_pb2 as dev_pb2
"""
Encoding of identifiers
@@ -139,3 +140,25 @@
def intf_id_from_nni_port_num(port_num):
return port_num - 128
+
+def intf_id_to_intf_type(intf_id):
+
+ if (2 << 28 ^ intf_id) < 16:
+ return Port.PON_OLT
+ elif 128 <= intf_id <= 132:
+ return Port.ETHERNET_NNI
+ else:
+ raise Exception('Invalid intf_id value')
+
+def intf_id_to_port_type_name(intf_id):
+ try:
+ return port_type_name_by_port_index(intf_id_to_intf_type(intf_id))
+ except Exception as err:
+ raise Exception(err)
+
+def port_type_name_by_port_index(port_index):
+ try:
+ return dev_pb2._PORT_PORTTYPE.values_by_number[port_index].name
+ except Exception as err:
+ raise Exception(err)
+
diff --git a/voltha/extensions/alarms/olt/olt_los_alarm.py b/voltha/extensions/alarms/olt/olt_los_alarm.py
index 26ec50e..f6a1482 100644
--- a/voltha/extensions/alarms/olt/olt_los_alarm.py
+++ b/voltha/extensions/alarms/olt/olt_los_alarm.py
@@ -17,17 +17,16 @@
class OltLosAlarm(AlarmBase):
- def __init__(self, alarm_mgr, onu_id, intf_id):
- super(OltLosAlarm, self).__init__(alarm_mgr, 'olt LOS',
+ def __init__(self, alarm_mgr, intf_id, port_type_name):
+ super(OltLosAlarm, self).__init__(alarm_mgr, object_type='olt LOS',
alarm='LOS',
alarm_category=AlarmEventCategory.OLT,
alarm_type=AlarmEventType.COMMUNICATION,
alarm_severity=AlarmEventSeverity.MAJOR)
+ # Added port type to indicate if alarm was on NNI or PON
self._intf_id = intf_id
- self._onu_id = onu_id
+ self._port_type_name = port_type_name
def get_context_data(self):
- return {
- 'onu-id': self._onu_id,
- 'olt-intf-id:': self._intf_id
- }
+ return {'olt-intf-id:': self._intf_id,
+ 'olt-port-type-name': self._port_type_name}
diff --git a/voltha/extensions/alarms/onu/onu_active_alarm.py b/voltha/extensions/alarms/onu/onu_active_alarm.py
index fe0b554..a139875 100644
--- a/voltha/extensions/alarms/onu/onu_active_alarm.py
+++ b/voltha/extensions/alarms/onu/onu_active_alarm.py
@@ -19,7 +19,7 @@
class OnuActiveAlarm(AlarmBase):
def __init__(self, alarm_mgr, device_id, pon_id, onu_serial_number,
reg_id, olt_serial_number, ipv4_address=None):
- super(OnuActiveAlarm, self).__init__(alarm_mgr, 'ONU',
+ super(OnuActiveAlarm, self).__init__(alarm_mgr, object_type='ONU',
alarm='ONU_ACTIVATED',
alarm_category=AlarmEventCategory.PON,
resource_id=pon_id,
diff --git a/voltha/extensions/alarms/onu/onu_discovery_alarm.py b/voltha/extensions/alarms/onu/onu_discovery_alarm.py
index 24211ef..126cc00 100644
--- a/voltha/extensions/alarms/onu/onu_discovery_alarm.py
+++ b/voltha/extensions/alarms/onu/onu_discovery_alarm.py
@@ -17,7 +17,7 @@
class OnuDiscoveryAlarm(AlarmBase):
def __init__(self, alarm_mgr, pon_id, serial_number):
- super(OnuDiscoveryAlarm, self).__init__(alarm_mgr, 'ONU Discovery',
+ super(OnuDiscoveryAlarm, self).__init__(alarm_mgr, object_type='ONU Discovery',
alarm='Discovery',
alarm_category=AlarmEventCategory.PON,
resource_id=pon_id,
diff --git a/voltha/extensions/alarms/onu/onu_dying_gasp_alarm.py b/voltha/extensions/alarms/onu/onu_dying_gasp_alarm.py
index e92755c..72c6cb0 100644
--- a/voltha/extensions/alarms/onu/onu_dying_gasp_alarm.py
+++ b/voltha/extensions/alarms/onu/onu_dying_gasp_alarm.py
@@ -18,11 +18,11 @@
class OnuDyingGaspAlarm(AlarmBase):
def __init__(self, alarm_mgr, onu_id, intf_id):
- super(OnuDyingGaspAlarm, self).__init__(alarm_mgr, 'onu DYING_GASP',
+ super(OnuDyingGaspAlarm, self).__init__(alarm_mgr, object_type='onu DYING_GASP',
alarm='DYING_GASP',
alarm_category=AlarmEventCategory.ONU,
alarm_type=AlarmEventType.COMMUNICATION,
- alarm_severity=AlarmEventSeverity.MINOR)
+ alarm_severity=AlarmEventSeverity.MAJOR)
self._onu_id = onu_id
self._intf_id = intf_id
diff --git a/voltha/extensions/alarms/onu/onu_lob_alarm.py b/voltha/extensions/alarms/onu/onu_lob_alarm.py
new file mode 100644
index 0000000..9087cda
--- /dev/null
+++ b/voltha/extensions/alarms/onu/onu_lob_alarm.py
@@ -0,0 +1,30 @@
+# Copyright 2017-present Adtran, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+from voltha.protos.events_pb2 import AlarmEventType, AlarmEventSeverity, AlarmEventCategory
+from voltha.extensions.alarms.adapter_alarms import AlarmBase
+
+
+class OnuLobAlarm(AlarmBase):
+ def __init__(self, alarm_mgr, onu_id, intf_id):
+ super(OnuLobAlarm, self).__init__(alarm_mgr, object_type='onu LOB',
+ alarm='LOB',
+ alarm_category=AlarmEventCategory.ONU,
+ alarm_type=AlarmEventType.COMMUNICATION,
+ alarm_severity=AlarmEventSeverity.MAJOR)
+ self._onu_id = onu_id
+ self._intf_id = intf_id
+
+ def get_context_data(self):
+ return {'onu-id': self._onu_id,
+ 'onu-intf-id': self._intf_id}
diff --git a/voltha/extensions/alarms/onu/onu_lopc_mic_error_alarm.py b/voltha/extensions/alarms/onu/onu_lopc_mic_error_alarm.py
new file mode 100644
index 0000000..c636d2b
--- /dev/null
+++ b/voltha/extensions/alarms/onu/onu_lopc_mic_error_alarm.py
@@ -0,0 +1,33 @@
+# Copyright 2017-present Adtran, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from voltha.protos.events_pb2 import AlarmEventType, AlarmEventSeverity, AlarmEventCategory
+from voltha.extensions.alarms.adapter_alarms import AlarmBase
+
+
+class OnuLopcMicErrorAlarm(AlarmBase):
+ def __init__(self, alarm_mgr, onu_id, intf_id):
+ super(OnuLopcMicErrorAlarm, self).__init__(alarm_mgr, object_type='onu LOPC_MIC_ERROR',
+ alarm='LOPC_MIC_ERROR',
+ alarm_category=AlarmEventCategory.ONU,
+ alarm_type=AlarmEventType.COMMUNICATION,
+ alarm_severity=AlarmEventSeverity.MAJOR)
+ self._onu_id = onu_id
+ self._intf_id = intf_id
+
+ def get_context_data(self):
+ return {
+ 'onu-id': self._onu_id,
+ 'onu-intf-id': self._intf_id
+ }
diff --git a/voltha/extensions/alarms/onu/onu_lopc_miss_alarm.py b/voltha/extensions/alarms/onu/onu_lopc_miss_alarm.py
new file mode 100644
index 0000000..0f63716
--- /dev/null
+++ b/voltha/extensions/alarms/onu/onu_lopc_miss_alarm.py
@@ -0,0 +1,33 @@
+# Copyright 2017-present Adtran, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from voltha.protos.events_pb2 import AlarmEventType, AlarmEventSeverity, AlarmEventCategory
+from voltha.extensions.alarms.adapter_alarms import AlarmBase
+
+
+class OnuLopcMissAlarm(AlarmBase):
+ def __init__(self, alarm_mgr, onu_id, intf_id):
+ super(OnuLopcMissAlarm, self).__init__(alarm_mgr, object_type='onu LOPC_MISS',
+ alarm='LOPC_MISS',
+ alarm_category=AlarmEventCategory.ONU,
+ alarm_type=AlarmEventType.COMMUNICATION,
+ alarm_severity=AlarmEventSeverity.MAJOR)
+ self._onu_id = onu_id
+ self._intf_id = intf_id
+
+ def get_context_data(self):
+ return {
+ 'onu-id': self._onu_id,
+ 'onu-intf-id': self._intf_id
+ }
diff --git a/voltha/extensions/alarms/onu/onu_los_alarm.py b/voltha/extensions/alarms/onu/onu_los_alarm.py
index 95c59d3..c2ad5d6 100644
--- a/voltha/extensions/alarms/onu/onu_los_alarm.py
+++ b/voltha/extensions/alarms/onu/onu_los_alarm.py
@@ -16,13 +16,15 @@
class OnuLosAlarm(AlarmBase):
- def __init__(self, alarm_mgr, onu_id):
- super(OnuLosAlarm, self).__init__(alarm_mgr, 'onu LOS',
+ def __init__(self, alarm_mgr, onu_id, intf_id):
+ super(OnuLosAlarm, self).__init__(alarm_mgr, object_type='onu LOS',
alarm='LOS',
- alarm_category=AlarmEventCategory.ONT,
+ alarm_category=AlarmEventCategory.ONU,
alarm_type=AlarmEventType.COMMUNICATION,
alarm_severity=AlarmEventSeverity.MAJOR)
self._onu_id = onu_id
+ self._intf_id = intf_id
def get_context_data(self):
- return {'onu-id': self._onu_id}
+ return {'onu-id': self._onu_id,
+ 'onu-intf-id': self._intf_id}