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 | daebae3 | 2018-10-26 09:39:21 -0500 | [diff] [blame] | 30 | from omci.adtn_mib_resync_task import AdtnMibResyncTask |
| 31 | from omci.adtn_mib_reconcile_task import AdtnMibReconcileTask |
Chip Boling | 3971d24 | 2018-06-06 10:26:34 -0500 | [diff] [blame] | 32 | from copy import deepcopy |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 33 | |
| 34 | _ = third_party |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 35 | |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 36 | |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 37 | class AdtranOnuAdapter(OnuAdapter): |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 38 | def __init__(self, adapter_agent, config): |
Chip Boling | ff3087f | 2017-10-12 09:26:29 -0500 | [diff] [blame] | 39 | self.log = structlog.get_logger() |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 40 | super(AdtranOnuAdapter, self).__init__(adapter_agent=adapter_agent, |
| 41 | config=config, |
| 42 | device_handler_class=AdtranOnuHandler, |
| 43 | name='adtran_onu', |
Chip Boling | 363d5ec | 2018-11-09 16:28:04 -0600 | [diff] [blame] | 44 | vendor='ADTRAN, Inc.', |
Chip Boling | 495389b | 2018-12-20 14:42:58 -0600 | [diff] [blame] | 45 | version='1.25', |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 46 | device_type='adtran_onu', |
Chip Boling | 639eb6f | 2018-08-07 14:54:53 -0500 | [diff] [blame] | 47 | vendor_id='ADTN', |
| 48 | accepts_add_remove_flow_updates=False), # TODO: Support flow-mods |
Chip Boling | 3971d24 | 2018-06-06 10:26:34 -0500 | [diff] [blame] | 49 | # Customize OpenOMCI for Adtran ONUs |
| 50 | self.adtran_omci = deepcopy(OpenOmciAgentDefaults) |
| 51 | |
Chip Boling | 9fef0fd | 2018-12-11 09:43:59 -0600 | [diff] [blame] | 52 | from voltha.extensions.omci.database.mib_db_dict import MibDbVolatileDict |
| 53 | self.adtran_omci['mib-synchronizer']['database'] = MibDbVolatileDict |
| 54 | |
Chip Boling | e931359 | 2018-06-08 13:36:18 -0500 | [diff] [blame] | 55 | self.adtran_omci['mib-synchronizer']['state-machine'] = AdtnMibSynchronizer |
| 56 | self.adtran_omci['mib-synchronizer']['tasks']['get-mds'] = AdtnGetMdsTask |
| 57 | self.adtran_omci['mib-synchronizer']['tasks']['mib-audit'] = AdtnGetMdsTask |
Chip Boling | daebae3 | 2018-10-26 09:39:21 -0500 | [diff] [blame] | 58 | self.adtran_omci['mib-synchronizer']['tasks']['mib-resync'] = AdtnMibResyncTask |
| 59 | self.adtran_omci['mib-synchronizer']['tasks']['mib-reconcile'] = AdtnMibReconcileTask |
Chip Boling | e931359 | 2018-06-08 13:36:18 -0500 | [diff] [blame] | 60 | self.adtran_omci['omci-capabilities']['tasks']['get-capabilities'] = AdtnCapabilitiesTask |
Chip Boling | 3971d24 | 2018-06-06 10:26:34 -0500 | [diff] [blame] | 61 | # TODO: Continue to customize adtran_omci here as needed |
| 62 | |
| 63 | self._omci_agent = OpenOMCIAgent(self.adapter_agent.core, |
| 64 | support_classes=self.adtran_omci) |
| 65 | |
| 66 | @property |
| 67 | def omci_agent(self): |
| 68 | return self._omci_agent |
| 69 | |
| 70 | def start(self): |
| 71 | super(AdtranOnuAdapter, self).start() |
| 72 | self._omci_agent.start() |
| 73 | |
| 74 | def stop(self): |
| 75 | omci, self._omci_agent = self._omci_agent, None |
| 76 | if omci is not None: |
| 77 | omci.stop() |
| 78 | |
| 79 | super(AdtranOnuAdapter, self).stop() |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 80 | |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 81 | def suppress_alarm(self, filter): |
| 82 | raise NotImplementedError() |
| 83 | |
| 84 | def unsuppress_alarm(self, filter): |
| 85 | raise NotImplementedError() |
| 86 | |
| 87 | def download_image(self, device, request): |
| 88 | raise NotImplementedError() |
| 89 | |
| 90 | def activate_image_update(self, device, request): |
| 91 | raise NotImplementedError() |
| 92 | |
| 93 | def cancel_image_download(self, device, request): |
| 94 | raise NotImplementedError() |
| 95 | |
| 96 | def revert_image_update(self, device, request): |
| 97 | raise NotImplementedError() |
| 98 | |
| 99 | def get_image_download_status(self, device, request): |
| 100 | raise NotImplementedError() |
| 101 | |
| 102 | def update_flows_incrementally(self, device, flow_changes, group_changes): |
| 103 | raise NotImplementedError() |
| 104 | |
| 105 | def send_proxied_message(self, proxy_address, msg): |
| 106 | raise NotImplementedError('Not an ONU method') |
| 107 | |
| 108 | def get_device_details(self, device): |
| 109 | raise NotImplementedError('TODO: Not currently supported') |
| 110 | |
| 111 | def change_master_state(self, master): |
| 112 | raise NotImplementedError('Not currently supported or required') |
| 113 | |
| 114 | def receive_inter_adapter_message(self, msg): |
| 115 | # Currently the only OLT Device adapter that uses this is the EdgeCore |
| 116 | |
Chip Boling | e84aca9 | 2018-03-27 11:45:56 -0700 | [diff] [blame] | 117 | self.log.info('receive_inter_adapter_message', msg=msg) |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 118 | proxy_address = msg['proxy_address'] |
| 119 | assert proxy_address is not None |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 120 | # Device_id from the proxy_address is the olt device id. We need to |
| 121 | # get the onu device id using the port number in the proxy_address |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 122 | device = self.adapter_agent.get_child_device_with_proxy_address(proxy_address) |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 123 | if device is not None: |
Chip Boling | 521735d | 2018-12-20 09:58:01 -0600 | [diff] [blame] | 124 | handler = self.devices_handlers[device.id] |
| 125 | handler.event_messages.put(msg) |
| 126 | else: |
| 127 | self.log.error("device-not-found") |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 128 | |
| 129 | def abandon_device(self, device): |
| 130 | raise NotImplementedError('TODO: Not currently supported') |
| 131 | |
| 132 | def receive_onu_detect_state(self, proxy_address, state): |
| 133 | raise NotImplementedError('TODO: Not currently supported') |
| 134 | |
| 135 | def receive_packet_out(self, logical_device_id, egress_port_no, msg): |
| 136 | raise NotImplementedError('Not an ONU method') |
| 137 | |
| 138 | def receive_proxied_message(self, proxy_address, msg): |
Chip Boling | e84aca9 | 2018-03-27 11:45:56 -0700 | [diff] [blame] | 139 | self.log.debug('receive-proxied-message', proxy_address=proxy_address, |
Chip Boling | daebae3 | 2018-10-26 09:39:21 -0500 | [diff] [blame] | 140 | device_id=proxy_address.device_id, msg=binascii.hexlify(msg)) |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 141 | # Device_id from the proxy_address is the olt device id. We need to |
| 142 | # get the onu device id using the port number in the proxy_address |
| 143 | device = self.adapter_agent.get_child_device_with_proxy_address(proxy_address) |
| 144 | |
| 145 | if device is not None: |
| 146 | handler = self.devices_handlers[device.id] |
| 147 | if handler is not None: |
| 148 | handler.receive_message(msg) |
| 149 | |
| 150 | ###################################################################### |
Chip Boling | b486819 | 2018-11-01 16:38:44 -0500 | [diff] [blame] | 151 | # PON Mgnt APIs (Eventually will be deprecated) |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 152 | |
| 153 | def create_interface(self, device, data): |
| 154 | """ |
| 155 | API to create various interfaces (only some PON interfaces as of now) |
| 156 | in the devices |
| 157 | """ |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 158 | self.log.debug('create-interface', data=data) |
| 159 | |
| 160 | handler = self.devices_handlers.get(device.id) |
| 161 | if handler is not None: |
| 162 | reactor.callLater(0, handler.xpon_create, data) |
| 163 | |
| 164 | def update_interface(self, device, data): |
| 165 | """ |
| 166 | API to update various interfaces (only some PON interfaces as of now) |
| 167 | in the devices |
| 168 | """ |
| 169 | self.log.debug('update-interface', data=data) |
| 170 | handler = self.devices_handlers.get(device.id) |
| 171 | if handler is not None: |
| 172 | handler.xpon_update(data) |
| 173 | |
| 174 | def remove_interface(self, device, data): |
| 175 | """ |
| 176 | API to delete various interfaces (only some PON interfaces as of now) |
| 177 | in the devices |
| 178 | """ |
| 179 | self.log.debug('remove-interface', data=data) |
| 180 | handler = self.devices_handlers.get(device.id) |
| 181 | if handler is not None: |
| 182 | handler.xpon_remove(data) |
| 183 | |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 184 | def create_tcont(self, device, tcont_data, traffic_descriptor_data): |
| 185 | """ |
| 186 | API to create tcont object in the devices |
| 187 | :param device: device id |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 188 | :param tcont_data: tcont data object |
| 189 | :param traffic_descriptor_data: traffic descriptor data object |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 190 | :return: None |
| 191 | """ |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 192 | self.log.info('create-tcont', tcont_data=tcont_data, |
| 193 | traffic_descriptor_data=traffic_descriptor_data) |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 194 | handler = self.devices_handlers.get(device.id) |
| 195 | if handler is not None: |
| 196 | handler.create_tcont(tcont_data, traffic_descriptor_data) |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 197 | |
| 198 | def update_tcont(self, device, tcont_data, traffic_descriptor_data): |
| 199 | """ |
| 200 | API to update tcont object in the devices |
| 201 | :param device: device id |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 202 | :param tcont_data: tcont data object |
| 203 | :param traffic_descriptor_data: traffic descriptor data object |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 204 | :return: None |
| 205 | """ |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 206 | self.log.info('update-tcont', tcont_data=tcont_data, |
| 207 | traffic_descriptor_data=traffic_descriptor_data) |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 208 | handler = self.devices_handlers.get(device.id) |
| 209 | if handler is not None: |
| 210 | handler.update_tcont(tcont_data, traffic_descriptor_data) |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 211 | |
| 212 | def remove_tcont(self, device, tcont_data, traffic_descriptor_data): |
| 213 | """ |
| 214 | API to delete tcont object in the devices |
| 215 | :param device: device id |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 216 | :param tcont_data: tcont data object |
| 217 | :param traffic_descriptor_data: traffic descriptor data object |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 218 | :return: None |
| 219 | """ |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 220 | self.log.info('remove-tcont', tcont_data=tcont_data, |
| 221 | traffic_descriptor_data=traffic_descriptor_data) |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 222 | handler = self.devices_handlers.get(device.id) |
| 223 | if handler is not None: |
| 224 | handler.remove_tcont(tcont_data, traffic_descriptor_data) |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 225 | |
| 226 | def create_gemport(self, device, data): |
| 227 | """ |
| 228 | API to create gemport object in the devices |
| 229 | :param device: device id |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 230 | :param data: gemport data object |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 231 | :return: None |
| 232 | """ |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 233 | self.log.info('create-gemport', data=data) |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 234 | handler = self.devices_handlers.get(device.id) |
| 235 | if handler is not None: |
| 236 | handler.xpon_create(data) |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 237 | |
| 238 | def update_gemport(self, device, data): |
| 239 | """ |
| 240 | API to update gemport object in the devices |
| 241 | :param device: device id |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 242 | :param data: gemport data object |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 243 | :return: None |
| 244 | """ |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 245 | self.log.info('update-gemport', data=data) |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 246 | handler = self.devices_handlers.get(device.id) |
| 247 | if handler is not None: |
| 248 | handler.xpon_update(data) |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 249 | |
| 250 | def remove_gemport(self, device, data): |
| 251 | """ |
| 252 | API to delete gemport object in the devices |
| 253 | :param device: device id |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 254 | :param data: gemport data object |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 255 | :return: None |
| 256 | """ |
Chip Boling | ef0e2fa | 2017-10-06 14:33:01 -0500 | [diff] [blame] | 257 | self.log.info('remove-gemport', data=data) |
Chip Boling | fd1fd37 | 2017-12-20 13:34:12 -0600 | [diff] [blame] | 258 | handler = self.devices_handlers.get(device.id) |
| 259 | if handler is not None: |
| 260 | handler.xpon_remove(data) |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 261 | |
| 262 | def create_multicast_gemport(self, device, data): |
Chip Boling | b486819 | 2018-11-01 16:38:44 -0500 | [diff] [blame] | 263 | raise NotImplemented('xPON has been deprecated') |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 264 | |
| 265 | def update_multicast_gemport(self, device, data): |
Chip Boling | b486819 | 2018-11-01 16:38:44 -0500 | [diff] [blame] | 266 | raise NotImplemented('xPON has been deprecated') |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 267 | |
| 268 | def remove_multicast_gemport(self, device, data): |
Chip Boling | b486819 | 2018-11-01 16:38:44 -0500 | [diff] [blame] | 269 | raise NotImplemented('xPON has been deprecated') |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 270 | |
| 271 | def create_multicast_distribution_set(self, device, data): |
Chip Boling | b486819 | 2018-11-01 16:38:44 -0500 | [diff] [blame] | 272 | raise NotImplemented('xPON has been deprecated') |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 273 | |
| 274 | def update_multicast_distribution_set(self, device, data): |
Chip Boling | b486819 | 2018-11-01 16:38:44 -0500 | [diff] [blame] | 275 | raise NotImplemented('xPON has been deprecated') |
Balaji Purushothaman | 17795c5 | 2017-08-28 14:21:48 -0500 | [diff] [blame] | 276 | |
| 277 | def remove_multicast_distribution_set(self, device, data): |
Chip Boling | b486819 | 2018-11-01 16:38:44 -0500 | [diff] [blame] | 278 | raise NotImplemented('xPON has been deprecated') |