Zsolt Haraszti | 7eeb2b3 | 2016-11-06 14:04:55 -0800 | [diff] [blame] | 1 | # |
Zsolt Haraszti | 3eb27a5 | 2017-01-03 21:56:48 -0800 | [diff] [blame] | 2 | # Copyright 2017 the original author or authors. |
Zsolt Haraszti | 7eeb2b3 | 2016-11-06 14:04:55 -0800 | [diff] [blame] | 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 | Interface definition for Voltha Adapters |
| 19 | """ |
| 20 | from zope.interface import Interface |
| 21 | |
| 22 | |
| 23 | class IAdapterInterface(Interface): |
| 24 | """ |
| 25 | A Voltha adapter |
| 26 | """ |
| 27 | |
| 28 | def start(): |
| 29 | """ |
| 30 | Called once after adapter instance is laoded. Can be used to async |
| 31 | initialization. |
| 32 | :return: (None or Deferred) |
| 33 | """ |
| 34 | |
| 35 | def stop(): |
| 36 | """ |
| 37 | Called once before adapter is unloaded. It can be used to perform |
| 38 | any cleanup after the adapter. |
| 39 | :return: (None or Deferred) |
| 40 | """ |
| 41 | |
| 42 | def adapter_descriptor(): |
| 43 | """ |
| 44 | Return the adapter descriptor object for this adapter. |
| 45 | :return: voltha.Adapter grpc object (see voltha/protos/adapter.proto), |
| 46 | with adapter-specific information and config extensions. |
| 47 | """ |
| 48 | |
| 49 | def device_types(): |
| 50 | """ |
| 51 | Return list of device types supported by the adapter. |
| 52 | :return: voltha.DeviceTypes protobuf object, with optional type |
| 53 | specific extensions. |
| 54 | """ |
| 55 | |
| 56 | def health(): |
| 57 | """ |
| 58 | Return a 3-state health status using the voltha.HealthStatus message. |
| 59 | :return: Deferred or direct return with voltha.HealthStatus message |
| 60 | """ |
| 61 | |
| 62 | def change_master_state(master): |
| 63 | """ |
| 64 | Called to indicate if plugin shall assume or lose master role. The |
| 65 | master role can be used to perform functions that must be performed |
| 66 | from a single point in the cluster. In single-node deployments of |
| 67 | Voltha, the plugins are always in master role. |
| 68 | :param master: (bool) True to indicate the mastership needs to be |
| 69 | assumed; False to indicate that mastership needs to be abandoned. |
| 70 | :return: (Deferred) which is fired by the adapter when mastership is |
| 71 | assumed/dropped, respectively. |
| 72 | """ |
| 73 | |
| 74 | def adopt_device(device): |
| 75 | """ |
| 76 | Make sure the adapter looks after given device. Called when a device |
| 77 | is provisioned top-down and needs to be activated by the adapter. |
| 78 | :param device: A voltha.Device object, with possible device-type |
| 79 | specific extensions. Such extensions shall be described as part of |
| 80 | the device type specification returned by device_types(). |
| 81 | :return: (Deferred) Shall be fired to acknowledge device ownership. |
| 82 | """ |
| 83 | |
khenaidoo | 032d330 | 2017-06-09 14:50:04 -0400 | [diff] [blame] | 84 | def reconcile_device(device): |
| 85 | """ |
| 86 | Make sure the adapter looks after given device. Called when this |
| 87 | device has changed ownership from another Voltha instance to |
| 88 | this one (typically, this occurs when the previous voltha |
| 89 | instance went down). |
| 90 | :param device: A voltha.Device object, with possible device-type |
| 91 | specific extensions. Such extensions shall be described as part of |
| 92 | the device type specification returned by device_types(). |
| 93 | :return: (Deferred) Shall be fired to acknowledge device ownership. |
| 94 | """ |
| 95 | |
| 96 | |
Zsolt Haraszti | 7eeb2b3 | 2016-11-06 14:04:55 -0800 | [diff] [blame] | 97 | def abandon_device(device): |
| 98 | """ |
| 99 | Make sur ethe adapter no longer looks after device. This is called |
| 100 | if device ownership is taken over by another Voltha instance. |
| 101 | :param device: A Voltha.Device object. |
| 102 | :return: (Deferred) Shall be fired to acknowledge abandonment. |
| 103 | """ |
| 104 | |
Khen Nursimulu | d068d81 | 2017-03-06 11:44:18 -0500 | [diff] [blame] | 105 | def disable_device(device): |
Zsolt Haraszti | 7eeb2b3 | 2016-11-06 14:04:55 -0800 | [diff] [blame] | 106 | """ |
Khen Nursimulu | d068d81 | 2017-03-06 11:44:18 -0500 | [diff] [blame] | 107 | This is called when a previously enabled device needs to be disabled |
| 108 | based on a NBI call. |
Zsolt Haraszti | c5c5d10 | 2016-12-07 21:12:27 -0800 | [diff] [blame] | 109 | :param device: A Voltha.Device object. |
Khen Nursimulu | d068d81 | 2017-03-06 11:44:18 -0500 | [diff] [blame] | 110 | :return: (Deferred) Shall be fired to acknowledge disabling the device. |
| 111 | """ |
| 112 | |
| 113 | def reenable_device(device): |
| 114 | """ |
| 115 | This is called when a previously disabled device needs to be enabled |
| 116 | based on a NBI call. |
| 117 | :param device: A Voltha.Device object. |
| 118 | :return: (Deferred) Shall be fired to acknowledge re-enabling the |
| 119 | device. |
| 120 | """ |
| 121 | |
| 122 | def reboot_device(device): |
| 123 | """ |
| 124 | This is called to reboot a device based on a NBI call. The admin |
| 125 | state of the device will not change after the reboot |
| 126 | :param device: A Voltha.Device object. |
| 127 | :return: (Deferred) Shall be fired to acknowledge the reboot. |
| 128 | """ |
| 129 | |
Lydia Fang | 01f2e85 | 2017-06-28 17:24:58 -0700 | [diff] [blame] | 130 | def download_image(device, request): |
| 131 | """ |
| 132 | This is called to request downloading a specified image into |
| 133 | the standby partition of a device based on a NBI call. |
| 134 | This call is expected to be non-blocking. |
| 135 | :param device: A Voltha.Device object. |
| 136 | A Voltha.ImageDownload object. |
| 137 | :return: (Deferred) Shall be fired to acknowledge the download. |
| 138 | """ |
| 139 | |
| 140 | def get_image_download_status(device, request): |
| 141 | """ |
| 142 | This is called to inquire about a requested image download |
| 143 | status based on a NBI call. |
| 144 | The adapter is expected to update the DownloadImage DB object |
| 145 | with the query result |
| 146 | :param device: A Voltha.Device object. |
| 147 | A Voltha.ImageDownload object. |
| 148 | :return: (Deferred) Shall be fired to acknowledge |
| 149 | """ |
| 150 | |
| 151 | def cancel_image_download(device, request): |
| 152 | """ |
| 153 | This is called to cancel a requested image download |
| 154 | based on a NBI call. The admin state of the device will not |
| 155 | change after the download. |
| 156 | :param device: A Voltha.Device object. |
| 157 | A Voltha.ImageDownload object. |
| 158 | :return: (Deferred) Shall be fired to acknowledge |
| 159 | """ |
| 160 | |
| 161 | def activate_image_update(device, request): |
| 162 | """ |
| 163 | This is called to activate a downloaded image from |
| 164 | a standby partition into active partition. |
| 165 | Depending on the device implementation, this call |
| 166 | may or may not cause device reboot. |
| 167 | If no reboot, then a reboot is required to make the |
| 168 | activated image running on device |
| 169 | This call is expected to be non-blocking. |
| 170 | :param device: A Voltha.Device object. |
| 171 | A Voltha.ImageDownload object. |
| 172 | :return: (Deferred) OperationResponse object. |
| 173 | """ |
| 174 | |
| 175 | def revert_image_update(device, request): |
| 176 | """ |
| 177 | This is called to deactivate the specified image at |
| 178 | active partition, and revert to previous image at |
| 179 | standby partition. |
| 180 | Depending on the device implementation, this call |
| 181 | may or may not cause device reboot. |
| 182 | If no reboot, then a reboot is required to make the |
| 183 | previous image running on device |
| 184 | This call is expected to be non-blocking. |
| 185 | :param device: A Voltha.Device object. |
| 186 | A Voltha.ImageDownload object. |
| 187 | :return: (Deferred) OperationResponse object. |
| 188 | """ |
| 189 | |
sathishg | 5ae8622 | 2017-06-28 15:16:29 +0530 | [diff] [blame] | 190 | def self_test_device(device): |
| 191 | """ |
| 192 | This is called to Self a device based on a NBI call. |
| 193 | :param device: A Voltha.Device object. |
| 194 | :return: Will return result of self test |
| 195 | """ |
| 196 | |
Khen Nursimulu | d068d81 | 2017-03-06 11:44:18 -0500 | [diff] [blame] | 197 | def delete_device(device): |
| 198 | """ |
| 199 | This is called to delete a device from the PON based on a NBI call. |
| 200 | If the device is an OLT then the whole PON will be deleted. |
| 201 | :param device: A Voltha.Device object. |
| 202 | :return: (Deferred) Shall be fired to acknowledge the deletion. |
| 203 | """ |
| 204 | |
| 205 | def get_device_details(device): |
| 206 | """ |
| 207 | This is called to get additional device details based on a NBI call. |
| 208 | :param device: A Voltha.Device object. |
| 209 | :return: (Deferred) Shall be fired to acknowledge the retrieval of |
| 210 | additional details. |
Zsolt Haraszti | 7eeb2b3 | 2016-11-06 14:04:55 -0800 | [diff] [blame] | 211 | """ |
| 212 | |
Zsolt Haraszti | c5c5d10 | 2016-12-07 21:12:27 -0800 | [diff] [blame] | 213 | def update_flows_bulk(device, flows, groups): |
| 214 | """ |
| 215 | Called after any flow table change, but only if the device supports |
| 216 | bulk mode, which is expressed by the 'accepts_bulk_flow_update' |
| 217 | capability attribute of the device type. |
| 218 | :param device: A Voltha.Device object. |
| 219 | :param flows: An openflow_v13.Flows object |
| 220 | :param groups: An openflow_v13.Flows object |
| 221 | :return: (Deferred or None) |
| 222 | """ |
| 223 | |
| 224 | def update_flows_incrementally(device, flow_changes, group_changes): |
| 225 | """ |
khenaidoo | f3593a8 | 2018-06-01 16:41:31 -0400 | [diff] [blame^] | 226 | Called after a flow table update, but only if the device supports |
| 227 | non-bulk mode, which is expressed by the 'accepts_add_remove_flow_updates' |
| 228 | capability attribute of the device type. |
Zsolt Haraszti | c5c5d10 | 2016-12-07 21:12:27 -0800 | [diff] [blame] | 229 | :param device: A Voltha.Device object. |
khenaidoo | f3593a8 | 2018-06-01 16:41:31 -0400 | [diff] [blame^] | 230 | :param flow_changes: An openflow_v13.FlowChanges object |
| 231 | :param group_changes: An openflow_v13.FlowGroupChanges object |
| 232 | :return: (Deferred or None) |
Zsolt Haraszti | c5c5d10 | 2016-12-07 21:12:27 -0800 | [diff] [blame] | 233 | """ |
| 234 | |
Sergio Slobodrian | ec864c6 | 2017-03-09 11:41:43 -0500 | [diff] [blame] | 235 | def update_pm_config(device, pm_configs): |
Sergio Slobodrian | a2eb52b | 2017-03-07 12:24:46 -0500 | [diff] [blame] | 236 | """ |
| 237 | Called every time a request is made to change pm collection behavior |
| 238 | :param device: A Voltha.Device object |
| 239 | :param pm_collection_config: A Pms |
| 240 | """ |
| 241 | |
Zsolt Haraszti | c5c5d10 | 2016-12-07 21:12:27 -0800 | [diff] [blame] | 242 | def send_proxied_message(proxy_address, msg): |
| 243 | """ |
| 244 | Forward a msg to a child device of device, addressed by the given |
| 245 | proxy_address=Device.ProxyAddress(). |
| 246 | :param proxy_address: Address info for the parent device |
| 247 | to route the message to the child device. This was given to the |
| 248 | child device by the parent device at the creation of the child |
| 249 | device. |
| 250 | :param msg: (str) The actual message to send. |
| 251 | :return: (Deferred(None) or None) The return of this method should |
| 252 | indicate that the message was successfully *sent*. |
| 253 | """ |
| 254 | |
| 255 | def receive_proxied_message(proxy_address, msg): |
| 256 | """ |
| 257 | Pass an async message (arrived via a proxy) to this device. |
| 258 | :param proxy_address: Address info for the parent device |
| 259 | to route the message to the child device. This was given to the |
| 260 | child device by the parent device at the creation of the child |
| 261 | device. Note this is the proxy_address with which the adapter |
| 262 | had to register prior to receiving proxied messages. |
| 263 | :param msg: (str) The actual message received. |
| 264 | :return: None |
| 265 | """ |
| 266 | |
Zsolt Haraszti | 656ecc6 | 2016-12-28 15:08:23 -0800 | [diff] [blame] | 267 | def receive_packet_out(logical_device_id, egress_port_no, msg): |
| 268 | """ |
| 269 | Pass a packet_out message content to adapter so that it can forward it |
| 270 | out to the device. This is only called on root devices. |
| 271 | :param logical_device_id: |
| 272 | :param egress_port: egress logical port number |
| 273 | :param msg: actual message |
| 274 | :return: None |
| 275 | """ |
| 276 | |
Peter Shafik | 9107f2e | 2017-05-02 15:54:39 -0400 | [diff] [blame] | 277 | def receive_inter_adapter_message(msg): |
| 278 | """ |
| 279 | Called when the adapter recieves a message that was sent to it directly |
| 280 | from another adapter. An adapter may register for these messages by calling |
| 281 | the register_for_inter_adapter_messages() method in the adapter agent. |
| 282 | Note that it is the responsibility of the sending and receiving |
| 283 | adapters to properly encode and decode the message. |
| 284 | :param msg: The message contents. |
| 285 | :return: None |
| 286 | """ |
| 287 | |
Stephane Barbarie | 980a091 | 2017-05-11 11:27:06 -0400 | [diff] [blame] | 288 | def suppress_alarm(filter): |
| 289 | """ |
| 290 | Inform an adapter that all incoming alarms should be suppressed |
| 291 | :param filter: A Voltha.AlarmFilter object. |
| 292 | :return: (Deferred) Shall be fired to acknowledge the suppression. |
| 293 | """ |
| 294 | |
| 295 | def unsuppress_alarm(filter): |
| 296 | """ |
| 297 | Inform an adapter that all incoming alarms should resume |
| 298 | :param filter: A Voltha.AlarmFilter object. |
| 299 | :return: (Deferred) Shall be fired to acknowledge the unsuppression. |
| 300 | """ |
| 301 | |
Khen Nursimulu | d068d81 | 2017-03-06 11:44:18 -0500 | [diff] [blame] | 302 | # TODO work in progress |
| 303 | # ... |
Zsolt Haraszti | 00d9a84 | 2016-11-23 11:18:23 -0800 | [diff] [blame] | 304 | |
Nikolay Titov | 89004ec | 2017-06-19 18:22:42 -0400 | [diff] [blame] | 305 | # PON Mgnt APIs # |
| 306 | def create_interface(device, data): |
| 307 | """ |
| 308 | API to create various interfaces (only some PON interfaces as of now) |
| 309 | in the devices |
Nikolay Titov | 176f1db | 2017-08-10 12:38:43 -0400 | [diff] [blame] | 310 | :param device: device id |
| 311 | :data: interface data object |
| 312 | :return: None |
Nikolay Titov | 89004ec | 2017-06-19 18:22:42 -0400 | [diff] [blame] | 313 | """ |
| 314 | |
| 315 | def update_interface(device, data): |
| 316 | """ |
| 317 | API to update various interfaces (only some PON interfaces as of now) |
| 318 | in the devices |
Nikolay Titov | 176f1db | 2017-08-10 12:38:43 -0400 | [diff] [blame] | 319 | :param device: device id |
| 320 | :data: interface data object |
| 321 | :return: None |
Nikolay Titov | 89004ec | 2017-06-19 18:22:42 -0400 | [diff] [blame] | 322 | """ |
| 323 | |
| 324 | def remove_interface(device, data): |
| 325 | """ |
| 326 | API to delete various interfaces (only some PON interfaces as of now) |
| 327 | in the devices |
Nikolay Titov | 176f1db | 2017-08-10 12:38:43 -0400 | [diff] [blame] | 328 | :param device: device id |
| 329 | :data: interface data object |
| 330 | :return: None |
Nikolay Titov | 89004ec | 2017-06-19 18:22:42 -0400 | [diff] [blame] | 331 | """ |
| 332 | |
| 333 | def receive_onu_detect_state(proxy_address, state): |
| 334 | """ |
| 335 | Receive onu detect state in ONU adapter |
| 336 | :param proxy_address: ONU device address |
| 337 | :param state: ONU detect state (bool) |
| 338 | :return: None |
| 339 | """ |
Zsolt Haraszti | 00d9a84 | 2016-11-23 11:18:23 -0800 | [diff] [blame] | 340 | |
Nikolay Titov | 176f1db | 2017-08-10 12:38:43 -0400 | [diff] [blame] | 341 | |
| 342 | def create_tcont(device, tcont_data, traffic_descriptor_data): |
| 343 | """ |
| 344 | API to create tcont object in the devices |
| 345 | :param device: device id |
| 346 | :tcont_data: tcont data object |
| 347 | :traffic_descriptor_data: traffic descriptor data object |
| 348 | :return: None |
| 349 | """ |
| 350 | |
| 351 | def update_tcont(device, tcont_data, traffic_descriptor_data): |
| 352 | """ |
| 353 | API to update tcont object in the devices |
| 354 | :param device: device id |
| 355 | :tcont_data: tcont data object |
| 356 | :traffic_descriptor_data: traffic descriptor data object |
| 357 | :return: None |
| 358 | """ |
| 359 | |
| 360 | def remove_tcont(device, tcont_data, traffic_descriptor_data): |
| 361 | """ |
| 362 | API to delete tcont object in the devices |
| 363 | :param device: device id |
| 364 | :tcont_data: tcont data object |
| 365 | :traffic_descriptor_data: traffic descriptor data object |
| 366 | :return: None |
| 367 | """ |
| 368 | |
| 369 | def create_gemport(device, data): |
| 370 | """ |
| 371 | API to create gemport object in the devices |
| 372 | :param device: device id |
| 373 | :data: gemport data object |
| 374 | :return: None |
| 375 | """ |
| 376 | |
| 377 | def update_gemport(device, data): |
| 378 | """ |
| 379 | API to update gemport object in the devices |
| 380 | :param device: device id |
| 381 | :data: gemport data object |
| 382 | :return: None |
| 383 | """ |
| 384 | |
| 385 | def remove_gemport(device, data): |
| 386 | """ |
| 387 | API to delete gemport object in the devices |
| 388 | :param device: device id |
| 389 | :data: gemport data object |
| 390 | :return: None |
| 391 | """ |
| 392 | |
| 393 | def create_multicast_gemport(device, data): |
| 394 | """ |
| 395 | API to create multicast gemport object in the devices |
| 396 | :param device: device id |
| 397 | :data: multicast gemport data object |
| 398 | :return: None |
| 399 | """ |
| 400 | |
| 401 | def update_multicast_gemport(device, data): |
| 402 | """ |
| 403 | API to update multicast gemport object in the devices |
| 404 | :param device: device id |
| 405 | :data: multicast gemport data object |
| 406 | :return: None |
| 407 | """ |
| 408 | |
| 409 | def remove_multicast_gemport(device, data): |
| 410 | """ |
| 411 | API to delete multicast gemport object in the devices |
| 412 | :param device: device id |
| 413 | :data: multicast gemport data object |
| 414 | :return: None |
| 415 | """ |
| 416 | |
| 417 | def create_multicast_distribution_set(device, data): |
| 418 | """ |
| 419 | API to create multicast distribution rule to specify |
| 420 | the multicast VLANs that ride on the multicast gemport |
| 421 | :param device: device id |
| 422 | :data: multicast distribution data object |
| 423 | :return: None |
| 424 | """ |
| 425 | |
| 426 | def update_multicast_distribution_set(device, data): |
| 427 | """ |
| 428 | API to update multicast distribution rule to specify |
| 429 | the multicast VLANs that ride on the multicast gemport |
| 430 | :param device: device id |
| 431 | :data: multicast distribution data object |
| 432 | :return: None |
| 433 | """ |
| 434 | |
| 435 | def remove_multicast_distribution_set(device, data): |
| 436 | """ |
| 437 | API to delete multicast distribution rule to specify |
| 438 | the multicast VLANs that ride on the multicast gemport |
| 439 | :param device: device id |
| 440 | :data: multicast distribution data object |
| 441 | :return: None |
| 442 | """ |
| 443 | |
Zsolt Haraszti | 6686203 | 2016-11-28 14:28:39 -0800 | [diff] [blame] | 444 | class IAdapterAgent(Interface): |
Zsolt Haraszti | 00d9a84 | 2016-11-23 11:18:23 -0800 | [diff] [blame] | 445 | """ |
| 446 | This object is passed in to the __init__ function of each adapter, |
| 447 | and can be used by the adapter implementation to initiate async calls |
| 448 | toward Voltha's CORE via the APIs defined here. |
| 449 | """ |
| 450 | |
Zsolt Haraszti | c5c5d10 | 2016-12-07 21:12:27 -0800 | [diff] [blame] | 451 | def get_device(device_id): |
Zsolt Haraszti | 6686203 | 2016-11-28 14:28:39 -0800 | [diff] [blame] | 452 | # TODO add doc |
| 453 | """""" |
| 454 | |
| 455 | def add_device(device): |
| 456 | # TODO add doc |
| 457 | """""" |
| 458 | |
| 459 | def update_device(device): |
Zsolt Haraszti | 00d9a84 | 2016-11-23 11:18:23 -0800 | [diff] [blame] | 460 | # TODO add doc |
| 461 | """""" |
| 462 | |
| 463 | def add_port(device_id, port): |
| 464 | # TODO add doc |
| 465 | """""" |
| 466 | |
| 467 | def create_logical_device(logical_device): |
| 468 | # TODO add doc |
| 469 | """""" |
| 470 | |
| 471 | def add_logical_port(logical_device_id, port): |
| 472 | # TODO add doc |
| 473 | """""" |
| 474 | |
Zsolt Haraszti | 6686203 | 2016-11-28 14:28:39 -0800 | [diff] [blame] | 475 | def child_device_detected(parent_device_id, |
Zsolt Haraszti | c5c5d10 | 2016-12-07 21:12:27 -0800 | [diff] [blame] | 476 | parent_port_no, |
Zsolt Haraszti | 6686203 | 2016-11-28 14:28:39 -0800 | [diff] [blame] | 477 | child_device_type, |
Zsolt Haraszti | 89a2730 | 2016-12-08 16:53:06 -0800 | [diff] [blame] | 478 | proxy_address, |
Nikolay Titov | 89004ec | 2017-06-19 18:22:42 -0400 | [diff] [blame] | 479 | admin_state, |
Zsolt Haraszti | 89a2730 | 2016-12-08 16:53:06 -0800 | [diff] [blame] | 480 | **kw): |
Zsolt Haraszti | 6686203 | 2016-11-28 14:28:39 -0800 | [diff] [blame] | 481 | # TODO add doc |
| 482 | """""" |
| 483 | |
Zsolt Haraszti | c5c5d10 | 2016-12-07 21:12:27 -0800 | [diff] [blame] | 484 | def send_proxied_message(proxy_address, msg): |
| 485 | """ |
| 486 | Forward a msg to a child device of device, addressed by the given |
| 487 | proxy_address=Device.ProxyAddress(). |
| 488 | :param proxy_address: Address info for the parent device |
| 489 | to route the message to the child device. This was given to the |
| 490 | child device by the parent device at the creation of the child |
| 491 | device. |
| 492 | :param msg: (str) The actual message to send. |
| 493 | :return: (Deferred(None) or None) The return of this method should |
| 494 | indicate that the message was successfully *sent*. |
| 495 | """ |
| 496 | |
| 497 | def receive_proxied_message(proxy_address, msg): |
| 498 | """ |
| 499 | Pass an async message (arrived via a proxy) to this device. |
| 500 | :param proxy_address: Address info for the parent device |
| 501 | to route the message to the child device. This was given to the |
| 502 | child device by the parent device at the creation of the child |
| 503 | device. Note this is the proxy_address with which the adapter |
| 504 | had to register prior to receiving proxied messages. |
| 505 | :param msg: (str) The actual message received. |
| 506 | :return: None |
| 507 | """ |
| 508 | |
| 509 | def register_for_proxied_messages(proxy_address): |
| 510 | """ |
| 511 | A child device adapter can use this to indicate its intent to |
| 512 | receive async messages sent via a parent device. Example: an |
| 513 | ONU adapter can use this to register for OMCI messages received |
| 514 | via the OLT and the OLT adapter. |
| 515 | :param child_device_address: Address info that was given to the |
| 516 | child device by the parent device at the creation of the child |
| 517 | device. Its uniqueness acts as a router information for the |
| 518 | registration. |
| 519 | :return: None |
| 520 | """ |
| 521 | |
| 522 | def unregister_for_proxied_messages(proxy_address): |
| 523 | """ |
| 524 | Cancel a previous registration |
| 525 | :return: |
| 526 | """ |
Zsolt Haraszti | 00d9a84 | 2016-11-23 11:18:23 -0800 | [diff] [blame] | 527 | |
Zsolt Haraszti | 8925d1f | 2016-12-21 00:45:19 -0800 | [diff] [blame] | 528 | def send_packet_in(logical_device_id, logical_port_no, packet): |
| 529 | """ |
| 530 | Forward given packet to the northbound toward an SDN controller. |
| 531 | :param device_id: logical device identifier |
| 532 | :param logical_port_no: logical port_no (as numbered in openflow) |
| 533 | :param packet: the actual packet; can be a serialized string or a scapy |
| 534 | Packet. |
| 535 | :return: None returned on success |
| 536 | """ |
Zsolt Haraszti | 00d9a84 | 2016-11-23 11:18:23 -0800 | [diff] [blame] | 537 | |
Zsolt Haraszti | 749b095 | 2017-01-18 09:02:35 -0800 | [diff] [blame] | 538 | def submit_kpis(kpi_event_msg): |
| 539 | """ |
| 540 | Submit KPI metrics on behalf of the OLT and its adapter. This can |
| 541 | include hardware related metrics, usage and utilization metrics, as |
| 542 | well as optional adapter specific metrics. |
| 543 | :param kpi_event_msg: A protobuf message of KpiEvent type. |
| 544 | :return: None |
| 545 | """ |
Stephane Barbarie | 52198b9 | 2017-03-02 13:44:46 -0500 | [diff] [blame] | 546 | |
Stephane Barbarie | 4db8ca2 | 2017-04-24 10:30:20 -0400 | [diff] [blame] | 547 | def submit_alarm(device_id, alarm_event_msg): |
Stephane Barbarie | 52198b9 | 2017-03-02 13:44:46 -0500 | [diff] [blame] | 548 | """ |
| 549 | Submit an alarm on behalf of the OLT and its adapter. |
| 550 | :param alarm_event_msg: A protobuf message of AlarmEvent type. |
| 551 | :return: None |
| 552 | """ |
Nikolay Titov | 89004ec | 2017-06-19 18:22:42 -0400 | [diff] [blame] | 553 | |
| 554 | def register_for_onu_detect_state(proxy_address): |
| 555 | """ |
| 556 | |
| 557 | :return: None |
| 558 | """ |
| 559 | |
| 560 | def unregister_for_onu_detect_state(proxy_address): |
| 561 | """ |
| 562 | |
| 563 | :return: None |
| 564 | """ |
| 565 | |
| 566 | def forward_onu_detect_state(proxy_address, state): |
| 567 | """ |
| 568 | Forward onu detect state to ONU adapter |
| 569 | :param proxy_address: ONU device address |
| 570 | :param state: ONU detect state (bool) |
| 571 | :return: None |
| 572 | """ |