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 | 920c305 | 2018-08-24 14:23:31 -0500 | [diff] [blame] | 43 | version='0.14', |
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 | """ |
| 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 Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 181 | 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 Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 185 | :param tcont_data: tcont data object |
| 186 | :param traffic_descriptor_data: traffic descriptor data object |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 187 | :return: None |
| 188 | """ |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 189 | self.log.info('create-tcont', tcont_data=tcont_data, |
| 190 | traffic_descriptor_data=traffic_descriptor_data) |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 191 | handler = self.devices_handlers.get(device.id) |
| 192 | if handler is not None: |
| 193 | handler.create_tcont(tcont_data, traffic_descriptor_data) |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 194 | |
| 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 Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 199 | :param tcont_data: tcont data object |
| 200 | :param traffic_descriptor_data: traffic descriptor data object |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 201 | :return: None |
| 202 | """ |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 203 | self.log.info('update-tcont', tcont_data=tcont_data, |
| 204 | traffic_descriptor_data=traffic_descriptor_data) |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 205 | handler = self.devices_handlers.get(device.id) |
| 206 | if handler is not None: |
| 207 | handler.update_tcont(tcont_data, traffic_descriptor_data) |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 208 | |
| 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 Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 213 | :param tcont_data: tcont data object |
| 214 | :param traffic_descriptor_data: traffic descriptor data object |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 215 | :return: None |
| 216 | """ |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 217 | self.log.info('remove-tcont', tcont_data=tcont_data, |
| 218 | traffic_descriptor_data=traffic_descriptor_data) |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 219 | handler = self.devices_handlers.get(device.id) |
| 220 | if handler is not None: |
| 221 | handler.remove_tcont(tcont_data, traffic_descriptor_data) |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 222 | |
| 223 | def create_gemport(self, device, data): |
| 224 | """ |
| 225 | API to create gemport object in the devices |
| 226 | :param device: device id |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 227 | :param data: gemport data object |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 228 | :return: None |
| 229 | """ |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 230 | self.log.info('create-gemport', data=data) |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 231 | handler = self.devices_handlers.get(device.id) |
| 232 | if handler is not None: |
| 233 | handler.xpon_create(data) |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 234 | |
| 235 | def update_gemport(self, device, data): |
| 236 | """ |
| 237 | API to update gemport object in the devices |
| 238 | :param device: device id |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 239 | :param data: gemport data object |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 240 | :return: None |
| 241 | """ |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 242 | self.log.info('update-gemport', data=data) |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 243 | handler = self.devices_handlers.get(device.id) |
| 244 | if handler is not None: |
| 245 | handler.xpon_update(data) |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 246 | |
| 247 | def remove_gemport(self, device, data): |
| 248 | """ |
| 249 | API to delete gemport object in the devices |
| 250 | :param device: device id |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 251 | :param data: gemport data object |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 252 | :return: None |
| 253 | """ |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 254 | self.log.info('remove-gemport', data=data) |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 255 | handler = self.devices_handlers.get(device.id) |
| 256 | if handler is not None: |
| 257 | handler.xpon_remove(data) |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 258 | |
| 259 | def create_multicast_gemport(self, device, data): |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 260 | """ |
| 261 | API to create multicast gemport object in the devices |
| 262 | :param device: device id |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 263 | :param data: multicast gemport data object |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 264 | :return: None |
| 265 | """ |
| 266 | self.log.info('create-mcast-gemport', data=data) |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 267 | handler = self.devices_handlers.get(device.id) |
| 268 | if handler is not None: |
| 269 | handler.xpon_create(data) |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 270 | |
| 271 | def update_multicast_gemport(self, device, data): |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 272 | """ |
| 273 | API to update multicast gemport object in the devices |
| 274 | :param device: device id |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 275 | :param data: multicast gemport data object |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 276 | :return: None |
| 277 | """ |
| 278 | self.log.info('update-mcast-gemport', data=data) |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 279 | handler = self.devices_handlers.get(device.id) |
| 280 | if handler is not None: |
| 281 | handler.xpon_update(data) |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 282 | |
| 283 | def remove_multicast_gemport(self, device, data): |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 284 | """ |
| 285 | API to delete multicast gemport object in the devices |
| 286 | :param device: device id |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 287 | :param data: multicast gemport data object |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 288 | :return: None |
| 289 | """ |
| 290 | self.log.info('remove-mcast-gemport', data=data) |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 291 | handler = self.devices_handlers.get(device.id) |
| 292 | if handler is not None: |
| 293 | handler.xpon_remove(data) |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 294 | |
| 295 | def create_multicast_distribution_set(self, device, data): |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 296 | """ |
| 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 Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 300 | :param data: multicast distribution data object |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 301 | :return: None |
| 302 | """ |
| 303 | self.log.info('create-mcast-distribution-set', data=data) |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 304 | handler = self.devices_handlers.get(device.id) |
| 305 | if handler is not None: |
| 306 | handler.xpon_create(data) |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 307 | |
| 308 | def update_multicast_distribution_set(self, device, data): |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 309 | """ |
| 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 Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 313 | :param data: multicast distribution data object |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 314 | :return: None |
| 315 | """ |
| 316 | self.log.info('update-mcast-distribution-set', data=data) |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 317 | handler = self.devices_handlers.get(device.id) |
| 318 | if handler is not None: |
| 319 | handler.xpon_update(data) |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 320 | |
| 321 | def remove_multicast_distribution_set(self, device, data): |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 322 | """ |
| 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 Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 326 | :param data: multicast distribution data object |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 327 | :return: None |
| 328 | """ |
| 329 | self.log.info('remove-mcast-distribution-set', data=data) |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 330 | handler = self.devices_handlers.get(device.id) |
| 331 | if handler is not None: |
| 332 | handler.xpon_remove(data) |