blob: 06bc4afd7b598e85ec75989c0aa2067979a37c9a [file] [log] [blame]
Balaji Purushothaman17795c52017-08-28 14:21:48 -05001#
2# Copyright 2017 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
17"""
18Adtran ONU adapter.
19"""
Chip Bolinge84aca92018-03-27 11:45:56 -070020import structlog
Chip Bolingfd1fd372017-12-20 13:34:12 -060021import binascii
Chip Bolingef0e2fa2017-10-06 14:33:01 -050022from voltha.adapters.iadapter import OnuAdapter
Balaji Purushothaman17795c52017-08-28 14:21:48 -050023from voltha.protos import third_party
Chip Bolingfd1fd372017-12-20 13:34:12 -060024from adtran_onu_handler import AdtranOnuHandler
Chip Boling3971d242018-06-06 10:26:34 -050025from voltha.extensions.omci.openomci_agent import OpenOMCIAgent, OpenOmciAgentDefaults
Chip Bolingfd1fd372017-12-20 13:34:12 -060026from twisted.internet import reactor
Chip Bolinge9313592018-06-08 13:36:18 -050027from omci.adtn_capabilities_task import AdtnCapabilitiesTask
28from omci.adtn_get_mds_task import AdtnGetMdsTask
29from omci.adtn_mib_sync import AdtnMibSynchronizer
Chip Boling3971d242018-06-06 10:26:34 -050030from copy import deepcopy
Balaji Purushothaman17795c52017-08-28 14:21:48 -050031
32_ = third_party
Chip Bolingef0e2fa2017-10-06 14:33:01 -050033
Balaji Purushothaman17795c52017-08-28 14:21:48 -050034
Chip Bolingef0e2fa2017-10-06 14:33:01 -050035class AdtranOnuAdapter(OnuAdapter):
Balaji Purushothaman17795c52017-08-28 14:21:48 -050036 def __init__(self, adapter_agent, config):
Chip Bolingff3087f2017-10-12 09:26:29 -050037 self.log = structlog.get_logger()
Chip Bolingef0e2fa2017-10-06 14:33:01 -050038 super(AdtranOnuAdapter, self).__init__(adapter_agent=adapter_agent,
39 config=config,
40 device_handler_class=AdtranOnuHandler,
41 name='adtran_onu',
Chip Boling639eb6f2018-08-07 14:54:53 -050042 vendor='Adtran Inc.',
Chip Boling920c3052018-08-24 14:23:31 -050043 version='0.14',
Chip Bolingef0e2fa2017-10-06 14:33:01 -050044 device_type='adtran_onu',
Chip Boling639eb6f2018-08-07 14:54:53 -050045 vendor_id='ADTN',
46 accepts_add_remove_flow_updates=False), # TODO: Support flow-mods
Chip Boling3971d242018-06-06 10:26:34 -050047 # Customize OpenOMCI for Adtran ONUs
48 self.adtran_omci = deepcopy(OpenOmciAgentDefaults)
49
Chip Bolinge9313592018-06-08 13:36:18 -050050 self.adtran_omci['mib-synchronizer']['state-machine'] = AdtnMibSynchronizer
51 self.adtran_omci['mib-synchronizer']['tasks']['get-mds'] = AdtnGetMdsTask
52 self.adtran_omci['mib-synchronizer']['tasks']['mib-audit'] = AdtnGetMdsTask
53 self.adtran_omci['omci-capabilities']['tasks']['get-capabilities'] = AdtnCapabilitiesTask
54
Chip Boling3971d242018-06-06 10:26:34 -050055 # TODO: Continue to customize adtran_omci here as needed
56
57 self._omci_agent = OpenOMCIAgent(self.adapter_agent.core,
58 support_classes=self.adtran_omci)
59
60 @property
61 def omci_agent(self):
62 return self._omci_agent
63
64 def start(self):
65 super(AdtranOnuAdapter, self).start()
66 self._omci_agent.start()
67
68 def stop(self):
69 omci, self._omci_agent = self._omci_agent, None
70 if omci is not None:
71 omci.stop()
72
73 super(AdtranOnuAdapter, self).stop()
Balaji Purushothaman17795c52017-08-28 14:21:48 -050074
Chip Bolingfd1fd372017-12-20 13:34:12 -060075 def suppress_alarm(self, filter):
76 raise NotImplementedError()
77
78 def unsuppress_alarm(self, filter):
79 raise NotImplementedError()
80
81 def download_image(self, device, request):
82 raise NotImplementedError()
83
84 def activate_image_update(self, device, request):
85 raise NotImplementedError()
86
87 def cancel_image_download(self, device, request):
88 raise NotImplementedError()
89
90 def revert_image_update(self, device, request):
91 raise NotImplementedError()
92
93 def get_image_download_status(self, device, request):
94 raise NotImplementedError()
95
96 def update_flows_incrementally(self, device, flow_changes, group_changes):
97 raise NotImplementedError()
98
99 def send_proxied_message(self, proxy_address, msg):
100 raise NotImplementedError('Not an ONU method')
101
102 def get_device_details(self, device):
103 raise NotImplementedError('TODO: Not currently supported')
104
105 def change_master_state(self, master):
106 raise NotImplementedError('Not currently supported or required')
107
108 def receive_inter_adapter_message(self, msg):
109 # Currently the only OLT Device adapter that uses this is the EdgeCore
110
Chip Bolinge84aca92018-03-27 11:45:56 -0700111 self.log.info('receive_inter_adapter_message', msg=msg)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600112 proxy_address = msg['proxy_address']
113 assert proxy_address is not None
114
115 # Device_id from the proxy_address is the olt device id. We need to
116 # get the onu device id using the port number in the proxy_address
117
118 device = self.adapter_agent.get_child_device_with_proxy_address(proxy_address)
119
120 if device is not None:
121 handler = self.devices_handlers.get(device.id)
122 if handler is not None:
123 handler.rx_inter_adapter_message(msg)
124
125 def abandon_device(self, device):
126 raise NotImplementedError('TODO: Not currently supported')
127
128 def receive_onu_detect_state(self, proxy_address, state):
129 raise NotImplementedError('TODO: Not currently supported')
130
131 def receive_packet_out(self, logical_device_id, egress_port_no, msg):
132 raise NotImplementedError('Not an ONU method')
133
134 def receive_proxied_message(self, proxy_address, msg):
Chip Bolinge84aca92018-03-27 11:45:56 -0700135 self.log.debug('receive-proxied-message', proxy_address=proxy_address,
Chip Bolingfd1fd372017-12-20 13:34:12 -0600136 device_id=proxy_address.device_id, msg=binascii.hexlify(msg))
137 # Device_id from the proxy_address is the olt device id. We need to
138 # get the onu device id using the port number in the proxy_address
139 device = self.adapter_agent.get_child_device_with_proxy_address(proxy_address)
140
141 if device is not None:
142 handler = self.devices_handlers[device.id]
143 if handler is not None:
144 handler.receive_message(msg)
145
146 ######################################################################
147 # PON Mgnt APIs
148
149 def create_interface(self, device, data):
150 """
151 API to create various interfaces (only some PON interfaces as of now)
152 in the devices
153 """
154
155 self.log.debug('create-interface', data=data)
156
157 handler = self.devices_handlers.get(device.id)
158 if handler is not None:
159 reactor.callLater(0, handler.xpon_create, data)
160
161 def update_interface(self, device, data):
162 """
163 API to update various interfaces (only some PON interfaces as of now)
164 in the devices
165 """
166 self.log.debug('update-interface', data=data)
167 handler = self.devices_handlers.get(device.id)
168 if handler is not None:
169 handler.xpon_update(data)
170
171 def remove_interface(self, device, data):
172 """
173 API to delete various interfaces (only some PON interfaces as of now)
174 in the devices
175 """
176 self.log.debug('remove-interface', data=data)
177 handler = self.devices_handlers.get(device.id)
178 if handler is not None:
179 handler.xpon_remove(data)
180
Balaji Purushothaman17795c52017-08-28 14:21:48 -0500181 def create_tcont(self, device, tcont_data, traffic_descriptor_data):
182 """
183 API to create tcont object in the devices
184 :param device: device id
Chip Bolingfd1fd372017-12-20 13:34:12 -0600185 :param tcont_data: tcont data object
186 :param traffic_descriptor_data: traffic descriptor data object
Balaji Purushothaman17795c52017-08-28 14:21:48 -0500187 :return: None
188 """
Chip Bolingef0e2fa2017-10-06 14:33:01 -0500189 self.log.info('create-tcont', tcont_data=tcont_data,
190 traffic_descriptor_data=traffic_descriptor_data)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600191 handler = self.devices_handlers.get(device.id)
192 if handler is not None:
193 handler.create_tcont(tcont_data, traffic_descriptor_data)
Balaji Purushothaman17795c52017-08-28 14:21:48 -0500194
195 def update_tcont(self, device, tcont_data, traffic_descriptor_data):
196 """
197 API to update tcont object in the devices
198 :param device: device id
Chip Bolingfd1fd372017-12-20 13:34:12 -0600199 :param tcont_data: tcont data object
200 :param traffic_descriptor_data: traffic descriptor data object
Balaji Purushothaman17795c52017-08-28 14:21:48 -0500201 :return: None
202 """
Chip Bolingef0e2fa2017-10-06 14:33:01 -0500203 self.log.info('update-tcont', tcont_data=tcont_data,
204 traffic_descriptor_data=traffic_descriptor_data)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600205 handler = self.devices_handlers.get(device.id)
206 if handler is not None:
207 handler.update_tcont(tcont_data, traffic_descriptor_data)
Balaji Purushothaman17795c52017-08-28 14:21:48 -0500208
209 def remove_tcont(self, device, tcont_data, traffic_descriptor_data):
210 """
211 API to delete tcont object in the devices
212 :param device: device id
Chip Bolingfd1fd372017-12-20 13:34:12 -0600213 :param tcont_data: tcont data object
214 :param traffic_descriptor_data: traffic descriptor data object
Balaji Purushothaman17795c52017-08-28 14:21:48 -0500215 :return: None
216 """
Chip Bolingef0e2fa2017-10-06 14:33:01 -0500217 self.log.info('remove-tcont', tcont_data=tcont_data,
218 traffic_descriptor_data=traffic_descriptor_data)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600219 handler = self.devices_handlers.get(device.id)
220 if handler is not None:
221 handler.remove_tcont(tcont_data, traffic_descriptor_data)
Balaji Purushothaman17795c52017-08-28 14:21:48 -0500222
223 def create_gemport(self, device, data):
224 """
225 API to create gemport object in the devices
226 :param device: device id
Chip Bolingfd1fd372017-12-20 13:34:12 -0600227 :param data: gemport data object
Balaji Purushothaman17795c52017-08-28 14:21:48 -0500228 :return: None
229 """
Chip Bolingef0e2fa2017-10-06 14:33:01 -0500230 self.log.info('create-gemport', data=data)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600231 handler = self.devices_handlers.get(device.id)
232 if handler is not None:
233 handler.xpon_create(data)
Balaji Purushothaman17795c52017-08-28 14:21:48 -0500234
235 def update_gemport(self, device, data):
236 """
237 API to update gemport object in the devices
238 :param device: device id
Chip Bolingfd1fd372017-12-20 13:34:12 -0600239 :param data: gemport data object
Balaji Purushothaman17795c52017-08-28 14:21:48 -0500240 :return: None
241 """
Chip Bolingef0e2fa2017-10-06 14:33:01 -0500242 self.log.info('update-gemport', data=data)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600243 handler = self.devices_handlers.get(device.id)
244 if handler is not None:
245 handler.xpon_update(data)
Balaji Purushothaman17795c52017-08-28 14:21:48 -0500246
247 def remove_gemport(self, device, data):
248 """
249 API to delete gemport object in the devices
250 :param device: device id
Chip Bolingfd1fd372017-12-20 13:34:12 -0600251 :param data: gemport data object
Balaji Purushothaman17795c52017-08-28 14:21:48 -0500252 :return: None
253 """
Chip Bolingef0e2fa2017-10-06 14:33:01 -0500254 self.log.info('remove-gemport', data=data)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600255 handler = self.devices_handlers.get(device.id)
256 if handler is not None:
257 handler.xpon_remove(data)
Balaji Purushothaman17795c52017-08-28 14:21:48 -0500258
259 def create_multicast_gemport(self, device, data):
Chip Bolingef0e2fa2017-10-06 14:33:01 -0500260 """
261 API to create multicast gemport object in the devices
262 :param device: device id
Chip Bolingfd1fd372017-12-20 13:34:12 -0600263 :param data: multicast gemport data object
Chip Bolingef0e2fa2017-10-06 14:33:01 -0500264 :return: None
265 """
266 self.log.info('create-mcast-gemport', data=data)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600267 handler = self.devices_handlers.get(device.id)
268 if handler is not None:
269 handler.xpon_create(data)
Balaji Purushothaman17795c52017-08-28 14:21:48 -0500270
271 def update_multicast_gemport(self, device, data):
Chip Bolingef0e2fa2017-10-06 14:33:01 -0500272 """
273 API to update multicast gemport object in the devices
274 :param device: device id
Chip Bolingfd1fd372017-12-20 13:34:12 -0600275 :param data: multicast gemport data object
Chip Bolingef0e2fa2017-10-06 14:33:01 -0500276 :return: None
277 """
278 self.log.info('update-mcast-gemport', data=data)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600279 handler = self.devices_handlers.get(device.id)
280 if handler is not None:
281 handler.xpon_update(data)
Balaji Purushothaman17795c52017-08-28 14:21:48 -0500282
283 def remove_multicast_gemport(self, device, data):
Chip Bolingef0e2fa2017-10-06 14:33:01 -0500284 """
285 API to delete multicast gemport object in the devices
286 :param device: device id
Chip Bolingfd1fd372017-12-20 13:34:12 -0600287 :param data: multicast gemport data object
Chip Bolingef0e2fa2017-10-06 14:33:01 -0500288 :return: None
289 """
290 self.log.info('remove-mcast-gemport', data=data)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600291 handler = self.devices_handlers.get(device.id)
292 if handler is not None:
293 handler.xpon_remove(data)
Balaji Purushothaman17795c52017-08-28 14:21:48 -0500294
295 def create_multicast_distribution_set(self, device, data):
Chip Bolingef0e2fa2017-10-06 14:33:01 -0500296 """
297 API to create multicast distribution rule to specify
298 the multicast VLANs that ride on the multicast gemport
299 :param device: device id
Chip Bolingfd1fd372017-12-20 13:34:12 -0600300 :param data: multicast distribution data object
Chip Bolingef0e2fa2017-10-06 14:33:01 -0500301 :return: None
302 """
303 self.log.info('create-mcast-distribution-set', data=data)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600304 handler = self.devices_handlers.get(device.id)
305 if handler is not None:
306 handler.xpon_create(data)
Balaji Purushothaman17795c52017-08-28 14:21:48 -0500307
308 def update_multicast_distribution_set(self, device, data):
Chip Bolingef0e2fa2017-10-06 14:33:01 -0500309 """
310 API to update multicast distribution rule to specify
311 the multicast VLANs that ride on the multicast gemport
312 :param device: device id
Chip Bolingfd1fd372017-12-20 13:34:12 -0600313 :param data: multicast distribution data object
Chip Bolingef0e2fa2017-10-06 14:33:01 -0500314 :return: None
315 """
316 self.log.info('update-mcast-distribution-set', data=data)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600317 handler = self.devices_handlers.get(device.id)
318 if handler is not None:
319 handler.xpon_update(data)
Balaji Purushothaman17795c52017-08-28 14:21:48 -0500320
321 def remove_multicast_distribution_set(self, device, data):
Chip Bolingef0e2fa2017-10-06 14:33:01 -0500322 """
323 API to delete multicast distribution rule to specify
324 the multicast VLANs that ride on the multicast gemport
325 :param device: device id
Chip Bolingfd1fd372017-12-20 13:34:12 -0600326 :param data: multicast distribution data object
Chip Bolingef0e2fa2017-10-06 14:33:01 -0500327 :return: None
328 """
329 self.log.info('remove-mcast-distribution-set', data=data)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600330 handler = self.devices_handlers.get(device.id)
331 if handler is not None:
332 handler.xpon_remove(data)