Chip Boling | 2727599 | 2017-09-22 15:17:04 -0500 | [diff] [blame] | 1 | # Copyright 2017-present Adtran, Inc. |
Chip Boling | 3e3b1a9 | 2017-05-16 11:51:18 -0500 | [diff] [blame] | 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
Chip Boling | 252c777 | 2017-08-16 10:13:17 -0500 | [diff] [blame] | 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
Chip Boling | 3e3b1a9 | 2017-05-16 11:51:18 -0500 | [diff] [blame] | 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
Chip Boling | 3e3b1a9 | 2017-05-16 11:51:18 -0500 | [diff] [blame] | 14 | |
| 15 | """ |
| 16 | Adtran 1-U OLT adapter. |
| 17 | """ |
| 18 | import structlog |
| 19 | from twisted.internet import reactor |
| 20 | from zope.interface import implementer |
| 21 | |
| 22 | from adtran_olt_handler import AdtranOltHandler |
| 23 | from voltha.adapters.interface import IAdapterInterface |
| 24 | from voltha.protos import third_party |
| 25 | from voltha.protos.adapter_pb2 import Adapter |
| 26 | from voltha.protos.adapter_pb2 import AdapterConfig |
| 27 | from voltha.protos.common_pb2 import LogLevel |
| 28 | from voltha.protos.device_pb2 import DeviceType, DeviceTypes |
| 29 | from voltha.protos.health_pb2 import HealthStatus |
| 30 | from voltha.registry import registry |
| 31 | |
| 32 | _ = third_party |
| 33 | log = structlog.get_logger() |
| 34 | |
| 35 | |
| 36 | @implementer(IAdapterInterface) |
| 37 | class AdtranOltAdapter(object): |
| 38 | name = 'adtran_olt' |
| 39 | |
| 40 | supported_device_types = [ |
| 41 | DeviceType( |
| 42 | id=name, |
| 43 | adapter=name, |
| 44 | accepts_bulk_flow_update=True |
| 45 | ) |
| 46 | ] |
| 47 | |
| 48 | def __init__(self, adapter_agent, config): |
| 49 | self.adapter_agent = adapter_agent |
| 50 | self.config = config |
| 51 | self.descriptor = Adapter( |
| 52 | id=self.name, |
Chip Boling | ae29801 | 2017-08-28 08:55:17 -0500 | [diff] [blame] | 53 | vendor='Adtran, Inc.', |
Chip Boling | 61a1279 | 2017-10-02 13:23:27 -0500 | [diff] [blame^] | 54 | version='0.7', |
Chip Boling | 3e3b1a9 | 2017-05-16 11:51:18 -0500 | [diff] [blame] | 55 | config=AdapterConfig(log_level=LogLevel.INFO) |
| 56 | ) |
| 57 | log.debug('adtran_olt.__init__', adapter_agent=adapter_agent) |
| 58 | self.devices_handlers = dict() # device_id -> AdtranOltHandler() |
| 59 | self.interface = registry('main').get_args().interface |
Chip Boling | 252c777 | 2017-08-16 10:13:17 -0500 | [diff] [blame] | 60 | self.logical_device_id_to_root_device_id = dict() |
Chip Boling | 3e3b1a9 | 2017-05-16 11:51:18 -0500 | [diff] [blame] | 61 | |
| 62 | def start(self): |
| 63 | """ |
| 64 | Called once after adapter instance is loaded. Can be used to async |
| 65 | initialization. |
| 66 | |
| 67 | :return: (None or Deferred) |
| 68 | """ |
Chip Boling | 3e3b1a9 | 2017-05-16 11:51:18 -0500 | [diff] [blame] | 69 | log.info('started', interface=self.interface) |
| 70 | |
| 71 | def stop(self): |
| 72 | """ |
| 73 | Called once before adapter is unloaded. It can be used to perform |
| 74 | any cleanup after the adapter. |
| 75 | |
| 76 | :return: (None or Deferred) |
| 77 | """ |
Chip Boling | 3e3b1a9 | 2017-05-16 11:51:18 -0500 | [diff] [blame] | 78 | log.info('stopped', interface=self.interface) |
| 79 | |
| 80 | def adapter_descriptor(self): |
| 81 | """ |
| 82 | Return the adapter descriptor object for this adapter. |
| 83 | |
| 84 | :return: voltha.Adapter grpc object (see voltha/protos/adapter.proto), |
| 85 | with adapter-specific information and config extensions. |
| 86 | """ |
| 87 | log.debug('get descriptor', interface=self.interface) |
| 88 | return self.descriptor |
| 89 | |
| 90 | def device_types(self): |
| 91 | """ |
| 92 | Return list of device types supported by the adapter. |
| 93 | |
| 94 | :return: voltha.DeviceTypes protobuf object, with optional type |
| 95 | specific extensions. |
| 96 | """ |
| 97 | log.debug('get device_types', interface=self.interface, items=self.supported_device_types) |
| 98 | return DeviceTypes(items=self.supported_device_types) |
| 99 | |
| 100 | def health(self): |
| 101 | """ |
| 102 | Return a 3-state health status using the voltha.HealthStatus message. |
| 103 | |
| 104 | :return: Deferred or direct return with voltha.HealthStatus message |
| 105 | """ |
| 106 | log.debug('get health', interface=self.interface) |
| 107 | return HealthStatus(state=HealthStatus.HealthState.HEALTHY) |
| 108 | |
| 109 | def change_master_state(self, master): |
| 110 | """ |
| 111 | Called to indicate if plugin shall assume or lose master role. The |
| 112 | master role can be used to perform functions that must be performed |
| 113 | from a single point in the cluster. In single-node deployments of |
| 114 | Voltha, the plugins are always in master role. |
| 115 | |
| 116 | :param master: (bool) True to indicate the mastership needs to be |
| 117 | assumed; False to indicate that mastership needs to be abandoned. |
| 118 | :return: (Deferred) which is fired by the adapter when mastership is |
| 119 | assumed/dropped, respectively. |
| 120 | """ |
| 121 | log.debug('change_master_state', interface=self.interface, master=master) |
| 122 | raise NotImplementedError() |
| 123 | |
| 124 | def adopt_device(self, device): |
| 125 | """ |
| 126 | Make sure the adapter looks after given device. Called when a device |
| 127 | is provisioned top-down and needs to be activated by the adapter. |
| 128 | |
| 129 | :param device: A voltha.Device object, with possible device-type |
| 130 | specific extensions. Such extensions shall be described as part of |
| 131 | the device type specification returned by device_types(). |
| 132 | :return: (Deferred) Shall be fired to acknowledge device ownership. |
| 133 | """ |
| 134 | log.info('adopt-device', device=device) |
| 135 | self.devices_handlers[device.id] = AdtranOltHandler(self, device.id) |
| 136 | reactor.callLater(0, self.devices_handlers[device.id].activate, device) |
| 137 | return device |
| 138 | |
khenaidoo | ce68104 | 2017-06-12 11:25:34 -0400 | [diff] [blame] | 139 | def reconcile_device(self, device): |
| 140 | """ |
Chip Boling | 7294b25 | 2017-06-15 16:16:55 -0500 | [diff] [blame] | 141 | Make sure the adapter looks after given device. Called when this device has |
| 142 | changed ownership from another Voltha instance to this one (typically, this |
| 143 | occurs when the previous voltha instance went down). |
khenaidoo | ce68104 | 2017-06-12 11:25:34 -0400 | [diff] [blame] | 144 | |
Chip Boling | 7294b25 | 2017-06-15 16:16:55 -0500 | [diff] [blame] | 145 | :param device: A voltha.Device object, with possible device-type specific |
| 146 | extensions. Such extensions shall be described as part of |
| 147 | the device type specification returned by device_types(). |
| 148 | :return: (Deferred) Shall be fired to acknowledge device ownership. |
| 149 | """ |
| 150 | log.info('reconcile-device', device=device) |
| 151 | self.devices_handlers[device.id] = AdtranOltHandler(self, device.id) |
| 152 | reactor.callLater(0, self.devices_handlers[device.id].activate, device, reconciling=True) |
| 153 | return device |
khenaidoo | ce68104 | 2017-06-12 11:25:34 -0400 | [diff] [blame] | 154 | |
Chip Boling | 3e3b1a9 | 2017-05-16 11:51:18 -0500 | [diff] [blame] | 155 | def abandon_device(self, device): |
| 156 | """ |
| 157 | Make sure the adapter no longer looks after device. This is called |
| 158 | if device ownership is taken over by another Voltha instance. |
| 159 | |
| 160 | :param device: A Voltha.Device object. |
| 161 | :return: (Deferred) Shall be fired to acknowledge abandonment. |
| 162 | """ |
| 163 | log.info('abandon-device', device=device) |
Chip Boling | 7294b25 | 2017-06-15 16:16:55 -0500 | [diff] [blame] | 164 | raise NotImplementedError() |
Chip Boling | 3e3b1a9 | 2017-05-16 11:51:18 -0500 | [diff] [blame] | 165 | |
| 166 | def disable_device(self, device): |
| 167 | """ |
| 168 | This is called when a previously enabled device needs to be disabled |
| 169 | based on a NBI call. |
| 170 | |
| 171 | :param device: A Voltha.Device object. |
| 172 | :return: (Deferred) Shall be fired to acknowledge disabling the device. |
| 173 | """ |
Chip Boling | 69fba86 | 2017-08-18 15:11:32 -0500 | [diff] [blame] | 174 | log.info('disable-device', device=device) |
Chip Boling | 7294b25 | 2017-06-15 16:16:55 -0500 | [diff] [blame] | 175 | reactor.callLater(0, self.devices_handlers[device.id].disable) |
| 176 | return device |
Chip Boling | 3e3b1a9 | 2017-05-16 11:51:18 -0500 | [diff] [blame] | 177 | |
| 178 | def reenable_device(self, device): |
| 179 | """ |
| 180 | This is called when a previously disabled device needs to be enabled |
| 181 | based on a NBI call. |
| 182 | |
| 183 | :param device: A Voltha.Device object. |
| 184 | :return: (Deferred) Shall be fired to acknowledge re-enabling the device. |
| 185 | """ |
Chip Boling | 69fba86 | 2017-08-18 15:11:32 -0500 | [diff] [blame] | 186 | log.info('reenable-device', device=device) |
Chip Boling | 7294b25 | 2017-06-15 16:16:55 -0500 | [diff] [blame] | 187 | reactor.callLater(0, self.devices_handlers[device.id].reenable) |
| 188 | return device |
Chip Boling | 3e3b1a9 | 2017-05-16 11:51:18 -0500 | [diff] [blame] | 189 | |
| 190 | def reboot_device(self, device): |
| 191 | """ |
| 192 | This is called to reboot a device based on a NBI call. The admin |
| 193 | state of the device will not change after the reboot |
| 194 | |
| 195 | :param device: A Voltha.Device object. |
| 196 | :return: (Deferred) Shall be fired to acknowledge the reboot. |
| 197 | """ |
| 198 | log.info('reboot_device', device=device) |
Chip Boling | 7294b25 | 2017-06-15 16:16:55 -0500 | [diff] [blame] | 199 | reactor.callLater(0, self.devices_handlers[device.id].reboot) |
| 200 | return device |
Chip Boling | 3e3b1a9 | 2017-05-16 11:51:18 -0500 | [diff] [blame] | 201 | |
Lydia Fang | 01f2e85 | 2017-06-28 17:24:58 -0700 | [diff] [blame] | 202 | def download_image(self, device, request): |
Chip Boling | ae29801 | 2017-08-28 08:55:17 -0500 | [diff] [blame] | 203 | """ |
| 204 | This is called to request downloading a specified image into |
| 205 | the standby partition of a device based on a NBI call. |
| 206 | This call is expected to be non-blocking. |
| 207 | :param device: A Voltha.Device object. |
| 208 | A Voltha.ImageDownload object. |
| 209 | :return: (Deferred) Shall be fired to acknowledge the download. |
| 210 | """ |
Lydia Fang | 01f2e85 | 2017-06-28 17:24:58 -0700 | [diff] [blame] | 211 | log.info('image_download', device=device, request=request) |
| 212 | raise NotImplementedError() |
| 213 | |
| 214 | def get_image_download_status(self, device, request): |
Chip Boling | ae29801 | 2017-08-28 08:55:17 -0500 | [diff] [blame] | 215 | """ |
| 216 | This is called to inquire about a requested image download |
| 217 | status based on a NBI call. |
| 218 | The adapter is expected to update the DownloadImage DB object |
| 219 | with the query result |
| 220 | :param device: A Voltha.Device object. |
| 221 | A Voltha.ImageDownload object. |
| 222 | :return: (Deferred) Shall be fired to acknowledge |
| 223 | """ |
Lydia Fang | 01f2e85 | 2017-06-28 17:24:58 -0700 | [diff] [blame] | 224 | log.info('get_image_download', device=device, request=request) |
| 225 | raise NotImplementedError() |
| 226 | |
| 227 | def cancel_image_download(self, device, request): |
Chip Boling | ae29801 | 2017-08-28 08:55:17 -0500 | [diff] [blame] | 228 | """ |
| 229 | This is called to cancel a requested image download |
| 230 | based on a NBI call. The admin state of the device will not |
| 231 | change after the download. |
| 232 | :param device: A Voltha.Device object. |
| 233 | A Voltha.ImageDownload object. |
| 234 | :return: (Deferred) Shall be fired to acknowledge |
| 235 | """ |
Lydia Fang | 01f2e85 | 2017-06-28 17:24:58 -0700 | [diff] [blame] | 236 | log.info('cancel_image_download', device=device) |
| 237 | raise NotImplementedError() |
| 238 | |
| 239 | def activate_image_update(self, device, request): |
Chip Boling | ae29801 | 2017-08-28 08:55:17 -0500 | [diff] [blame] | 240 | """ |
| 241 | This is called to activate a downloaded image from |
| 242 | a standby partition into active partition. |
| 243 | Depending on the device implementation, this call |
| 244 | may or may not cause device reboot. |
| 245 | If no reboot, then a reboot is required to make the |
| 246 | activated image running on device |
| 247 | This call is expected to be non-blocking. |
| 248 | :param device: A Voltha.Device object. |
| 249 | A Voltha.ImageDownload object. |
| 250 | :return: (Deferred) OperationResponse object. |
| 251 | """ |
| 252 | log.info('activate_image_update', device=device, request=request) |
Lydia Fang | 01f2e85 | 2017-06-28 17:24:58 -0700 | [diff] [blame] | 253 | raise NotImplementedError() |
| 254 | |
| 255 | def revert_image_update(self, device, request): |
Chip Boling | ae29801 | 2017-08-28 08:55:17 -0500 | [diff] [blame] | 256 | """ |
| 257 | This is called to deactivate the specified image at |
| 258 | active partition, and revert to previous image at |
| 259 | standby partition. |
| 260 | Depending on the device implementation, this call |
| 261 | may or may not cause device reboot. |
| 262 | If no reboot, then a reboot is required to make the |
| 263 | previous image running on device |
| 264 | This call is expected to be non-blocking. |
| 265 | :param device: A Voltha.Device object. |
| 266 | A Voltha.ImageDownload object. |
| 267 | :return: (Deferred) OperationResponse object. |
| 268 | """ |
| 269 | log.info('revert_image_update', device=device, request=request) |
Lydia Fang | 01f2e85 | 2017-06-28 17:24:58 -0700 | [diff] [blame] | 270 | raise NotImplementedError() |
| 271 | |
sathishg | 5ae8622 | 2017-06-28 15:16:29 +0530 | [diff] [blame] | 272 | def self_test_device(self, device): |
| 273 | """ |
| 274 | This is called to Self a device based on a NBI call. |
| 275 | :param device: A Voltha.Device object. |
| 276 | :return: Will return result of self test |
| 277 | """ |
Chip Boling | 5561d55 | 2017-07-07 15:11:26 -0500 | [diff] [blame] | 278 | from voltha.protos.voltha_pb2 import SelfTestResponse |
sathishg | 5ae8622 | 2017-06-28 15:16:29 +0530 | [diff] [blame] | 279 | log.info('self-test-device', device=device.id) |
Chip Boling | 5561d55 | 2017-07-07 15:11:26 -0500 | [diff] [blame] | 280 | |
| 281 | # TODO: Support self test? |
| 282 | return SelfTestResponse(result=SelfTestResponse.NOT_SUPPORTED) |
sathishg | 5ae8622 | 2017-06-28 15:16:29 +0530 | [diff] [blame] | 283 | |
Chip Boling | 3e3b1a9 | 2017-05-16 11:51:18 -0500 | [diff] [blame] | 284 | def delete_device(self, device): |
| 285 | """ |
| 286 | This is called to delete a device from the PON based on a NBI call. |
| 287 | If the device is an OLT then the whole PON will be deleted. |
| 288 | |
| 289 | :param device: A Voltha.Device object. |
| 290 | :return: (Deferred) Shall be fired to acknowledge the deletion. |
| 291 | """ |
Chip Boling | 69fba86 | 2017-08-18 15:11:32 -0500 | [diff] [blame] | 292 | log.info('delete-device', device=device) |
Chip Boling | 7294b25 | 2017-06-15 16:16:55 -0500 | [diff] [blame] | 293 | reactor.callLater(0, self.devices_handlers[device.id].delete) |
| 294 | return device |
Chip Boling | 3e3b1a9 | 2017-05-16 11:51:18 -0500 | [diff] [blame] | 295 | |
| 296 | def get_device_details(self, device): |
| 297 | """ |
| 298 | This is called to get additional device details based on a NBI call. |
| 299 | |
| 300 | :param device: A Voltha.Device object. |
| 301 | :return: (Deferred) Shall be fired to acknowledge the retrieval of |
| 302 | additional details. |
| 303 | """ |
| 304 | log.debug('get_device_details', device=device) |
| 305 | raise NotImplementedError() |
| 306 | |
| 307 | def update_flows_bulk(self, device, flows, groups): |
| 308 | """ |
| 309 | Called after any flow table change, but only if the device supports |
| 310 | bulk mode, which is expressed by the 'accepts_bulk_flow_update' |
| 311 | capability attribute of the device type. |
| 312 | |
| 313 | :param device: A Voltha.Device object. |
| 314 | :param flows: An openflow_v13.Flows object |
| 315 | :param groups: An openflow_v13.Flows object |
| 316 | :return: (Deferred or None) |
| 317 | """ |
| 318 | log.info('bulk-flow-update', device_id=device.id, flows=flows, |
Chip Boling | 69fba86 | 2017-08-18 15:11:32 -0500 | [diff] [blame] | 319 | groups=groups, num_flows=len(flows.items)) |
Chip Boling | 3e3b1a9 | 2017-05-16 11:51:18 -0500 | [diff] [blame] | 320 | assert len(groups.items) == 0, "Cannot yet deal with groups" |
Chip Boling | 7294b25 | 2017-06-15 16:16:55 -0500 | [diff] [blame] | 321 | |
Chip Boling | 3e3b1a9 | 2017-05-16 11:51:18 -0500 | [diff] [blame] | 322 | handler = self.devices_handlers[device.id] |
| 323 | return handler.update_flow_table(flows.items, device) |
| 324 | |
| 325 | def update_flows_incrementally(self, device, flow_changes, group_changes): |
| 326 | """ |
| 327 | [This mode is not supported yet.] |
| 328 | |
| 329 | :param device: A Voltha.Device object. |
| 330 | :param flow_changes: |
| 331 | :param group_changes: |
| 332 | :return: |
| 333 | """ |
| 334 | log.debug('update_flows_incrementally', device=device, flow_changes=flow_changes, |
| 335 | group_changes=group_changes) |
| 336 | raise NotImplementedError() |
| 337 | |
| 338 | def update_pm_config(self, device, pm_configs): |
| 339 | """ |
| 340 | Called every time a request is made to change pm collection behavior |
| 341 | :param device: A Voltha.Device object |
| 342 | :param pm_configs: A Pms |
| 343 | """ |
| 344 | log.debug('update_pm_config', device=device, pm_configs=pm_configs) |
Chip Boling | 5561d55 | 2017-07-07 15:11:26 -0500 | [diff] [blame] | 345 | handler = self.devices_handlers[device.id] |
| 346 | handler.update_pm_config(device, pm_configs) |
Chip Boling | 3e3b1a9 | 2017-05-16 11:51:18 -0500 | [diff] [blame] | 347 | |
| 348 | def send_proxied_message(self, proxy_address, msg): |
| 349 | """ |
| 350 | Forward a msg to a child device of device, addressed by the given |
| 351 | proxy_address=Device.ProxyAddress(). |
| 352 | |
| 353 | :param proxy_address: Address info for the parent device |
| 354 | to route the message to the child device. This was given to the |
| 355 | child device by the parent device at the creation of the child |
| 356 | device. |
| 357 | :param msg: (str) The actual message to send. |
| 358 | :return: (Deferred(None) or None) The return of this method should |
| 359 | indicate that the message was successfully *sent*. |
| 360 | """ |
Chip Boling | 69fba86 | 2017-08-18 15:11:32 -0500 | [diff] [blame] | 361 | log.debug('send-proxied-message', proxy_address=proxy_address, msg=msg) |
Chip Boling | 3e3b1a9 | 2017-05-16 11:51:18 -0500 | [diff] [blame] | 362 | handler = self.devices_handlers[proxy_address.device_id] |
| 363 | handler.send_proxied_message(proxy_address, msg) |
| 364 | |
| 365 | def receive_proxied_message(self, proxy_address, msg): |
| 366 | """ |
| 367 | Pass an async message (arrived via a proxy) to this device. |
| 368 | |
| 369 | :param proxy_address: Address info for the parent device |
| 370 | to route the message to the child device. This was given to the |
| 371 | child device by the parent device at the creation of the child |
| 372 | device. Note this is the proxy_address with which the adapter |
| 373 | had to register prior to receiving proxied messages. |
| 374 | :param msg: (str) The actual message received. |
| 375 | :return: None |
| 376 | """ |
| 377 | log.debug('receive_proxied_message', proxy_address=proxy_address, msg=msg) |
| 378 | raise NotImplementedError() |
| 379 | |
| 380 | def receive_packet_out(self, logical_device_id, egress_port_no, msg): |
| 381 | """ |
| 382 | Pass a packet_out message content to adapter so that it can forward it |
| 383 | out to the device. This is only called on root devices. |
| 384 | |
| 385 | :param logical_device_id: |
| 386 | :param egress_port_no: egress logical port number |
| 387 | :param msg: actual message |
| 388 | :return: None |
| 389 | """ |
Chip Boling | 69fba86 | 2017-08-18 15:11:32 -0500 | [diff] [blame] | 390 | log.debug('packet-out', logical_device_id=logical_device_id, |
| 391 | egress_port_no=egress_port_no, msg_len=len(msg)) |
Chip Boling | 5561d55 | 2017-07-07 15:11:26 -0500 | [diff] [blame] | 392 | |
| 393 | def ldi_to_di(ldi): |
| 394 | di = self.logical_device_id_to_root_device_id.get(ldi) |
| 395 | if di is None: |
| 396 | logical_device = self.adapter_agent.get_logical_device(ldi) |
| 397 | di = logical_device.root_device_id |
| 398 | self.logical_device_id_to_root_device_id[ldi] = di |
| 399 | return di |
| 400 | |
| 401 | device_id = ldi_to_di(logical_device_id) |
| 402 | handler = self.devices_handlers[device_id] |
| 403 | handler.packet_out(egress_port_no, msg) |
Chip Boling | 3e3b1a9 | 2017-05-16 11:51:18 -0500 | [diff] [blame] | 404 | |
| 405 | def receive_inter_adapter_message(self, msg): |
| 406 | """ |
Chip Boling | 252c777 | 2017-08-16 10:13:17 -0500 | [diff] [blame] | 407 | Called when the adapter receives a message that was sent to it directly |
Chip Boling | 3e3b1a9 | 2017-05-16 11:51:18 -0500 | [diff] [blame] | 408 | from another adapter. An adapter may register for these messages by calling |
| 409 | the register_for_inter_adapter_messages() method in the adapter agent. |
| 410 | Note that it is the responsibility of the sending and receiving |
| 411 | adapters to properly encode and decode the message. |
| 412 | :param msg: The message contents. |
| 413 | :return: None |
| 414 | """ |
| 415 | log.info('rx_inter_adapter_msg') |
| 416 | raise NotImplementedError() |
Chip Boling | 9900488 | 2017-05-19 15:36:19 -0500 | [diff] [blame] | 417 | |
| 418 | def suppress_alarm(self, filter): |
Chip Boling | 5561d55 | 2017-07-07 15:11:26 -0500 | [diff] [blame] | 419 | """ |
| 420 | Inform an adapter that all incoming alarms should be suppressed |
| 421 | :param filter: A Voltha.AlarmFilter object. |
| 422 | :return: (Deferred) Shall be fired to acknowledge the suppression. |
| 423 | """ |
Chip Boling | 9900488 | 2017-05-19 15:36:19 -0500 | [diff] [blame] | 424 | log.info('suppress_alarm', filter=filter) |
| 425 | raise NotImplementedError() |
| 426 | |
| 427 | def unsuppress_alarm(self, filter): |
Chip Boling | 5561d55 | 2017-07-07 15:11:26 -0500 | [diff] [blame] | 428 | """ |
| 429 | Inform an adapter that all incoming alarms should resume |
| 430 | :param filter: A Voltha.AlarmFilter object. |
| 431 | :return: (Deferred) Shall be fired to acknowledge the unsuppression. |
| 432 | """ |
Chip Boling | 9900488 | 2017-05-19 15:36:19 -0500 | [diff] [blame] | 433 | log.info('unsuppress_alarm', filter=filter) |
| 434 | raise NotImplementedError() |
Nikolay Titov | 89004ec | 2017-06-19 18:22:42 -0400 | [diff] [blame] | 435 | |
Chip Boling | 5561d55 | 2017-07-07 15:11:26 -0500 | [diff] [blame] | 436 | # PON Mgnt APIs # |
Nikolay Titov | 89004ec | 2017-06-19 18:22:42 -0400 | [diff] [blame] | 437 | def create_interface(self, device, data): |
Chip Boling | 5561d55 | 2017-07-07 15:11:26 -0500 | [diff] [blame] | 438 | """ |
| 439 | API to create various interfaces (only some PON interfaces as of now) |
| 440 | in the devices |
| 441 | """ |
Chip Boling | 69fba86 | 2017-08-18 15:11:32 -0500 | [diff] [blame] | 442 | log.info('create-interface', data=data) |
Chip Boling | 2727599 | 2017-09-22 15:17:04 -0500 | [diff] [blame] | 443 | if device.id in self.devices_handlers: |
| 444 | handler = self.devices_handlers[device.id] |
| 445 | if handler is not None: |
| 446 | handler.create_interface(data) |
Nikolay Titov | 89004ec | 2017-06-19 18:22:42 -0400 | [diff] [blame] | 447 | |
| 448 | def update_interface(self, device, data): |
Chip Boling | 5561d55 | 2017-07-07 15:11:26 -0500 | [diff] [blame] | 449 | """ |
| 450 | API to update various interfaces (only some PON interfaces as of now) |
| 451 | in the devices |
| 452 | """ |
Chip Boling | 69fba86 | 2017-08-18 15:11:32 -0500 | [diff] [blame] | 453 | log.info('update-interface', data=data) |
Chip Boling | 2727599 | 2017-09-22 15:17:04 -0500 | [diff] [blame] | 454 | if device.id in self.devices_handlers: |
| 455 | handler = self.devices_handlers[device.id] |
| 456 | if handler is not None: |
| 457 | handler.update_interface(data) |
Nikolay Titov | 89004ec | 2017-06-19 18:22:42 -0400 | [diff] [blame] | 458 | |
| 459 | def remove_interface(self, device, data): |
Chip Boling | 5561d55 | 2017-07-07 15:11:26 -0500 | [diff] [blame] | 460 | """ |
| 461 | API to delete various interfaces (only some PON interfaces as of now) |
| 462 | in the devices |
| 463 | """ |
Chip Boling | 69fba86 | 2017-08-18 15:11:32 -0500 | [diff] [blame] | 464 | log.info('remove-interface', data=data) |
Chip Boling | 2727599 | 2017-09-22 15:17:04 -0500 | [diff] [blame] | 465 | if device.id in self.devices_handlers: |
| 466 | handler = self.devices_handlers[device.id] |
| 467 | if handler is not None: |
| 468 | handler.remove_interface(data) |
Nikolay Titov | 89004ec | 2017-06-19 18:22:42 -0400 | [diff] [blame] | 469 | |
Chip Boling | ae29801 | 2017-08-28 08:55:17 -0500 | [diff] [blame] | 470 | def receive_onu_detect_state(self, proxy_address, state): |
Chip Boling | 5561d55 | 2017-07-07 15:11:26 -0500 | [diff] [blame] | 471 | """ |
| 472 | Receive onu detect state in ONU adapter |
| 473 | :param proxy_address: ONU device address |
| 474 | :param state: ONU detect state (bool) |
| 475 | :return: None |
| 476 | """ |
Nikolay Titov | 89004ec | 2017-06-19 18:22:42 -0400 | [diff] [blame] | 477 | raise NotImplementedError() |
Nikolay Titov | 176f1db | 2017-08-10 12:38:43 -0400 | [diff] [blame] | 478 | |
| 479 | def create_tcont(self, device, tcont_data, traffic_descriptor_data): |
Chip Boling | ae29801 | 2017-08-28 08:55:17 -0500 | [diff] [blame] | 480 | """ |
| 481 | API to create tcont object in the devices |
| 482 | :param device: device id |
| 483 | :tcont_data: tcont data object |
| 484 | :traffic_descriptor_data: traffic descriptor data object |
| 485 | :return: None |
| 486 | """ |
Chip Boling | 69fba86 | 2017-08-18 15:11:32 -0500 | [diff] [blame] | 487 | log.info('create-tcont', tcont_data=tcont_data, |
| 488 | traffic_descriptor_data=traffic_descriptor_data) |
Chip Boling | 2727599 | 2017-09-22 15:17:04 -0500 | [diff] [blame] | 489 | if device.id in self.devices_handlers: |
| 490 | handler = self.devices_handlers[device.id] |
| 491 | if handler is not None: |
| 492 | handler.create_tcont(tcont_data, traffic_descriptor_data) |
Nikolay Titov | 176f1db | 2017-08-10 12:38:43 -0400 | [diff] [blame] | 493 | |
| 494 | def update_tcont(self, device, tcont_data, traffic_descriptor_data): |
Chip Boling | ae29801 | 2017-08-28 08:55:17 -0500 | [diff] [blame] | 495 | """ |
| 496 | API to update tcont object in the devices |
| 497 | :param device: device id |
| 498 | :tcont_data: tcont data object |
| 499 | :traffic_descriptor_data: traffic descriptor data object |
| 500 | :return: None |
| 501 | """ |
Chip Boling | 69fba86 | 2017-08-18 15:11:32 -0500 | [diff] [blame] | 502 | log.info('update-tcont', tcont_data=tcont_data, |
| 503 | traffic_descriptor_data=traffic_descriptor_data) |
Chip Boling | 2727599 | 2017-09-22 15:17:04 -0500 | [diff] [blame] | 504 | if device.id in self.devices_handlers: |
| 505 | handler = self.devices_handlers[device.id] |
| 506 | if handler is not None: |
| 507 | handler.update_tcont(tcont_data, traffic_descriptor_data) |
Nikolay Titov | 176f1db | 2017-08-10 12:38:43 -0400 | [diff] [blame] | 508 | |
| 509 | def remove_tcont(self, device, tcont_data, traffic_descriptor_data): |
Chip Boling | ae29801 | 2017-08-28 08:55:17 -0500 | [diff] [blame] | 510 | """ |
| 511 | API to delete tcont object in the devices |
| 512 | :param device: device id |
| 513 | :tcont_data: tcont data object |
| 514 | :traffic_descriptor_data: traffic descriptor data object |
| 515 | :return: None |
| 516 | """ |
Chip Boling | 69fba86 | 2017-08-18 15:11:32 -0500 | [diff] [blame] | 517 | log.info('remove-tcont', tcont_data=tcont_data, |
| 518 | traffic_descriptor_data=traffic_descriptor_data) |
Chip Boling | 2727599 | 2017-09-22 15:17:04 -0500 | [diff] [blame] | 519 | if device.id in self.devices_handlers: |
| 520 | handler = self.devices_handlers[device.id] |
| 521 | if handler is not None: |
| 522 | handler.remove_tcont(tcont_data, traffic_descriptor_data) |
Nikolay Titov | 176f1db | 2017-08-10 12:38:43 -0400 | [diff] [blame] | 523 | |
| 524 | def create_gemport(self, device, data): |
Chip Boling | ae29801 | 2017-08-28 08:55:17 -0500 | [diff] [blame] | 525 | """ |
| 526 | API to create gemport object in the devices |
| 527 | :param device: device id |
| 528 | :data: gemport data object |
| 529 | :return: None |
| 530 | """ |
Chip Boling | 69fba86 | 2017-08-18 15:11:32 -0500 | [diff] [blame] | 531 | log.info('create-gemport', data=data) |
Chip Boling | 2727599 | 2017-09-22 15:17:04 -0500 | [diff] [blame] | 532 | if device.id in self.devices_handlers: |
| 533 | handler = self.devices_handlers[device.id] |
| 534 | if handler is not None: |
| 535 | handler.create_gemport(data) |
Nikolay Titov | 176f1db | 2017-08-10 12:38:43 -0400 | [diff] [blame] | 536 | |
| 537 | def update_gemport(self, device, data): |
Chip Boling | ae29801 | 2017-08-28 08:55:17 -0500 | [diff] [blame] | 538 | """ |
| 539 | API to update gemport object in the devices |
| 540 | :param device: device id |
| 541 | :data: gemport data object |
| 542 | :return: None |
| 543 | """ |
Chip Boling | 69fba86 | 2017-08-18 15:11:32 -0500 | [diff] [blame] | 544 | log.info('update-gemport', data=data) |
Chip Boling | 2727599 | 2017-09-22 15:17:04 -0500 | [diff] [blame] | 545 | if device.id in self.devices_handlers: |
| 546 | handler = self.devices_handlers[device.id] |
| 547 | if handler is not None: |
| 548 | handler.update_gemport(data) |
Nikolay Titov | 176f1db | 2017-08-10 12:38:43 -0400 | [diff] [blame] | 549 | |
| 550 | def remove_gemport(self, device, data): |
Chip Boling | ae29801 | 2017-08-28 08:55:17 -0500 | [diff] [blame] | 551 | """ |
| 552 | API to delete gemport object in the devices |
| 553 | :param device: device id |
| 554 | :data: gemport data object |
| 555 | :return: None |
| 556 | """ |
Chip Boling | 69fba86 | 2017-08-18 15:11:32 -0500 | [diff] [blame] | 557 | log.info('remove-gemport', data=data) |
Chip Boling | 2727599 | 2017-09-22 15:17:04 -0500 | [diff] [blame] | 558 | if device.id in self.devices_handlers: |
| 559 | handler = self.devices_handlers[device.id] |
| 560 | if handler is not None: |
| 561 | handler.remove_gemport(data) |
Nikolay Titov | 176f1db | 2017-08-10 12:38:43 -0400 | [diff] [blame] | 562 | |
| 563 | def create_multicast_gemport(self, device, data): |
Chip Boling | ae29801 | 2017-08-28 08:55:17 -0500 | [diff] [blame] | 564 | """ |
| 565 | API to create multicast gemport object in the devices |
| 566 | :param device: device id |
| 567 | :data: multicast gemport data object |
| 568 | :return: None |
| 569 | """ |
Chip Boling | 69fba86 | 2017-08-18 15:11:32 -0500 | [diff] [blame] | 570 | log.info('create-mcast-gemport', data=data) |
Chip Boling | 2727599 | 2017-09-22 15:17:04 -0500 | [diff] [blame] | 571 | if device.id in self.devices_handlers: |
| 572 | handler = self.devices_handlers[device.id] |
| 573 | if handler is not None: |
| 574 | handler.create_multicast_gemport(data) |
Nikolay Titov | 176f1db | 2017-08-10 12:38:43 -0400 | [diff] [blame] | 575 | |
| 576 | def update_multicast_gemport(self, device, data): |
Chip Boling | ae29801 | 2017-08-28 08:55:17 -0500 | [diff] [blame] | 577 | """ |
| 578 | API to update multicast gemport object in the devices |
| 579 | :param device: device id |
| 580 | :data: multicast gemport data object |
| 581 | :return: None |
| 582 | """ |
Chip Boling | 69fba86 | 2017-08-18 15:11:32 -0500 | [diff] [blame] | 583 | log.info('update-mcast-gemport', data=data) |
Chip Boling | 2727599 | 2017-09-22 15:17:04 -0500 | [diff] [blame] | 584 | if device.id in self.devices_handlers: |
| 585 | handler = self.devices_handlers[device.id] |
| 586 | if handler is not None: |
| 587 | handler.update_multicast_gemport(data) |
Nikolay Titov | 176f1db | 2017-08-10 12:38:43 -0400 | [diff] [blame] | 588 | |
| 589 | def remove_multicast_gemport(self, device, data): |
Chip Boling | ae29801 | 2017-08-28 08:55:17 -0500 | [diff] [blame] | 590 | """ |
| 591 | API to delete multicast gemport object in the devices |
| 592 | :param device: device id |
| 593 | :data: multicast gemport data object |
| 594 | :return: None |
| 595 | """ |
Chip Boling | 69fba86 | 2017-08-18 15:11:32 -0500 | [diff] [blame] | 596 | log.info('remove-mcast-gemport', data=data) |
Chip Boling | 2727599 | 2017-09-22 15:17:04 -0500 | [diff] [blame] | 597 | if device.id in self.devices_handlers: |
| 598 | handler = self.devices_handlers[device.id] |
| 599 | if handler is not None: |
| 600 | handler.remove_multicast_gemport(data) |
Nikolay Titov | 176f1db | 2017-08-10 12:38:43 -0400 | [diff] [blame] | 601 | |
| 602 | def create_multicast_distribution_set(self, device, data): |
Chip Boling | ae29801 | 2017-08-28 08:55:17 -0500 | [diff] [blame] | 603 | """ |
| 604 | API to create multicast distribution rule to specify |
| 605 | the multicast VLANs that ride on the multicast gemport |
| 606 | :param device: device id |
| 607 | :data: multicast distribution data object |
| 608 | :return: None |
| 609 | """ |
Chip Boling | 69fba86 | 2017-08-18 15:11:32 -0500 | [diff] [blame] | 610 | log.info('create-mcast-distribution-set', data=data) |
Chip Boling | 2727599 | 2017-09-22 15:17:04 -0500 | [diff] [blame] | 611 | if device.id in self.devices_handlers: |
| 612 | handler = self.devices_handlers[device.id] |
| 613 | if handler is not None: |
| 614 | handler.create_multicast_distribution_set(data) |
Nikolay Titov | 176f1db | 2017-08-10 12:38:43 -0400 | [diff] [blame] | 615 | |
| 616 | def update_multicast_distribution_set(self, device, data): |
Chip Boling | ae29801 | 2017-08-28 08:55:17 -0500 | [diff] [blame] | 617 | """ |
| 618 | API to update multicast distribution rule to specify |
| 619 | the multicast VLANs that ride on the multicast gemport |
| 620 | :param device: device id |
| 621 | :data: multicast distribution data object |
| 622 | :return: None |
| 623 | """ |
Chip Boling | 69fba86 | 2017-08-18 15:11:32 -0500 | [diff] [blame] | 624 | log.info('update-mcast-distribution-set', data=data) |
Chip Boling | 2727599 | 2017-09-22 15:17:04 -0500 | [diff] [blame] | 625 | if device.id in self.devices_handlers: |
| 626 | handler = self.devices_handlers[device.id] |
| 627 | if handler is not None: |
| 628 | handler.create_multicast_distribution_set(data) |
Nikolay Titov | 176f1db | 2017-08-10 12:38:43 -0400 | [diff] [blame] | 629 | |
| 630 | def remove_multicast_distribution_set(self, device, data): |
Chip Boling | ae29801 | 2017-08-28 08:55:17 -0500 | [diff] [blame] | 631 | """ |
| 632 | API to delete multicast distribution rule to specify |
| 633 | the multicast VLANs that ride on the multicast gemport |
| 634 | :param device: device id |
| 635 | :data: multicast distribution data object |
| 636 | :return: None |
| 637 | """ |
Chip Boling | 69fba86 | 2017-08-18 15:11:32 -0500 | [diff] [blame] | 638 | log.info('remove-mcast-distribution-set', data=data) |
Chip Boling | 2727599 | 2017-09-22 15:17:04 -0500 | [diff] [blame] | 639 | if device.id in self.devices_handlers: |
| 640 | handler = self.devices_handlers[device.id] |
| 641 | if handler is not None: |
| 642 | handler.create_multicast_distribution_set(data) |