blob: 2a3f07ebcd2f2fbf3e9a32b60679487e1fbea636 [file] [log] [blame]
Devmalya Paul0d3abf02019-07-31 18:34:27 -04001# Copyright 2017-present Adtran, Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
Zack Williams84a71e92019-11-15 09:00:19 -070015from __future__ import absolute_import
Devmalya Paul0d3abf02019-07-31 18:34:27 -040016from voltha_protos.events_pb2 import EventCategory, EventSubCategory, EventType
17from pyvoltha.adapters.extensions.events.adapter_events import DeviceEventBase
18
19
20class OnuActiveEvent(DeviceEventBase):
21 def __init__(self, event_mgr, device_id, pon_id, onu_serial_number,
22 reg_id, olt_serial_number, raised_ts, ipv4_address=None,
23 onu_id=None):
24 super(OnuActiveEvent, self).__init__(event_mgr, raised_ts, object_type='ONU',
25 event='ONU_ACTIVATED',
26 resource_id=pon_id,
27 category=EventCategory.EQUIPMENT,
28 sub_category=EventSubCategory.PON,
29 )
30
31 self._pon_id = pon_id
32 self._onu_id = onu_id
33 self._onu_serial_number = onu_serial_number
34 self._device_id = device_id
35 self._olt_serial_number = olt_serial_number
36 self._host = ipv4_address
37 self._reg_id = reg_id
38
39 def get_context_data(self):
40 data = {
41 'pon-id': self._pon_id,
42 'onu-id': self._onu_id,
43 'serial-number': self._onu_serial_number,
Devmalya Paul3fb6f742020-05-07 02:30:50 -040044 'olt-serial-number': self._olt_serial_number,
45 'device-id': self._device_id,
46 'registration-id': self._reg_id
Devmalya Paul0d3abf02019-07-31 18:34:27 -040047 }
48 if self._host is not None:
49 data['host'] = self._host
50
51 return data