blob: af0acbf0f99c53de4db8482dd9f7e7eaec5c59de [file] [log] [blame]
Zsolt Haraszti7eeb2b32016-11-06 14:04:55 -08001#
Zsolt Haraszti3eb27a52017-01-03 21:56:48 -08002# Copyright 2017 the original author or authors.
Zsolt Haraszti7eeb2b32016-11-06 14:04:55 -08003#
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"""
18Interface definition for Voltha Adapters
19"""
20from zope.interface import Interface
21
22
23class 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
khenaidoo032d3302017-06-09 14:50:04 -040084 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 Haraszti7eeb2b32016-11-06 14:04:55 -080097 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 Nursimulud068d812017-03-06 11:44:18 -0500105 def disable_device(device):
Zsolt Haraszti7eeb2b32016-11-06 14:04:55 -0800106 """
Khen Nursimulud068d812017-03-06 11:44:18 -0500107 This is called when a previously enabled device needs to be disabled
108 based on a NBI call.
Zsolt Harasztic5c5d102016-12-07 21:12:27 -0800109 :param device: A Voltha.Device object.
Khen Nursimulud068d812017-03-06 11:44:18 -0500110 :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 Fang01f2e852017-06-28 17:24:58 -0700130 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
sathishg5ae86222017-06-28 15:16:29 +0530190 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 Nursimulud068d812017-03-06 11:44:18 -0500197 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 Haraszti7eeb2b32016-11-06 14:04:55 -0800211 """
212
Zsolt Harasztic5c5d102016-12-07 21:12:27 -0800213 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 """
khenaidoof3593a82018-06-01 16:41:31 -0400226 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 Harasztic5c5d102016-12-07 21:12:27 -0800229 :param device: A Voltha.Device object.
khenaidoof3593a82018-06-01 16:41:31 -0400230 :param flow_changes: An openflow_v13.FlowChanges object
231 :param group_changes: An openflow_v13.FlowGroupChanges object
232 :return: (Deferred or None)
Zsolt Harasztic5c5d102016-12-07 21:12:27 -0800233 """
234
Sergio Slobodrianec864c62017-03-09 11:41:43 -0500235 def update_pm_config(device, pm_configs):
Sergio Slobodriana2eb52b2017-03-07 12:24:46 -0500236 """
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 Harasztic5c5d102016-12-07 21:12:27 -0800242 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 Haraszti656ecc62016-12-28 15:08:23 -0800267 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 Shafik9107f2e2017-05-02 15:54:39 -0400277 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 Barbarie980a0912017-05-11 11:27:06 -0400288 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 Nursimulud068d812017-03-06 11:44:18 -0500302 # TODO work in progress
303 # ...
Zsolt Haraszti00d9a842016-11-23 11:18:23 -0800304
Nikolay Titov89004ec2017-06-19 18:22:42 -0400305 # 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 Titov176f1db2017-08-10 12:38:43 -0400310 :param device: device id
311 :data: interface data object
312 :return: None
Nikolay Titov89004ec2017-06-19 18:22:42 -0400313 """
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 Titov176f1db2017-08-10 12:38:43 -0400319 :param device: device id
320 :data: interface data object
321 :return: None
Nikolay Titov89004ec2017-06-19 18:22:42 -0400322 """
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 Titov176f1db2017-08-10 12:38:43 -0400328 :param device: device id
329 :data: interface data object
330 :return: None
Nikolay Titov89004ec2017-06-19 18:22:42 -0400331 """
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 Haraszti00d9a842016-11-23 11:18:23 -0800340
Nikolay Titov176f1db2017-08-10 12:38:43 -0400341
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 Haraszti66862032016-11-28 14:28:39 -0800444class IAdapterAgent(Interface):
Zsolt Haraszti00d9a842016-11-23 11:18:23 -0800445 """
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 Harasztic5c5d102016-12-07 21:12:27 -0800451 def get_device(device_id):
Zsolt Haraszti66862032016-11-28 14:28:39 -0800452 # TODO add doc
453 """"""
454
455 def add_device(device):
456 # TODO add doc
457 """"""
458
459 def update_device(device):
Zsolt Haraszti00d9a842016-11-23 11:18:23 -0800460 # 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 Haraszti66862032016-11-28 14:28:39 -0800475 def child_device_detected(parent_device_id,
Zsolt Harasztic5c5d102016-12-07 21:12:27 -0800476 parent_port_no,
Zsolt Haraszti66862032016-11-28 14:28:39 -0800477 child_device_type,
Zsolt Haraszti89a27302016-12-08 16:53:06 -0800478 proxy_address,
Nikolay Titov89004ec2017-06-19 18:22:42 -0400479 admin_state,
Zsolt Haraszti89a27302016-12-08 16:53:06 -0800480 **kw):
Zsolt Haraszti66862032016-11-28 14:28:39 -0800481 # TODO add doc
482 """"""
483
Zsolt Harasztic5c5d102016-12-07 21:12:27 -0800484 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 Haraszti00d9a842016-11-23 11:18:23 -0800527
Zsolt Haraszti8925d1f2016-12-21 00:45:19 -0800528 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 Haraszti00d9a842016-11-23 11:18:23 -0800537
Zsolt Haraszti749b0952017-01-18 09:02:35 -0800538 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 Barbarie52198b92017-03-02 13:44:46 -0500546
Stephane Barbarie4db8ca22017-04-24 10:30:20 -0400547 def submit_alarm(device_id, alarm_event_msg):
Stephane Barbarie52198b92017-03-02 13:44:46 -0500548 """
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 Titov89004ec2017-06-19 18:22:42 -0400553
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 """