SEBA-830: Fix syntax errors and argument count mismatches
Also add some unit tests
Change-Id: Id93dd2f5a2a691b045d78cbfa7a2b1b8c30bd32b
diff --git a/.gitignore b/.gitignore
index 07bffa2..7605bb2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,4 +12,7 @@
# ide workspace
.idea
+# Virtualenv
+venv-*
+
*.pyc
diff --git a/Makefile b/Makefile
index da864d1..eece9ac 100644
--- a/Makefile
+++ b/Makefile
@@ -41,6 +41,14 @@
@ echo "Uploading sdist to test.pypi.org"
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
+VENVDIR := venv-pyvoltha
+
+venv:
+ virtualenv ${VENVDIR};\
+ source ./${VENVDIR}/bin/activate ; set -u ;\
+ rm ${VENVDIR}/local/bin ${VENVDIR}/local/lib ${VENVDIR}/local/include ;\
+ pip install -r requirements.txt
+
test:
@ echo "Executing unit tests w/tox"
tox
@@ -54,4 +62,7 @@
dist \
nose-results.xml \
pyvoltha.egg-info \
- test/unit/tmp
+ test/unit/tmp \
+ rm -rf ${VENVDIR}
+
+# end file
diff --git a/VERSION b/VERSION
index c043eea..6cec60f 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.2.1
+2.2.2-dev0
diff --git a/env.sh b/env.sh
index aeb4a1f..fafdc24 100644
--- a/env.sh
+++ b/env.sh
@@ -12,18 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# sourcing this file is needed to make local development and integration testing work
-export VOLTHA_BASE=${PWD}
-# load local python virtualenv if exists, otherwise create it
-VENVDIR="venv-$(uname -s | tr '[:upper:]' '[:lower:]')"
-if [ ! -e "${VENVDIR}/.built" ]; then
- echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
- echo "Initializing OS-appropriate virtual env."
- echo "This will take a few minutes."
- echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
- make venv
+# load local python virtualenv if exists
+VENVDIR="venv-pyvoltha"
+if [ -e "$VENVDIR/bin/activate" ]; then
+ . $VENVDIR/bin/activate
+else
+ echo "Run 'make venv' to setup python development environment"
fi
-. ${VENVDIR}/bin/activate
-# add top-level voltha dir to pythonpath
-export PYTHONPATH=${VOLTHA_BASE}/${VENVDIR}/lib/python2.7/site-packages:${VOLTHA_BASE}/pyvoltha:${VOLTHA_BASE}/pyvoltha/protos/third_party
diff --git a/pyvoltha/adapters/extensions/events/device_events/onu/onu_dying_gasp_event.py b/pyvoltha/adapters/extensions/events/device_events/onu/onu_dying_gasp_event.py
index e8efc0a..a149aa4 100644
--- a/pyvoltha/adapters/extensions/events/device_events/onu/onu_dying_gasp_event.py
+++ b/pyvoltha/adapters/extensions/events/device_events/onu/onu_dying_gasp_event.py
@@ -25,8 +25,6 @@
self._serial_number = serial_number
def get_context_data(self):
- return {
- 'onu-id': self._onu_id,
- 'onu-intf-id': self._intf_id,
- 'onu-serial-number': self._serial_number
- }
+ return {'onu-id': self._onu_id,
+ 'onu-intf-id': self._intf_id,
+ 'onu-serial-number': self._serial_number}
diff --git a/pyvoltha/adapters/extensions/events/device_events/onu/onu_equipment_event.py b/pyvoltha/adapters/extensions/events/device_events/onu/onu_equipment_event.py
index cdc2e21..63be391 100644
--- a/pyvoltha/adapters/extensions/events/device_events/onu/onu_equipment_event.py
+++ b/pyvoltha/adapters/extensions/events/device_events/onu/onu_equipment_event.py
@@ -31,14 +31,16 @@
may report it with a different event number specifically for a
self-test failure.
"""
- def __init__(self, event_mgr, onu_id, intf_id, raised_ts):
+ def __init__(self, event_mgr, onu_id, intf_id, serial_number, raised_ts):
super(OnuEquipmentEvent, self).__init__(event_mgr, raised_ts, object_type='onu equipment',
event='ONU_EQUIPMENT',
category=EventCategory.EQUIPMENT,
- sub_category=EventSubCategory.ONU,
+ sub_category=EventSubCategory.ONU)
self._onu_id = onu_id
self._intf_id = intf_id
+ self._serial_number = serial_number
def get_context_data(self):
return {'onu-id': self._onu_id,
- 'onu-intf-id': self._intf_id}
+ 'onu-intf-id': self._intf_id,
+ 'onu-serial-number': self._serial_number}
diff --git a/pyvoltha/adapters/extensions/events/device_events/onu/onu_high_rx_optical_power_event.py b/pyvoltha/adapters/extensions/events/device_events/onu/onu_high_rx_optical_power_event.py
index da72b33..adc67c7 100644
--- a/pyvoltha/adapters/extensions/events/device_events/onu/onu_high_rx_optical_power_event.py
+++ b/pyvoltha/adapters/extensions/events/device_events/onu/onu_high_rx_optical_power_event.py
@@ -22,14 +22,16 @@
For ANI-G equipment events, the intf_id reported is that of the PON/ANI
physical port number
"""
- def __init__(self, event_mgr, onu_id, intf_id, raised_ts):
+ def __init__(self, event_mgr, onu_id, intf_id, serial_number, raised_ts):
super(OnuHighRxOpticalEvent, self).__init__(event_mgr, raised_ts, object_type='onu high rx optical power',
event='ONU_HIGH_RX_OPTICAL',
category=EventCategory.COMMUNICATION,
sub_category=EventSubCategory.ONU)
self._onu_id = onu_id
self._intf_id = intf_id
+ self._serial_number = serial_number
def get_context_data(self):
return {'onu-id': self._onu_id,
- 'onu-intf-id': self._intf_id}
+ 'onu-intf-id': self._intf_id,
+ 'onu-serial-number': self._serial_number}
diff --git a/pyvoltha/adapters/extensions/events/device_events/onu/onu_high_tx_optical_power_event.py b/pyvoltha/adapters/extensions/events/device_events/onu/onu_high_tx_optical_power_event.py
index 05ede7b..66fa16f 100644
--- a/pyvoltha/adapters/extensions/events/device_events/onu/onu_high_tx_optical_power_event.py
+++ b/pyvoltha/adapters/extensions/events/device_events/onu/onu_high_tx_optical_power_event.py
@@ -22,14 +22,16 @@
For ANI-G equipment events, the intf_id reported is that of the PON/ANI
physical port number
"""
- def __init__(self, event_mgr, onu_id, intf_id, raised_ts):
+ def __init__(self, event_mgr, onu_id, intf_id, serial_number, raised_ts):
super(OnuHighTxOpticalEvent, self).__init__(event_mgr, raised_ts, object_type='onu high tx optical power',
event='ONU_HIGH_TX_OPTICAL',
category=EventCategory.COMMUNICATION,
sub_category=EventSubCategory.ONU)
self._onu_id = onu_id
self._intf_id = intf_id
+ self._serial_number = serial_number
def get_context_data(self):
return {'onu-id': self._onu_id,
- 'onu-intf-id': self._intf_id}
+ 'onu-intf-id': self._intf_id,
+ 'onu-serial-number': self._serial_number}
diff --git a/pyvoltha/adapters/extensions/events/device_events/onu/onu_laser_bias_current_event.py b/pyvoltha/adapters/extensions/events/device_events/onu/onu_laser_bias_current_event.py
index c7971d2..1d62a9c 100644
--- a/pyvoltha/adapters/extensions/events/device_events/onu/onu_laser_bias_current_event.py
+++ b/pyvoltha/adapters/extensions/events/device_events/onu/onu_laser_bias_current_event.py
@@ -23,14 +23,16 @@
For ANI-G equipment events, the intf_id reported is that of the PON/ANI
physical port number
"""
- def __init__(self, event_mgr, onu_id, intf_id, raised_ts):
+ def __init__(self, event_mgr, onu_id, intf_id, serial_number, raised_ts):
super(OnuLaserBiasEvent, self).__init__(event_mgr, raised_ts, object_type='onu laser bias current',
event='ONU_LASER_BIAS_CURRENT',
category=EventCategory.EQUIPMENT,
sub_category=EventSubCategory.ONU)
self._onu_id = onu_id
self._intf_id = intf_id
+ self._serial_number = serial_number
def get_context_data(self):
return {'onu-id': self._onu_id,
- 'onu-intf-id': self._intf_id}
+ 'onu-intf-id': self._intf_id,
+ 'onu-serial-number': self._serial_number}
diff --git a/pyvoltha/adapters/extensions/events/device_events/onu/onu_laser_eol_event.py b/pyvoltha/adapters/extensions/events/device_events/onu/onu_laser_eol_event.py
index 4cc17e2..d0e636a 100644
--- a/pyvoltha/adapters/extensions/events/device_events/onu/onu_laser_eol_event.py
+++ b/pyvoltha/adapters/extensions/events/device_events/onu/onu_laser_eol_event.py
@@ -22,14 +22,16 @@
The intf_id reported is that of the UNI's logical port number
"""
- def __init__(self, event_mgr, onu_id, intf_id, raised_ts):
+ def __init__(self, event_mgr, onu_id, intf_id, serial_number, raised_ts):
super(OnuLaserEolEvent, self).__init__(event_mgr, raised_ts, object_type='onu laser EOL',
event='ONU_LASER_EOL',
category=EventCategory.EQUIPMENT,
sub_category=EventSubCategory.ONU)
self._onu_id = onu_id
self._intf_id = intf_id
+ self._serial_number = serial_number
def get_context_data(self):
return {'onu-id': self._onu_id,
- 'onu-intf-id': self._intf_id}
+ 'onu-intf-id': self._intf_id,
+ 'onu-serial-number': self._serial_number}
diff --git a/pyvoltha/adapters/extensions/events/device_events/onu/onu_lob_event.py b/pyvoltha/adapters/extensions/events/device_events/onu/onu_lob_event.py
index da22c0f..8fcf1a2 100644
--- a/pyvoltha/adapters/extensions/events/device_events/onu/onu_lob_event.py
+++ b/pyvoltha/adapters/extensions/events/device_events/onu/onu_lob_event.py
@@ -28,5 +28,4 @@
def get_context_data(self):
return {'onu-id': self._onu_id,
'onu-intf-id': self._intf_id,
- 'onu-serial-number': self._serial_number
- }
+ 'onu-serial-number': self._serial_number}
diff --git a/pyvoltha/adapters/extensions/events/device_events/onu/onu_lopc_mic_error_event.py b/pyvoltha/adapters/extensions/events/device_events/onu/onu_lopc_mic_error_event.py
index 7605bef..1463ee4 100644
--- a/pyvoltha/adapters/extensions/events/device_events/onu/onu_lopc_mic_error_event.py
+++ b/pyvoltha/adapters/extensions/events/device_events/onu/onu_lopc_mic_error_event.py
@@ -16,7 +16,7 @@
from pyvoltha.adapters.extensions.events.adapter_events import DeviceEventBase
class OnuLopcMicErrorEvent(DeviceEventBase):
- def __init__(self, evemt_mgr, onu_id, intf_id, serial_number, raised_ts):
+ def __init__(self, event_mgr, onu_id, intf_id, serial_number, raised_ts):
super(OnuLopcMicErrorEvent, self).__init__(event_mgr, raised_ts, object_type='onu LOPC_MIC_ERROR',
event='ONU_LOPC_MIC_ERROR',
category=EventCategory.COMMUNICATION,
@@ -27,8 +27,6 @@
self._serial_number = serial_number
def get_context_data(self):
- return {
- 'onu-id': self._onu_id,
- 'onu-intf-id': self._intf_id,
- 'onu-serial-number': self._serial_number
- }
+ return {'onu-id': self._onu_id,
+ 'onu-intf-id': self._intf_id,
+ 'onu-serial-number': self._serial_number}
diff --git a/pyvoltha/adapters/extensions/events/device_events/onu/onu_lopc_miss_event.py b/pyvoltha/adapters/extensions/events/device_events/onu/onu_lopc_miss_event.py
index 58e949c..f387b14 100644
--- a/pyvoltha/adapters/extensions/events/device_events/onu/onu_lopc_miss_event.py
+++ b/pyvoltha/adapters/extensions/events/device_events/onu/onu_lopc_miss_event.py
@@ -26,8 +26,6 @@
self._serial_number = serial_number
def get_context_data(self):
- return {
- 'onu-id': self._onu_id,
- 'onu-intf-id': self._intf_id,
- 'onu-serial-number': self._serial_number
- }
+ return {'onu-id': self._onu_id,
+ 'onu-intf-id': self._intf_id,
+ 'onu-serial-number': self._serial_number}
diff --git a/pyvoltha/adapters/extensions/events/device_events/onu/onu_los_event.py b/pyvoltha/adapters/extensions/events/device_events/onu/onu_los_event.py
index f9bbccd..ba80836 100644
--- a/pyvoltha/adapters/extensions/events/device_events/onu/onu_los_event.py
+++ b/pyvoltha/adapters/extensions/events/device_events/onu/onu_los_event.py
@@ -28,5 +28,4 @@
def get_context_data(self):
return {'onu-id': self._onu_id,
'onu-intf-id': self._intf_id,
- 'onu-serial-number': self._serial_number
- }
+ 'onu-serial-number': self._serial_number}
diff --git a/pyvoltha/adapters/extensions/events/device_events/onu/onu_low_rx_optical_power_event.py b/pyvoltha/adapters/extensions/events/device_events/onu/onu_low_rx_optical_power_event.py
index 45603d5..c177c89 100644
--- a/pyvoltha/adapters/extensions/events/device_events/onu/onu_low_rx_optical_power_event.py
+++ b/pyvoltha/adapters/extensions/events/device_events/onu/onu_low_rx_optical_power_event.py
@@ -23,14 +23,16 @@
For ANI-G equipment events, the intf_id reported is that of the PON/ANI
physical port number
"""
- def __init__(self, event_mgr, onu_id, intf_id, raised_ts):
+ def __init__(self, event_mgr, onu_id, intf_id, serial_number, raised_ts):
super(OnuLowRxOpticalEvent, self).__init__(event_mgr, raised_ts, object_type='onu low rx optical power',
event='ONU_LOW_RX_OPTICAL',
category=EventCategory.COMMUNICATION,
sub_category=EventSubCategory.ONU)
self._onu_id = onu_id
self._intf_id = intf_id
+ self._serial_number = serial_number
def get_context_data(self):
return {'onu-id': self._onu_id,
- 'onu-intf-id': self._intf_id}
+ 'onu-intf-id': self._intf_id,
+ 'onu-serial-number': self._serial_number}
diff --git a/pyvoltha/adapters/extensions/events/device_events/onu/onu_low_tx_optical_power_event.py b/pyvoltha/adapters/extensions/events/device_events/onu/onu_low_tx_optical_power_event.py
index 8a073c2..63c0582 100644
--- a/pyvoltha/adapters/extensions/events/device_events/onu/onu_low_tx_optical_power_event.py
+++ b/pyvoltha/adapters/extensions/events/device_events/onu/onu_low_tx_optical_power_event.py
@@ -24,14 +24,16 @@
For ANI-G equipment events, the intf_id reported is that of the PON/ANI
physical port number
"""
- def __init__(self, event_mgr, onu_id, intf_id, raised_ts):
+ def __init__(self, event_mgr, onu_id, intf_id, serial_number, raised_ts):
super(OnuLowTxOpticalEvent, self).__init__(event_mgr, raised_ts, object_type='onu low tx optical power',
event='ONU_LOW_TX_OPTICAL',
category=EventCategory.COMMUNICATION,
- sub_category=EventCategory.ONU)
+ sub_category=EventSubCategory.ONU)
self._onu_id = onu_id
self._intf_id = intf_id
+ self._serial_number = serial_number
def get_context_data(self):
return {'onu-id': self._onu_id,
- 'onu-intf-id': self._intf_id}
+ 'onu-intf-id': self._intf_id,
+ 'onu-serial-number': self._serial_number}
diff --git a/pyvoltha/adapters/extensions/events/device_events/onu/onu_selftest_failure_event.py b/pyvoltha/adapters/extensions/events/device_events/onu/onu_selftest_failure_event.py
index 72ff144..00a5fd3 100644
--- a/pyvoltha/adapters/extensions/events/device_events/onu/onu_selftest_failure_event.py
+++ b/pyvoltha/adapters/extensions/events/device_events/onu/onu_selftest_failure_event.py
@@ -29,14 +29,16 @@
may report it with the ONU Equipment Event which can also cover a
self-test failure.
"""
- def __init__(self, event_mgr, onu_id, intf_id, raised_ts):
+ def __init__(self, event_mgr, onu_id, intf_id, serial_number, raised_ts):
super(OnuSelfTestFailureEvent, self).__init__(event_mgr, raised_ts, object_type='onu self-test failure',
event='ONU_SELF_TEST_FAIL',
category=EventCategory.EQUIPMENT,
sub_category=EventSubCategory.ONU)
self._onu_id = onu_id
self._intf_id = intf_id
+ self._serial_number = serial_number
def get_context_data(self):
return {'onu-id': self._onu_id,
- 'onu-intf-id': self._intf_id}
+ 'onu-intf-id': self._intf_id,
+ 'onu-serial-number': self._serial_number}
diff --git a/pyvoltha/adapters/extensions/events/device_events/onu/onu_signal_degrade_event.py b/pyvoltha/adapters/extensions/events/device_events/onu/onu_signal_degrade_event.py
index 840a72b..13a812f 100644
--- a/pyvoltha/adapters/extensions/events/device_events/onu/onu_signal_degrade_event.py
+++ b/pyvoltha/adapters/extensions/events/device_events/onu/onu_signal_degrade_event.py
@@ -20,7 +20,7 @@
inverse_bit_error_rate, serial_number, raised_ts):
super(OnuSignalDegradeEvent, self).__init__(event_mgr, raised_ts, object_type='onu SIGNAL DEGRADE',
event='ONU_SIGNAL_DEGRADE',
- category=EventCategory.COMMUNICATION
+ category=EventCategory.COMMUNICATION,
sub_category=EventSubCategory.ONU)
self._onu_id = onu_id
self._intf_id = intf_id
diff --git a/pyvoltha/adapters/extensions/events/device_events/onu/onu_signal_fail_event.py b/pyvoltha/adapters/extensions/events/device_events/onu/onu_signal_fail_event.py
index 17f4bc5..d49b27a 100644
--- a/pyvoltha/adapters/extensions/events/device_events/onu/onu_signal_fail_event.py
+++ b/pyvoltha/adapters/extensions/events/device_events/onu/onu_signal_fail_event.py
@@ -26,7 +26,7 @@
class OnuSignalFailEvent(DeviceEventBase):
def __init__(self, event_mgr, onu_id, intf_id, inverse_bit_error_rate, serial_number, raised_ts):
super(OnuSignalFailEvent, self).__init__(event_mgr, raised_ts, object_type='onu SIGNAL FAIL',
- alarm='ONU_SIGNAL_FAIL',
+ event='ONU_SIGNAL_FAIL',
category=EventCategory.COMMUNICATION,
sub_category=EventSubCategory.ONU)
self._onu_id = onu_id
diff --git a/pyvoltha/adapters/extensions/events/device_events/onu/onu_startup_event.py b/pyvoltha/adapters/extensions/events/device_events/onu/onu_startup_event.py
index a621a20..f041c91 100644
--- a/pyvoltha/adapters/extensions/events/device_events/onu/onu_startup_event.py
+++ b/pyvoltha/adapters/extensions/events/device_events/onu/onu_startup_event.py
@@ -39,5 +39,4 @@
def get_context_data(self):
return {'onu-id': self._onu_id,
'onu-intf-id': self._intf_id,
- 'onu-serial-number': self._serial_number
- }
+ 'onu-serial-number': self._serial_number}
diff --git a/pyvoltha/adapters/extensions/events/device_events/onu/onu_temp_red_event.py b/pyvoltha/adapters/extensions/events/device_events/onu/onu_temp_red_event.py
index 8b01796..51d1a3b 100644
--- a/pyvoltha/adapters/extensions/events/device_events/onu/onu_temp_red_event.py
+++ b/pyvoltha/adapters/extensions/events/device_events/onu/onu_temp_red_event.py
@@ -27,14 +27,16 @@
For ONT-G equipment events, the intf_id reported is that of the PON/ANI
physical port number
"""
- def __init__(self, event_mgr, onu_id, intf_id, raised_ts):
+ def __init__(self, event_mgr, onu_id, intf_id, serial_number, raised_ts):
super(OnuTempRedEvent, self).__init__(event_mgr, raised_ts, object_type='onu temperature red',
event='ONU_TEMP_RED',
category=EventCategory.ENVIRONMENT,
sub_category=EventSubCategory.ONU)
self._onu_id = onu_id
self._intf_id = intf_id
+ self._serial_number = serial_number
def get_context_data(self):
return {'onu-id': self._onu_id,
- 'onu-intf-id': self._intf_id}
+ 'onu-intf-id': self._intf_id,
+ 'onu-serial-number': self._serial_number}
diff --git a/pyvoltha/adapters/extensions/events/device_events/onu/onu_temp_yellow_event.py b/pyvoltha/adapters/extensions/events/device_events/onu/onu_temp_yellow_event.py
index 5531b2a..9285eb4 100644
--- a/pyvoltha/adapters/extensions/events/device_events/onu/onu_temp_yellow_event.py
+++ b/pyvoltha/adapters/extensions/events/device_events/onu/onu_temp_yellow_event.py
@@ -26,14 +26,16 @@
For ONT-G equipment events, the intf_id reported is that of the PON/ANI
physical port number
"""
- def __init__(self, event_mgr, onu_id, intf_id, raised_ts):
+ def __init__(self, event_mgr, onu_id, intf_id, serial_number, raised_ts):
super(OnuTempYellowEvent, self).__init__(event_mgr, raised_ts, object_type='onu temperature yellow',
event='ONU_TEMP_YELLOW',
category=EventCategory.ENVIRONMENT,
sub_category=EventSubCategory.ONU)
self._onu_id = onu_id
self._intf_id = intf_id
+ self._serial_number = serial_number
def get_context_data(self):
return {'onu-id': self._onu_id,
- 'onu-intf-id': self._intf_id}
+ 'onu-intf-id': self._intf_id,
+ 'onu-serial-number': self._serial_number}
diff --git a/pyvoltha/adapters/extensions/events/device_events/onu/onu_voltage_red_event.py b/pyvoltha/adapters/extensions/events/device_events/onu/onu_voltage_red_event.py
index 438e79f..7cde4ce 100644
--- a/pyvoltha/adapters/extensions/events/device_events/onu/onu_voltage_red_event.py
+++ b/pyvoltha/adapters/extensions/events/device_events/onu/onu_voltage_red_event.py
@@ -24,7 +24,7 @@
For ONT-G equipment events, the intf_id reported is that of the PON/ANI
physical port number
"""
- def __init__(self, event_mgr, onu_id, intf_id, raised_ts):
+ def __init__(self, event_mgr, onu_id, intf_id, serial_number, raised_ts):
super(OnuVoltageRedEvent, self).__init__(event_mgr, raised_ts, object_type='onu voltage red',
event='ONU_VOLTAGE_RED',
category=EventCategory.ENVIRONMENT,
@@ -32,7 +32,9 @@
self._onu_id = onu_id
self._intf_id = intf_id
+ self._serial_number = serial_number
def get_context_data(self):
return {'onu-id': self._onu_id,
- 'onu-intf-id': self._intf_id}
+ 'onu-intf-id': self._intf_id,
+ 'onu-serial-number': self._serial_number}
diff --git a/pyvoltha/adapters/extensions/events/device_events/onu/onu_voltage_yellow_event.py b/pyvoltha/adapters/extensions/events/device_events/onu/onu_voltage_yellow_event.py
index 2758949..d39647b 100644
--- a/pyvoltha/adapters/extensions/events/device_events/onu/onu_voltage_yellow_event.py
+++ b/pyvoltha/adapters/extensions/events/device_events/onu/onu_voltage_yellow_event.py
@@ -24,14 +24,16 @@
For ONT-G equipment events, the intf_id reported is that of the PON/ANI
physical port number
"""
- def __init__(self, event_mgr, onu_id, intf_id, raised_ts):
+ def __init__(self, event_mgr, onu_id, intf_id, serial_number, raised_ts):
super(OnuVoltageYellowEvent, self).__init__(event_mgr, raised_ts, object_type='onu voltage yellow',
event='ONU_VOLTAGE_YELLOW',
category=EventCategory.EQUIPMENT,
sub_category=EventSubCategory.ONU)
self._onu_id = onu_id
self._intf_id = intf_id
+ self._serial_number = serial_number
def get_context_data(self):
return {'onu-id': self._onu_id,
- 'onu-intf-id': self._intf_id}
+ 'onu-intf-id': self._intf_id,
+ 'onu-serial-number': self._serial_number}
diff --git a/pyvoltha/adapters/extensions/omci/state_machines/alarm_sync.py b/pyvoltha/adapters/extensions/omci/state_machines/alarm_sync.py
index 976d1d0..b63c062 100644
--- a/pyvoltha/adapters/extensions/omci/state_machines/alarm_sync.py
+++ b/pyvoltha/adapters/extensions/omci/state_machines/alarm_sync.py
@@ -14,6 +14,7 @@
# limitations under the License.
#
import structlog
+import arrow
from datetime import datetime
from transitions import Machine
from twisted.internet import reactor
@@ -528,7 +529,7 @@
if self._alarm_manager is not None:
alarm = self.omci_alarm_to_onu_alarm(class_id, entity_id, alarm_number)
if alarm is not None:
- alarm.raise_alarm()
+ alarm.send(True)
def clear_alarm(self, class_id, entity_id, alarm_number):
"""
@@ -546,7 +547,7 @@
if self._alarm_manager is not None:
alarm = self.omci_alarm_to_onu_alarm(class_id, entity_id, alarm_number)
if alarm is not None:
- alarm.clear_alarm()
+ alarm.send(False)
def query_mib(self, class_id=None, instance_id=None):
"""
@@ -630,7 +631,7 @@
}
alarm_cls = alarm_map.get((class_id, alarm_number))
- return alarm_cls(mgr, self._onu_id, intf_id, self._serial_number) if alarm_cls is not None else None
+ return alarm_cls(mgr, self._onu_id, intf_id, self._serial_number, arrow.utcnow().timestamp) if alarm_cls is not None else None
def select_uni_port(self, class_id, entity_id):
"""
diff --git a/test/unit/extensions/events/__init__.py b/test/unit/extensions/events/__init__.py
new file mode 100644
index 0000000..b0fb0b2
--- /dev/null
+++ b/test/unit/extensions/events/__init__.py
@@ -0,0 +1,13 @@
+# Copyright 2017-present Open Networking Foundation
+#
+# 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.
diff --git a/test/unit/extensions/events/device_events/__init__.py b/test/unit/extensions/events/device_events/__init__.py
new file mode 100644
index 0000000..b0fb0b2
--- /dev/null
+++ b/test/unit/extensions/events/device_events/__init__.py
@@ -0,0 +1,13 @@
+# Copyright 2017-present Open Networking Foundation
+#
+# 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.
diff --git a/test/unit/extensions/events/device_events/onu/__init__.py b/test/unit/extensions/events/device_events/onu/__init__.py
new file mode 100644
index 0000000..b0fb0b2
--- /dev/null
+++ b/test/unit/extensions/events/device_events/onu/__init__.py
@@ -0,0 +1,13 @@
+# Copyright 2017-present Open Networking Foundation
+#
+# 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.
diff --git a/test/unit/extensions/events/device_events/onu/test_onu_events.py b/test/unit/extensions/events/device_events/onu/test_onu_events.py
new file mode 100644
index 0000000..b86aacc
--- /dev/null
+++ b/test/unit/extensions/events/device_events/onu/test_onu_events.py
@@ -0,0 +1,385 @@
+#
+# Copyright 2017 the original author or authors.
+#
+# 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.
+#
+
+import arrow
+from unittest import TestCase, main
+from pyvoltha.adapters.kafka.core_proxy import CoreProxy
+from pyvoltha.adapters.extensions.events.adapter_events import AdapterEvents
+from pyvoltha.adapters.extensions.events.device_events.onu.onu_activation_fail_event import OnuActivationFailEvent
+from pyvoltha.adapters.extensions.events.device_events.onu.onu_active_event import OnuActiveEvent
+from pyvoltha.adapters.extensions.events.device_events.onu.onu_discovery_event import OnuDiscoveryEvent
+from pyvoltha.adapters.extensions.events.device_events.onu.onu_dying_gasp_event import OnuDyingGaspEvent
+from pyvoltha.adapters.extensions.events.device_events.onu.onu_equipment_event import OnuEquipmentEvent
+from pyvoltha.adapters.extensions.events.device_events.onu.onu_high_rx_optical_power_event import OnuHighRxOpticalEvent
+from pyvoltha.adapters.extensions.events.device_events.onu.onu_high_tx_optical_power_event import OnuHighTxOpticalEvent
+from pyvoltha.adapters.extensions.events.device_events.onu.onu_laser_bias_current_event import OnuLaserBiasEvent
+from pyvoltha.adapters.extensions.events.device_events.onu.onu_laser_eol_event import OnuLaserEolEvent
+from pyvoltha.adapters.extensions.events.device_events.onu.onu_lob_event import OnuLobEvent
+from pyvoltha.adapters.extensions.events.device_events.onu.onu_lopc_mic_error_event import OnuLopcMicErrorEvent
+from pyvoltha.adapters.extensions.events.device_events.onu.onu_lopc_miss_event import OnuLopcMissEvent
+from pyvoltha.adapters.extensions.events.device_events.onu.onu_los_event import OnuLosEvent
+from pyvoltha.adapters.extensions.events.device_events.onu.onu_low_rx_optical_power_event import OnuLowRxOpticalEvent
+from pyvoltha.adapters.extensions.events.device_events.onu.onu_low_tx_optical_power_event import OnuLowTxOpticalEvent
+from pyvoltha.adapters.extensions.events.device_events.onu.onu_selftest_failure_event import OnuSelfTestFailureEvent
+from pyvoltha.adapters.extensions.events.device_events.onu.onu_signal_degrade_event import OnuSignalDegradeEvent
+from pyvoltha.adapters.extensions.events.device_events.onu.onu_signal_fail_event import OnuSignalFailEvent
+from pyvoltha.adapters.extensions.events.device_events.onu.onu_startup_event import OnuStartupEvent
+from pyvoltha.adapters.extensions.events.device_events.onu.onu_temp_red_event import OnuTempRedEvent
+from pyvoltha.adapters.extensions.events.device_events.onu.onu_temp_yellow_event import OnuTempYellowEvent
+from pyvoltha.adapters.extensions.events.device_events.onu.onu_voltage_red_event import OnuVoltageRedEvent
+from pyvoltha.adapters.extensions.events.device_events.onu.onu_voltage_yellow_event import OnuVoltageYellowEvent
+from pyvoltha.adapters.extensions.events.device_events.onu.onu_window_drift_event import OnuWindowDriftEvent
+
+DEFAULT_ONU_DEVICE_ID = 'default_onu_mock'
+DEFAULT_PON_ID = 0
+DEFAULT_ONU_ID = 0
+DEFAULT_ONU_SN = 'TEST00000001'
+DEFAULT_OLT_SN = 'ABCDXXXXYYYY'
+DEFAULT_ONU_REG = 'ABCD1234'
+
+core_proxy = CoreProxy(
+ kafka_proxy=None,
+ default_core_topic='rwcore',
+ default_event_topic='voltha.events',
+ my_listening_topic='openonu')
+
+event_mgr = AdapterEvents(core_proxy, DEFAULT_ONU_DEVICE_ID, DEFAULT_ONU_DEVICE_ID, DEFAULT_ONU_SN)
+
+
+class TestOnuActivationFailEvent(TestCase):
+
+ def setUp(self):
+ self.event = OnuActivationFailEvent(event_mgr, DEFAULT_ONU_ID, DEFAULT_PON_ID, DEFAULT_ONU_SN,
+ arrow.utcnow().timestamp)
+
+ def test_get_context_data(self):
+ expected_dict = {'onu-id': DEFAULT_ONU_ID,
+ 'onu-intf-id': DEFAULT_PON_ID,
+ 'onu-serial-number': DEFAULT_ONU_SN}
+
+ self.assertEqual(self.event.get_context_data(), expected_dict)
+
+class TestOnuActiveEvent(TestCase):
+
+ def setUp(self):
+ self.event = OnuActiveEvent(event_mgr, DEFAULT_ONU_DEVICE_ID, DEFAULT_PON_ID, DEFAULT_ONU_SN,
+ DEFAULT_ONU_REG, DEFAULT_OLT_SN, arrow.utcnow().timestamp, onu_id=DEFAULT_ONU_ID )
+
+ def test_get_context_data(self):
+
+ expected_dict = {
+ 'pon-id': DEFAULT_PON_ID,
+ 'onu-id': DEFAULT_ONU_ID,
+ 'serial-number': DEFAULT_ONU_SN,
+ 'olt_serial_number': DEFAULT_OLT_SN,
+ 'device_id': DEFAULT_ONU_DEVICE_ID,
+ 'registration_id': DEFAULT_ONU_REG
+ }
+
+ self.assertEqual(self.event.get_context_data(), expected_dict)
+
+class TestOnuDiscoveryEvent(TestCase):
+
+ def setUp(self):
+ self.event = OnuDiscoveryEvent(event_mgr, DEFAULT_PON_ID, DEFAULT_ONU_SN,
+ arrow.utcnow().timestamp)
+ def test_get_context_data(self):
+ expected_dict = {'pon-id': DEFAULT_PON_ID,
+ 'serial-number': DEFAULT_ONU_SN,
+ 'device-type': 'onu'}
+
+ self.assertEqual(self.event.get_context_data(), expected_dict)
+
+class TestOnuDyingGaspEvent(TestCase):
+
+ def setUp(self):
+ self.event = OnuDyingGaspEvent(event_mgr, DEFAULT_ONU_ID, DEFAULT_PON_ID, DEFAULT_ONU_SN,
+ arrow.utcnow().timestamp)
+
+ def test_get_context_data(self):
+ expected_dict = {'onu-id': DEFAULT_ONU_ID,
+ 'onu-intf-id': DEFAULT_PON_ID,
+ 'onu-serial-number': DEFAULT_ONU_SN}
+
+ self.assertEqual(self.event.get_context_data(), expected_dict)
+
+class TestOnuEquipmentEvent(TestCase):
+
+ def setUp(self):
+ self.event = OnuEquipmentEvent(event_mgr, DEFAULT_ONU_ID, DEFAULT_PON_ID, DEFAULT_ONU_SN,
+ arrow.utcnow().timestamp)
+
+ def test_get_context_data(self):
+ expected_dict = {'onu-id': DEFAULT_ONU_ID,
+ 'onu-intf-id': DEFAULT_PON_ID,
+ 'onu-serial-number': DEFAULT_ONU_SN}
+
+ self.assertEqual(self.event.get_context_data(), expected_dict)
+
+class TestOnuHighRxOpticalEvent(TestCase):
+
+ def setUp(self):
+ self.event = OnuHighRxOpticalEvent(event_mgr, DEFAULT_ONU_ID, DEFAULT_PON_ID, DEFAULT_ONU_SN,
+ arrow.utcnow().timestamp)
+
+ def test_get_context_data(self):
+ expected_dict = {'onu-id': DEFAULT_ONU_ID,
+ 'onu-intf-id': DEFAULT_PON_ID,
+ 'onu-serial-number': DEFAULT_ONU_SN}
+
+ self.assertEqual(self.event.get_context_data(), expected_dict)
+
+class TestOnuHighTxOpticalEvent(TestCase):
+
+ def setUp(self):
+ self.event = OnuHighTxOpticalEvent(event_mgr, DEFAULT_ONU_ID, DEFAULT_PON_ID, DEFAULT_ONU_SN,
+ arrow.utcnow().timestamp)
+
+ def test_get_context_data(self):
+ expected_dict = {'onu-id': DEFAULT_ONU_ID,
+ 'onu-intf-id': DEFAULT_PON_ID,
+ 'onu-serial-number': DEFAULT_ONU_SN}
+
+ self.assertEqual(self.event.get_context_data(), expected_dict)
+
+class TestOnuLaserBiasEvent(TestCase):
+
+ def setUp(self):
+ self.event = OnuLaserBiasEvent(event_mgr, DEFAULT_ONU_ID, DEFAULT_PON_ID, DEFAULT_ONU_SN,
+ arrow.utcnow().timestamp)
+
+ def test_get_context_data(self):
+ expected_dict = {'onu-id': DEFAULT_ONU_ID,
+ 'onu-intf-id': DEFAULT_PON_ID,
+ 'onu-serial-number': DEFAULT_ONU_SN}
+
+ self.assertEqual(self.event.get_context_data(), expected_dict)
+
+class TestOnuLaserEolEvent(TestCase):
+
+ def setUp(self):
+ self.event = OnuLaserEolEvent(event_mgr, DEFAULT_ONU_ID, DEFAULT_PON_ID, DEFAULT_ONU_SN,
+ arrow.utcnow().timestamp)
+
+ def test_get_context_data(self):
+ expected_dict = {'onu-id': DEFAULT_ONU_ID,
+ 'onu-intf-id': DEFAULT_PON_ID,
+ 'onu-serial-number': DEFAULT_ONU_SN}
+
+ self.assertEqual(self.event.get_context_data(), expected_dict)
+
+class TestOnuLobEvent(TestCase):
+
+ def setUp(self):
+ self.event = OnuLobEvent(event_mgr, DEFAULT_ONU_ID, DEFAULT_PON_ID, DEFAULT_ONU_SN,
+ arrow.utcnow().timestamp)
+
+ def test_get_context_data(self):
+ expected_dict = {'onu-id': DEFAULT_ONU_ID,
+ 'onu-intf-id': DEFAULT_PON_ID,
+ 'onu-serial-number': DEFAULT_ONU_SN}
+
+ self.assertEqual(self.event.get_context_data(), expected_dict)
+
+class TestOnuLopcMicErrorEvent(TestCase):
+
+ def setUp(self):
+ self.event = OnuLopcMicErrorEvent(event_mgr, DEFAULT_ONU_ID, DEFAULT_PON_ID, DEFAULT_ONU_SN,
+ arrow.utcnow().timestamp)
+
+ def test_get_context_data(self):
+ expected_dict = {'onu-id': DEFAULT_ONU_ID,
+ 'onu-intf-id': DEFAULT_PON_ID,
+ 'onu-serial-number': DEFAULT_ONU_SN}
+
+ self.assertEqual(self.event.get_context_data(), expected_dict)
+
+class TestOnuLopcMissEvent(TestCase):
+
+ def setUp(self):
+ self.event = OnuLopcMissEvent(event_mgr, DEFAULT_ONU_ID, DEFAULT_PON_ID, DEFAULT_ONU_SN,
+ arrow.utcnow().timestamp)
+
+ def test_get_context_data(self):
+ expected_dict = {'onu-id': DEFAULT_ONU_ID,
+ 'onu-intf-id': DEFAULT_PON_ID,
+ 'onu-serial-number': DEFAULT_ONU_SN}
+
+ self.assertEqual(self.event.get_context_data(), expected_dict)
+
+class TestOnuLosEvent(TestCase):
+
+ def setUp(self):
+ self.event = OnuLosEvent(event_mgr, DEFAULT_ONU_ID, DEFAULT_PON_ID, DEFAULT_ONU_SN,
+ arrow.utcnow().timestamp)
+
+ def test_get_context_data(self):
+ expected_dict = {'onu-id': DEFAULT_ONU_ID,
+ 'onu-intf-id': DEFAULT_PON_ID,
+ 'onu-serial-number': DEFAULT_ONU_SN}
+
+ self.assertEqual(self.event.get_context_data(), expected_dict)
+
+class TestOnuLowRxOpticalEvent(TestCase):
+
+ def setUp(self):
+ self.event = OnuLowRxOpticalEvent(event_mgr, DEFAULT_ONU_ID, DEFAULT_PON_ID, DEFAULT_ONU_SN,
+ arrow.utcnow().timestamp)
+
+ def test_get_context_data(self):
+ expected_dict = {'onu-id': DEFAULT_ONU_ID,
+ 'onu-intf-id': DEFAULT_PON_ID,
+ 'onu-serial-number': DEFAULT_ONU_SN}
+
+ self.assertEqual(self.event.get_context_data(), expected_dict)
+
+class TestOnuLowTxOpticalEvent(TestCase):
+
+ def setUp(self):
+ self.event = OnuLowTxOpticalEvent(event_mgr, DEFAULT_ONU_ID, DEFAULT_PON_ID, DEFAULT_ONU_SN,
+ arrow.utcnow().timestamp)
+
+ def test_get_context_data(self):
+ expected_dict = {'onu-id': DEFAULT_ONU_ID,
+ 'onu-intf-id': DEFAULT_PON_ID,
+ 'onu-serial-number': DEFAULT_ONU_SN}
+
+ self.assertEqual(self.event.get_context_data(), expected_dict)
+
+class TestOnuSelfTestFailureEvent(TestCase):
+
+ def setUp(self):
+ self.event = OnuSelfTestFailureEvent(event_mgr, DEFAULT_ONU_ID, DEFAULT_PON_ID, DEFAULT_ONU_SN,
+ arrow.utcnow().timestamp)
+
+ def test_get_context_data(self):
+ expected_dict = {'onu-id': DEFAULT_ONU_ID,
+ 'onu-intf-id': DEFAULT_PON_ID,
+ 'onu-serial-number': DEFAULT_ONU_SN}
+
+ self.assertEqual(self.event.get_context_data(), expected_dict)
+
+class TestOnuSignalDegradeEvent(TestCase):
+
+ def setUp(self):
+ self.event = OnuSignalDegradeEvent(event_mgr, DEFAULT_ONU_ID, DEFAULT_PON_ID, 20, DEFAULT_ONU_SN,
+ arrow.utcnow().timestamp)
+
+ def test_get_context_data(self):
+ expected_dict = {'onu-id': DEFAULT_ONU_ID,
+ 'onu-intf-id': DEFAULT_PON_ID,
+ 'onu-serial-number': DEFAULT_ONU_SN,
+ 'inverse-bit-error-rate': 20}
+
+ self.assertEqual(self.event.get_context_data(), expected_dict)
+
+class TestOnuSignalFailEvent(TestCase):
+
+ def setUp(self):
+ self.event = OnuSignalFailEvent(event_mgr, DEFAULT_ONU_ID, DEFAULT_PON_ID, 20, DEFAULT_ONU_SN,
+ arrow.utcnow().timestamp)
+
+ def test_get_context_data(self):
+ expected_dict = {'onu-id': DEFAULT_ONU_ID,
+ 'onu-intf-id': DEFAULT_PON_ID,
+ 'onu-serial-number': DEFAULT_ONU_SN,
+ 'inverse-bit-error-rate': 20}
+
+ self.assertEqual(self.event.get_context_data(), expected_dict)
+
+class TestOnuStartupEvent(TestCase):
+
+ def setUp(self):
+ self.event = OnuStartupEvent(event_mgr, DEFAULT_ONU_ID, DEFAULT_PON_ID, DEFAULT_ONU_SN,
+ arrow.utcnow().timestamp)
+
+ def test_get_context_data(self):
+ expected_dict = {'onu-id': DEFAULT_ONU_ID,
+ 'onu-intf-id': DEFAULT_PON_ID,
+ 'onu-serial-number': DEFAULT_ONU_SN}
+
+ self.assertEqual(self.event.get_context_data(), expected_dict)
+
+class TestOnuTempRedEvent(TestCase):
+
+ def setUp(self):
+ self.event = OnuTempRedEvent(event_mgr, DEFAULT_ONU_ID, DEFAULT_PON_ID, DEFAULT_ONU_SN,
+ arrow.utcnow().timestamp)
+
+ def test_get_context_data(self):
+ expected_dict = {'onu-id': DEFAULT_ONU_ID,
+ 'onu-intf-id': DEFAULT_PON_ID,
+ 'onu-serial-number': DEFAULT_ONU_SN}
+
+ self.assertEqual(self.event.get_context_data(), expected_dict)
+
+class TestOnuTempYellowEvent(TestCase):
+
+ def setUp(self):
+ self.event = OnuTempYellowEvent(event_mgr, DEFAULT_ONU_ID, DEFAULT_PON_ID, DEFAULT_ONU_SN,
+ arrow.utcnow().timestamp)
+
+ def test_get_context_data(self):
+ expected_dict = {'onu-id': DEFAULT_ONU_ID,
+ 'onu-intf-id': DEFAULT_PON_ID,
+ 'onu-serial-number': DEFAULT_ONU_SN}
+
+ self.assertEqual(self.event.get_context_data(), expected_dict)
+
+class TestOnuVoltageRedEvent(TestCase):
+
+ def setUp(self):
+ self.event = OnuVoltageRedEvent(event_mgr, DEFAULT_ONU_ID, DEFAULT_PON_ID, DEFAULT_ONU_SN,
+ arrow.utcnow().timestamp)
+
+ def test_get_context_data(self):
+ expected_dict = {'onu-id': DEFAULT_ONU_ID,
+ 'onu-intf-id': DEFAULT_PON_ID,
+ 'onu-serial-number': DEFAULT_ONU_SN}
+
+ self.assertEqual(self.event.get_context_data(), expected_dict)
+
+class TestOnuVoltageYellowEvent(TestCase):
+
+ def setUp(self):
+ self.event = OnuVoltageYellowEvent(event_mgr, DEFAULT_ONU_ID, DEFAULT_PON_ID, DEFAULT_ONU_SN,
+ arrow.utcnow().timestamp)
+
+ def test_get_context_data(self):
+ expected_dict = {'onu-id': DEFAULT_ONU_ID,
+ 'onu-intf-id': DEFAULT_PON_ID,
+ 'onu-serial-number': DEFAULT_ONU_SN}
+
+ self.assertEqual(self.event.get_context_data(), expected_dict)
+
+class TestOnuWindowDriftEvent(TestCase):
+
+ def setUp(self):
+ self.event = OnuWindowDriftEvent(event_mgr, DEFAULT_ONU_ID, DEFAULT_PON_ID, 10, 20, DEFAULT_ONU_SN,
+ arrow.utcnow().timestamp)
+
+ def test_get_context_data(self):
+ expected_dict = {'onu-id': DEFAULT_ONU_ID,
+ 'onu-intf-id': DEFAULT_PON_ID,
+ 'onu-serial-number': DEFAULT_ONU_SN,
+ 'drift': 10,
+ 'new-eqd': 20}
+
+ self.assertEqual(self.event.get_context_data(), expected_dict)
+
+
+if __name__ == '__main__':
+ main()