Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 1 | # |
| 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 | """ |
| 18 | Adtran ONU adapter. |
| 19 | """ |
Chip Boling | e84aca9 | 2018-03-27 11:45:56 -0700 | [diff] [blame] | 20 | import structlog |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 21 | import binascii |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 22 | from voltha.adapters.iadapter import OnuAdapter |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 23 | from voltha.protos import third_party |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 24 | from adtran_onu_handler import AdtranOnuHandler |
Chip Boling | 3971d24 | 2018-06-06 10:26:34 -0500 | [diff] [blame] | 25 | from voltha.extensions.omci.openomci_agent import OpenOMCIAgent, OpenOmciAgentDefaults |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 26 | from twisted.internet import reactor |
Chip Boling | e931359 | 2018-06-08 13:36:18 -0500 | [diff] [blame] | 27 | from omci.adtn_capabilities_task import AdtnCapabilitiesTask |
| 28 | from omci.adtn_get_mds_task import AdtnGetMdsTask |
| 29 | from omci.adtn_mib_sync import AdtnMibSynchronizer |
Chip Boling | 3971d24 | 2018-06-06 10:26:34 -0500 | [diff] [blame] | 30 | from copy import deepcopy |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 31 | |
| 32 | _ = third_party |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 33 | |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 34 | |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 35 | class AdtranOnuAdapter(OnuAdapter): |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 36 | def __init__(self, adapter_agent, config): |
Chip Boling | ff3087f | 2017-10-12 09:26:29 -0500 | [diff] [blame] | 37 | self.log = structlog.get_logger() |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 38 | super(AdtranOnuAdapter, self).__init__(adapter_agent=adapter_agent, |
| 39 | config=config, |
| 40 | device_handler_class=AdtranOnuHandler, |
| 41 | name='adtran_onu', |
Chip Boling | 639eb6f | 2018-08-07 14:54:53 -0500 | [diff] [blame] | 42 | vendor='Adtran Inc.', |
Chip Boling | 3810e13 | 2018-10-12 13:03:47 -0500 | [diff] [blame^] | 43 | version='1.17', |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 44 | device_type='adtran_onu', |
Chip Boling | 639eb6f | 2018-08-07 14:54:53 -0500 | [diff] [blame] | 45 | vendor_id='ADTN', |
| 46 | accepts_add_remove_flow_updates=False), # TODO: Support flow-mods |
Chip Boling | 3971d24 | 2018-06-06 10:26:34 -0500 | [diff] [blame] | 47 | # Customize OpenOMCI for Adtran ONUs |
| 48 | self.adtran_omci = deepcopy(OpenOmciAgentDefaults) |
| 49 | |
Chip Boling | e931359 | 2018-06-08 13:36:18 -0500 | [diff] [blame] | 50 | 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 Boling | 3971d24 | 2018-06-06 10:26:34 -0500 | [diff] [blame] | 55 | # 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 Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 74 | |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 75 | 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 Boling | e84aca9 | 2018-03-27 11:45:56 -0700 | [diff] [blame] | 111 | self.log.info('receive_inter_adapter_message', msg=msg) |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 112 | 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 Boling | e84aca9 | 2018-03-27 11:45:56 -0700 | [diff] [blame] | 135 | self.log.debug('receive-proxied-message', proxy_address=proxy_address, |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 136 | 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 Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 154 | 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 Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 180 | 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 Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 184 | :param tcont_data: tcont data object |
| 185 | :param traffic_descriptor_data: traffic descriptor data object |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 186 | :return: None |
| 187 | """ |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 188 | self.log.info('create-tcont', tcont_data=tcont_data, |
| 189 | traffic_descriptor_data=traffic_descriptor_data) |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 190 | handler = self.devices_handlers.get(device.id) |
| 191 | if handler is not None: |
| 192 | handler.create_tcont(tcont_data, traffic_descriptor_data) |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 193 | |
| 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 Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 198 | :param tcont_data: tcont data object |
| 199 | :param traffic_descriptor_data: traffic descriptor data object |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 200 | :return: None |
| 201 | """ |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 202 | self.log.info('update-tcont', tcont_data=tcont_data, |
| 203 | traffic_descriptor_data=traffic_descriptor_data) |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 204 | handler = self.devices_handlers.get(device.id) |
| 205 | if handler is not None: |
| 206 | handler.update_tcont(tcont_data, traffic_descriptor_data) |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 207 | |
| 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 Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 212 | :param tcont_data: tcont data object |
| 213 | :param traffic_descriptor_data: traffic descriptor data object |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 214 | :return: None |
| 215 | """ |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 216 | self.log.info('remove-tcont', tcont_data=tcont_data, |
| 217 | traffic_descriptor_data=traffic_descriptor_data) |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 218 | handler = self.devices_handlers.get(device.id) |
| 219 | if handler is not None: |
| 220 | handler.remove_tcont(tcont_data, traffic_descriptor_data) |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 221 | |
| 222 | def create_gemport(self, device, data): |
| 223 | """ |
| 224 | API to create gemport object in the devices |
| 225 | :param device: device id |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 226 | :param data: gemport data object |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 227 | :return: None |
| 228 | """ |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 229 | self.log.info('create-gemport', data=data) |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 230 | handler = self.devices_handlers.get(device.id) |
| 231 | if handler is not None: |
| 232 | handler.xpon_create(data) |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 233 | |
| 234 | def update_gemport(self, device, data): |
| 235 | """ |
| 236 | API to update gemport object in the devices |
| 237 | :param device: device id |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 238 | :param data: gemport data object |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 239 | :return: None |
| 240 | """ |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 241 | self.log.info('update-gemport', data=data) |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 242 | handler = self.devices_handlers.get(device.id) |
| 243 | if handler is not None: |
| 244 | handler.xpon_update(data) |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 245 | |
| 246 | def remove_gemport(self, device, data): |
| 247 | """ |
| 248 | API to delete gemport object in the devices |
| 249 | :param device: device id |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 250 | :param data: gemport data object |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 251 | :return: None |
| 252 | """ |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 253 | self.log.info('remove-gemport', data=data) |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 254 | handler = self.devices_handlers.get(device.id) |
| 255 | if handler is not None: |
| 256 | handler.xpon_remove(data) |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 257 | |
| 258 | def create_multicast_gemport(self, device, data): |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 259 | """ |
| 260 | API to create multicast gemport object in the devices |
| 261 | :param device: device id |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 262 | :param data: multicast gemport data object |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 263 | :return: None |
| 264 | """ |
| 265 | self.log.info('create-mcast-gemport', data=data) |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 266 | handler = self.devices_handlers.get(device.id) |
| 267 | if handler is not None: |
| 268 | handler.xpon_create(data) |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 269 | |
| 270 | def update_multicast_gemport(self, device, data): |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 271 | """ |
| 272 | API to update multicast gemport object in the devices |
| 273 | :param device: device id |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 274 | :param data: multicast gemport data object |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 275 | :return: None |
| 276 | """ |
| 277 | self.log.info('update-mcast-gemport', data=data) |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 278 | handler = self.devices_handlers.get(device.id) |
| 279 | if handler is not None: |
| 280 | handler.xpon_update(data) |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 281 | |
| 282 | def remove_multicast_gemport(self, device, data): |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 283 | """ |
| 284 | API to delete multicast gemport object in the devices |
| 285 | :param device: device id |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 286 | :param data: multicast gemport data object |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 287 | :return: None |
| 288 | """ |
| 289 | self.log.info('remove-mcast-gemport', data=data) |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 290 | handler = self.devices_handlers.get(device.id) |
| 291 | if handler is not None: |
| 292 | handler.xpon_remove(data) |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 293 | |
| 294 | def create_multicast_distribution_set(self, device, data): |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 295 | """ |
| 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 Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 299 | :param data: multicast distribution data object |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 300 | :return: None |
| 301 | """ |
| 302 | self.log.info('create-mcast-distribution-set', data=data) |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 303 | handler = self.devices_handlers.get(device.id) |
| 304 | if handler is not None: |
| 305 | handler.xpon_create(data) |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 306 | |
| 307 | def update_multicast_distribution_set(self, device, data): |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 308 | """ |
| 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 Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 312 | :param data: multicast distribution data object |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 313 | :return: None |
| 314 | """ |
| 315 | self.log.info('update-mcast-distribution-set', data=data) |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 316 | handler = self.devices_handlers.get(device.id) |
| 317 | if handler is not None: |
| 318 | handler.xpon_update(data) |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 319 | |
| 320 | def remove_multicast_distribution_set(self, device, data): |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 321 | """ |
| 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 Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 325 | :param data: multicast distribution data object |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 326 | :return: None |
| 327 | """ |
| 328 | self.log.info('remove-mcast-distribution-set', data=data) |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 329 | handler = self.devices_handlers.get(device.id) |
| 330 | if handler is not None: |
| 331 | handler.xpon_remove(data) |