blob: 539a6b31be7b657e935ab95ca7093ccb2601a4d4 [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 Boling3810e132018-10-12 13:03:47 -050043 version='1.17',
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 """
Chip Bolingfd1fd372017-12-20 13:34:12 -0600154 self.log.debug('create-interface', data=data)
155
156 handler = self.devices_handlers.get(device.id)
157 if handler is not None:
158 reactor.callLater(0, handler.xpon_create, data)
159
160 def update_interface(self, device, data):
161 """
162 API to update various interfaces (only some PON interfaces as of now)
163 in the devices
164 """
165 self.log.debug('update-interface', data=data)
166 handler = self.devices_handlers.get(device.id)
167 if handler is not None:
168 handler.xpon_update(data)
169
170 def remove_interface(self, device, data):
171 """
172 API to delete various interfaces (only some PON interfaces as of now)
173 in the devices
174 """
175 self.log.debug('remove-interface', data=data)
176 handler = self.devices_handlers.get(device.id)
177 if handler is not None:
178 handler.xpon_remove(data)
179
Balaji Purushothaman17795c52017-08-28 14:21:48 -0500180 def create_tcont(self, device, tcont_data, traffic_descriptor_data):
181 """
182 API to create tcont object in the devices
183 :param device: device id
Chip Bolingfd1fd372017-12-20 13:34:12 -0600184 :param tcont_data: tcont data object
185 :param traffic_descriptor_data: traffic descriptor data object
Balaji Purushothaman17795c52017-08-28 14:21:48 -0500186 :return: None
187 """
Chip Bolingef0e2fa2017-10-06 14:33:01 -0500188 self.log.info('create-tcont', tcont_data=tcont_data,
189 traffic_descriptor_data=traffic_descriptor_data)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600190 handler = self.devices_handlers.get(device.id)
191 if handler is not None:
192 handler.create_tcont(tcont_data, traffic_descriptor_data)
Balaji Purushothaman17795c52017-08-28 14:21:48 -0500193
194 def update_tcont(self, device, tcont_data, traffic_descriptor_data):
195 """
196 API to update tcont object in the devices
197 :param device: device id
Chip Bolingfd1fd372017-12-20 13:34:12 -0600198 :param tcont_data: tcont data object
199 :param traffic_descriptor_data: traffic descriptor data object
Balaji Purushothaman17795c52017-08-28 14:21:48 -0500200 :return: None
201 """
Chip Bolingef0e2fa2017-10-06 14:33:01 -0500202 self.log.info('update-tcont', tcont_data=tcont_data,
203 traffic_descriptor_data=traffic_descriptor_data)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600204 handler = self.devices_handlers.get(device.id)
205 if handler is not None:
206 handler.update_tcont(tcont_data, traffic_descriptor_data)
Balaji Purushothaman17795c52017-08-28 14:21:48 -0500207
208 def remove_tcont(self, device, tcont_data, traffic_descriptor_data):
209 """
210 API to delete tcont object in the devices
211 :param device: device id
Chip Bolingfd1fd372017-12-20 13:34:12 -0600212 :param tcont_data: tcont data object
213 :param traffic_descriptor_data: traffic descriptor data object
Balaji Purushothaman17795c52017-08-28 14:21:48 -0500214 :return: None
215 """
Chip Bolingef0e2fa2017-10-06 14:33:01 -0500216 self.log.info('remove-tcont', tcont_data=tcont_data,
217 traffic_descriptor_data=traffic_descriptor_data)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600218 handler = self.devices_handlers.get(device.id)
219 if handler is not None:
220 handler.remove_tcont(tcont_data, traffic_descriptor_data)
Balaji Purushothaman17795c52017-08-28 14:21:48 -0500221
222 def create_gemport(self, device, data):
223 """
224 API to create gemport object in the devices
225 :param device: device id
Chip Bolingfd1fd372017-12-20 13:34:12 -0600226 :param data: gemport data object
Balaji Purushothaman17795c52017-08-28 14:21:48 -0500227 :return: None
228 """
Chip Bolingef0e2fa2017-10-06 14:33:01 -0500229 self.log.info('create-gemport', data=data)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600230 handler = self.devices_handlers.get(device.id)
231 if handler is not None:
232 handler.xpon_create(data)
Balaji Purushothaman17795c52017-08-28 14:21:48 -0500233
234 def update_gemport(self, device, data):
235 """
236 API to update gemport object in the devices
237 :param device: device id
Chip Bolingfd1fd372017-12-20 13:34:12 -0600238 :param data: gemport data object
Balaji Purushothaman17795c52017-08-28 14:21:48 -0500239 :return: None
240 """
Chip Bolingef0e2fa2017-10-06 14:33:01 -0500241 self.log.info('update-gemport', data=data)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600242 handler = self.devices_handlers.get(device.id)
243 if handler is not None:
244 handler.xpon_update(data)
Balaji Purushothaman17795c52017-08-28 14:21:48 -0500245
246 def remove_gemport(self, device, data):
247 """
248 API to delete gemport object in the devices
249 :param device: device id
Chip Bolingfd1fd372017-12-20 13:34:12 -0600250 :param data: gemport data object
Balaji Purushothaman17795c52017-08-28 14:21:48 -0500251 :return: None
252 """
Chip Bolingef0e2fa2017-10-06 14:33:01 -0500253 self.log.info('remove-gemport', data=data)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600254 handler = self.devices_handlers.get(device.id)
255 if handler is not None:
256 handler.xpon_remove(data)
Balaji Purushothaman17795c52017-08-28 14:21:48 -0500257
258 def create_multicast_gemport(self, device, data):
Chip Bolingef0e2fa2017-10-06 14:33:01 -0500259 """
260 API to create multicast gemport object in the devices
261 :param device: device id
Chip Bolingfd1fd372017-12-20 13:34:12 -0600262 :param data: multicast gemport data object
Chip Bolingef0e2fa2017-10-06 14:33:01 -0500263 :return: None
264 """
265 self.log.info('create-mcast-gemport', data=data)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600266 handler = self.devices_handlers.get(device.id)
267 if handler is not None:
268 handler.xpon_create(data)
Balaji Purushothaman17795c52017-08-28 14:21:48 -0500269
270 def update_multicast_gemport(self, device, data):
Chip Bolingef0e2fa2017-10-06 14:33:01 -0500271 """
272 API to update multicast gemport object in the devices
273 :param device: device id
Chip Bolingfd1fd372017-12-20 13:34:12 -0600274 :param data: multicast gemport data object
Chip Bolingef0e2fa2017-10-06 14:33:01 -0500275 :return: None
276 """
277 self.log.info('update-mcast-gemport', data=data)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600278 handler = self.devices_handlers.get(device.id)
279 if handler is not None:
280 handler.xpon_update(data)
Balaji Purushothaman17795c52017-08-28 14:21:48 -0500281
282 def remove_multicast_gemport(self, device, data):
Chip Bolingef0e2fa2017-10-06 14:33:01 -0500283 """
284 API to delete multicast gemport object in the devices
285 :param device: device id
Chip Bolingfd1fd372017-12-20 13:34:12 -0600286 :param data: multicast gemport data object
Chip Bolingef0e2fa2017-10-06 14:33:01 -0500287 :return: None
288 """
289 self.log.info('remove-mcast-gemport', data=data)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600290 handler = self.devices_handlers.get(device.id)
291 if handler is not None:
292 handler.xpon_remove(data)
Balaji Purushothaman17795c52017-08-28 14:21:48 -0500293
294 def create_multicast_distribution_set(self, device, data):
Chip Bolingef0e2fa2017-10-06 14:33:01 -0500295 """
296 API to create multicast distribution rule to specify
297 the multicast VLANs that ride on the multicast gemport
298 :param device: device id
Chip Bolingfd1fd372017-12-20 13:34:12 -0600299 :param data: multicast distribution data object
Chip Bolingef0e2fa2017-10-06 14:33:01 -0500300 :return: None
301 """
302 self.log.info('create-mcast-distribution-set', data=data)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600303 handler = self.devices_handlers.get(device.id)
304 if handler is not None:
305 handler.xpon_create(data)
Balaji Purushothaman17795c52017-08-28 14:21:48 -0500306
307 def update_multicast_distribution_set(self, device, data):
Chip Bolingef0e2fa2017-10-06 14:33:01 -0500308 """
309 API to update multicast distribution rule to specify
310 the multicast VLANs that ride on the multicast gemport
311 :param device: device id
Chip Bolingfd1fd372017-12-20 13:34:12 -0600312 :param data: multicast distribution data object
Chip Bolingef0e2fa2017-10-06 14:33:01 -0500313 :return: None
314 """
315 self.log.info('update-mcast-distribution-set', data=data)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600316 handler = self.devices_handlers.get(device.id)
317 if handler is not None:
318 handler.xpon_update(data)
Balaji Purushothaman17795c52017-08-28 14:21:48 -0500319
320 def remove_multicast_distribution_set(self, device, data):
Chip Bolingef0e2fa2017-10-06 14:33:01 -0500321 """
322 API to delete multicast distribution rule to specify
323 the multicast VLANs that ride on the multicast gemport
324 :param device: device id
Chip Bolingfd1fd372017-12-20 13:34:12 -0600325 :param data: multicast distribution data object
Chip Bolingef0e2fa2017-10-06 14:33:01 -0500326 :return: None
327 """
328 self.log.info('remove-mcast-distribution-set', data=data)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600329 handler = self.devices_handlers.get(device.id)
330 if handler is not None:
331 handler.xpon_remove(data)