blob: 268754928c9adfdc1d582da26a07d55dc45d26f4 [file] [log] [blame]
Chip Boling67b674a2019-02-08 11:42:18 -06001#
2# Copyright 2018 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"""
18Interface definition for Voltha Adapters
19"""
Zack Williams84a71e92019-11-15 09:00:19 -070020from __future__ import absolute_import
Chip Boling67b674a2019-02-08 11:42:18 -060021from zope.interface import Interface
22
23
24class IAdapterInterface(Interface):
25 """
26 A Voltha adapter. This interface is used by the Voltha Core to initiate
27 requests towards a voltha adapter.
28 """
29
30 def adapter_descriptor():
31 """
32 Return the adapter descriptor object for this adapter.
33 :return: voltha.Adapter grpc object (see voltha/protos/adapter.proto),
34 with adapter-specific information and config extensions.
35 """
36
37 def device_types():
38 """
39 Return list of device types supported by the adapter.
40 :return: voltha.DeviceTypes protobuf object, with optional type
41 specific extensions.
42 """
43
44 def health():
45 """
46 Return a 3-state health status using the voltha.HealthStatus message.
47 :return: Deferred or direct return with voltha.HealthStatus message
48 """
49
50 def adopt_device(device):
51 """
52 Make sure the adapter looks after given device. Called when a device
53 is provisioned top-down and needs to be activated by the adapter.
54 :param device: A voltha.Device object, with possible device-type
55 specific extensions. Such extensions shall be described as part of
56 the device type specification returned by device_types().
57 :return: (Deferred) Shall be fired to acknowledge device ownership.
58 """
59
60 def reconcile_device(device):
61 """
62 Make sure the adapter looks after given device. Called when this
63 device has changed ownership from another Voltha instance to
64 this one (typically, this occurs when the previous voltha
65 instance went down).
66 :param device: A voltha.Device object, with possible device-type
67 specific extensions. Such extensions shall be described as part of
68 the device type specification returned by device_types().
69 :return: (Deferred) Shall be fired to acknowledge device ownership.
70 """
71
72 def abandon_device(device):
73 """
74 Make sur ethe adapter no longer looks after device. This is called
75 if device ownership is taken over by another Voltha instance.
76 :param device: A Voltha.Device object.
77 :return: (Deferred) Shall be fired to acknowledge abandonment.
78 """
79
80 def disable_device(device):
81 """
82 This is called when a previously enabled device needs to be disabled
83 based on a NBI call.
84 :param device: A Voltha.Device object.
85 :return: (Deferred) Shall be fired to acknowledge disabling the device.
86 """
87
88 def reenable_device(device):
89 """
90 This is called when a previously disabled device needs to be enabled
91 based on a NBI call.
92 :param device: A Voltha.Device object.
93 :return: (Deferred) Shall be fired to acknowledge re-enabling the
94 device.
95 """
96
97 def reboot_device(device):
98 """
99 This is called to reboot a device based on a NBI call. The admin
100 state of the device will not change after the reboot
101 :param device: A Voltha.Device object.
102 :return: (Deferred) Shall be fired to acknowledge the reboot.
103 """
104
105 def download_image(device, request):
106 """
107 This is called to request downloading a specified image into
108 the standby partition of a device based on a NBI call.
109 This call is expected to be non-blocking.
110 :param device: A Voltha.Device object.
111 A Voltha.ImageDownload object.
112 :return: (Deferred) Shall be fired to acknowledge the download.
113 """
114
115 def get_image_download_status(device, request):
116 """
117 This is called to inquire about a requested image download
118 status based on a NBI call.
119 The adapter is expected to update the DownloadImage DB object
120 with the query result
121 :param device: A Voltha.Device object.
122 A Voltha.ImageDownload object.
123 :return: (Deferred) Shall be fired to acknowledge
124 """
125
126 def cancel_image_download(device, request):
127 """
128 This is called to cancel a requested image download
129 based on a NBI call. The admin state of the device will not
130 change after the download.
131 :param device: A Voltha.Device object.
132 A Voltha.ImageDownload object.
133 :return: (Deferred) Shall be fired to acknowledge
134 """
135
136 def activate_image_update(device, request):
137 """
138 This is called to activate a downloaded image from
139 a standby partition into active partition.
140 Depending on the device implementation, this call
141 may or may not cause device reboot.
142 If no reboot, then a reboot is required to make the
143 activated image running on device
144 This call is expected to be non-blocking.
145 :param device: A Voltha.Device object.
146 A Voltha.ImageDownload object.
147 :return: (Deferred) OperationResponse object.
148 """
149
150 def revert_image_update(device, request):
151 """
152 This is called to deactivate the specified image at
153 active partition, and revert to previous image at
154 standby partition.
155 Depending on the device implementation, this call
156 may or may not cause device reboot.
157 If no reboot, then a reboot is required to make the
158 previous image running on device
159 This call is expected to be non-blocking.
160 :param device: A Voltha.Device object.
161 A Voltha.ImageDownload object.
162 :return: (Deferred) OperationResponse object.
163 """
164
kesavandd9ef7fe2020-01-29 20:54:13 -0500165 def enable_port(device_id, port):
166 """
167 This is called to enable the specified port.
168
169 Depending on the implementation, this call may or may
170 not cause port enable.
171 This call is expected to be non-blocking.
172 :param device_id: A voltha.Device.id object.
173 :param port: A voltha.Port object
174 """
175
176 def disable_port(device_id, port):
177 """
178 This is called to disable the specified port.
179
180 Depending on the implementation, this call may or may
181 not cause port disable.
182 This call is expected to be non-blocking.
183 :param device_id: A voltha.Device.id object.
184 :param port: A voltha.Port object
185 """
186
Chip Boling67b674a2019-02-08 11:42:18 -0600187 def self_test_device(device):
188 """
189 This is called to Self a device based on a NBI call.
190 :param device: A Voltha.Device object.
191 :return: Will return result of self test
192 """
193
194 def delete_device(device):
195 """
196 This is called to delete a device from the PON based on a NBI call.
197 If the device is an OLT then the whole PON will be deleted.
198 :param device: A Voltha.Device object.
199 :return: (Deferred) Shall be fired to acknowledge the deletion.
200 """
201
202 def get_device_details(device):
203 """
204 This is called to get additional device details based on a NBI call.
205 :param device: A Voltha.Device object.
206 :return: (Deferred) Shall be fired to acknowledge the retrieval of
207 additional details.
208 """
209
210 def update_flows_bulk(device, flows, groups):
211 """
212 Called after any flow table change, but only if the device supports
213 bulk mode, which is expressed by the 'accepts_bulk_flow_update'
214 capability attribute of the device type.
215 :param device: A Voltha.Device object.
216 :param flows: An openflow_v13.Flows object
217 :param groups: An openflow_v13.Flows object
218 :return: (Deferred or None)
219 """
220
221 def update_flows_incrementally(device, flow_changes, group_changes):
222 """
223 Called after a flow table update, but only if the device supports
224 non-bulk mode, which is expressed by the 'accepts_add_remove_flow_updates'
225 capability attribute of the device type.
226 :param device: A Voltha.Device object.
227 :param flow_changes: An openflow_v13.FlowChanges object
228 :param group_changes: An openflow_v13.FlowGroupChanges object
229 :return: (Deferred or None)
230 """
231
232 def update_pm_config(device, pm_configs):
233 """
234 Called every time a request is made to change pm collection behavior
235 :param device: A Voltha.Device object
236 :param pm_collection_config: A Pms
237 """
238
239 def receive_packet_out(device_id, egress_port_no, msg):
240 """
241 Pass a packet_out message content to adapter so that it can forward
242 it out to the device. This is only called on root devices.
243 :param device_id: device ID
244 :param egress_port: egress logical port number
245 :param msg: actual message
246 :return: None
247 """
248
249 def suppress_alarm(filter):
250 """
251 Inform an adapter that all incoming alarms should be suppressed
252 :param filter: A Voltha.AlarmFilter object.
253 :return: (Deferred) Shall be fired to acknowledge the suppression.
254 """
255
256 def unsuppress_alarm(filter):
257 """
258 Inform an adapter that all incoming alarms should resume
259 :param filter: A Voltha.AlarmFilter object.
260 :return: (Deferred) Shall be fired to acknowledge the unsuppression.
261 """
262
263 def get_ofp_device_info(device):
264 """
265 Retrieve the OLT device info. This includes the ofp_desc and
266 ofp_switch_features. The existing ofp structures can be used,
267 or all the attributes get added to the Device definition or a new proto
268 definition gets created. This API will allow the Core to create a
269 LogicalDevice associated with this device (OLT only).
270 :param device: device
271 :return: Proto Message (TBD)
272 """
273
Chip Boling67b674a2019-02-08 11:42:18 -0600274 def process_inter_adapter_message(msg):
275 """
276 Called when the adapter receives a message that was sent to it directly
277 from another adapter. An adapter is automatically registered for these
278 messages when creating the inter-container kafka proxy. Note that it is
279 the responsibility of the sending and receiving adapters to properly encode
280 and decode the message.
281 :param msg: Proto Message (any)
282 :return: Proto Message Response
283 """
284
amit.ghosh1b7b4542020-11-19 09:19:21 +0100285 def single_get_value_request(msg):
286 """
287 Retrive a single type of attribute from a device.
288 :param msg: Proto Message (any)
289 :return: Proto Message Response
290 """
291
292 def single_set_value_request(msg):
293 """
294 Set a single type of attribute of a device.
295 :param msg: Proto Message (any)
296 :return: Proto Message Response
297 """
298
Chip Boling67b674a2019-02-08 11:42:18 -0600299
300class ICoreSouthBoundInterface(Interface):
301 """
302 Represents a Voltha Core. This is used by an adapter to initiate async
303 calls towards Voltha Core.
304 """
305
306 def get_device(device_id):
307 """
308 Retrieve a device using its ID.
309 :param device_id: a device ID
310 :return: Device Object or None
311 """
312
313 def get_child_device(parent_device_id, **kwargs):
314 """
315 Retrieve a child device object belonging to the specified parent
316 device based on some match criteria. The first child device that
317 matches the provided criteria is returned.
318 :param parent_device_id: parent's device protobuf ID
319 :param **kwargs: arbitrary list of match criteria where the Value
320 in each key-value pair must be a protobuf type
321 :return: Child Device Object or None
322 """
323
324 def get_ports(device_id, port_type):
325 """
326 Retrieve all the ports of a given type of a Device.
327 :param device_id: a device ID
328 :param port_type: type of port
329 :return Ports object
330 """
331
332 def get_child_devices(parent_device_id):
333 """
334 Get all child devices given a parent device id
335 :param parent_device_id: The parent device ID
336 :return: Devices object
337 """
338
339 def get_child_device_with_proxy_address(proxy_address):
340 """
341 Get a child device based on its proxy address. Proxy address is
342 defined as {parent id, channel_id}
343 :param proxy_address: A Device.ProxyAddress object
344 :return: Device object or None
345 """
346
347 def device_state_update(device_id,
348 oper_status=None,
349 connect_status=None):
350 """
351 Update a device state.
352 :param device_id: The device ID
353 :param oper_state: Operational state of device
354 :param conn_state: Connection state of device
355 :return: None
356 """
357
358 def child_device_detected(parent_device_id,
359 parent_port_no,
360 child_device_type,
361 channel_id,
362 **kw):
363 """
364 A child device has been detected. Core will create the device along
365 with its unique ID.
366 :param parent_device_id: The parent device ID
367 :param parent_port_no: The parent port number
368 :param device_type: The child device type
369 :param channel_id: A unique identifier for that child device within
370 the parent device (e.g. vlan_id)
371 :param kw: A list of key-value pair where the value is a protobuf
372 message
373 :return: None
374 """
375
376 def device_update(device):
377 """
378 Event corresponding to a device update.
379 :param device: Device Object
380 :return: None
381 """
382
383 def child_device_removed(parent_device_id, child_device_id):
384 """
385 Event indicating a child device has been removed from a parent.
386 :param parent_device_id: Device ID of the parent
387 :param child_device_id: Device ID of the child
388 :return: None
389 """
390
391 def child_devices_state_update(parent_device_id,
392 oper_status=None,
393 connect_status=None,
394 admin_status=None):
395 """
396 Event indicating the status of all child devices have been changed.
397 :param parent_device_id: Device ID of the parent
398 :param oper_status: Operational status
399 :param connect_status: Connection status
400 :param admin_status: Admin status
401 :return: None
402 """
403
404 def child_devices_removed(parent_device_id):
405 """
406 Event indicating all child devices have been removed from a parent.
407 :param parent_device_id: Device ID of the parent device
408 :return: None
409 """
410
411 def device_pm_config_update(device_pm_config, init=False):
412 """
413 Event corresponding to a PM config update of a device.
414 :param device_pm_config: a PmConfigs object
415 :param init: True indicates initializing stage
416 :return: None
417 """
418
419 def port_created(device_id, port):
420 """
421 A port has been created and needs to be added to a device.
422 :param device_id: a device ID
423 :param port: Port object
424 :return None
425 """
426
427 def port_removed(device_id, port):
428 """
429 A port has been removed and it needs to be removed from a Device.
430 :param device_id: a device ID
431 :param port: a Port object
432 :return None
433 """
434
435 def ports_enabled(device_id):
436 """
437 All ports on that device have been re-enabled. The Core will change
438 the admin state to ENABLED and operational state to ACTIVE for all
439 ports on that device.
440 :param device_id: a device ID
441 :return: None
442 """
443
444 def ports_disabled(device_id):
445 """
446 All ports on that device have been disabled. The Core will change the
447 admin status to DISABLED and operational state to UNKNOWN for all
448 ports on that device.
449 :param device_id: a device ID
450 :return: None
451 """
452
453 def ports_oper_status_update(device_id, oper_status):
454 """
455 The operational status of all ports of a Device has been changed.
456 The Core will update the operational status for all ports on the
457 device.
458 :param device_id: a device ID
459 :param oper_status: operational Status
460 :return None
461 """
462
463 def image_download_update(img_dnld):
464 """
465 Event corresponding to an image download update.
466 :param img_dnld: a ImageDownload object
467 :return: None
468 """
469
470 def image_download_deleted(img_dnld):
471 """
472 Event corresponding to the deletion of a downloaded image. The
473 references of this image needs to be removed from the Core.
474 :param img_dnld: a ImageDownload object
475 :return: None
476 """
477
478 def packet_in(device_id, egress_port_no, packet):
479 """
480 Sends a packet to the SDN controller via voltha Core
481 :param device_id: The OLT device ID
482 :param egress_port_no: The port number representing the ONU (cvid)
483 :param packet: The actual packet
484 :return: None
485 """