blob: e7ba52e0b661a16e1f774d1807cf68a709eae5ee [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
165 def self_test_device(device):
166 """
167 This is called to Self a device based on a NBI call.
168 :param device: A Voltha.Device object.
169 :return: Will return result of self test
170 """
171
172 def delete_device(device):
173 """
174 This is called to delete a device from the PON based on a NBI call.
175 If the device is an OLT then the whole PON will be deleted.
176 :param device: A Voltha.Device object.
177 :return: (Deferred) Shall be fired to acknowledge the deletion.
178 """
179
180 def get_device_details(device):
181 """
182 This is called to get additional device details based on a NBI call.
183 :param device: A Voltha.Device object.
184 :return: (Deferred) Shall be fired to acknowledge the retrieval of
185 additional details.
186 """
187
188 def update_flows_bulk(device, flows, groups):
189 """
190 Called after any flow table change, but only if the device supports
191 bulk mode, which is expressed by the 'accepts_bulk_flow_update'
192 capability attribute of the device type.
193 :param device: A Voltha.Device object.
194 :param flows: An openflow_v13.Flows object
195 :param groups: An openflow_v13.Flows object
196 :return: (Deferred or None)
197 """
198
199 def update_flows_incrementally(device, flow_changes, group_changes):
200 """
201 Called after a flow table update, but only if the device supports
202 non-bulk mode, which is expressed by the 'accepts_add_remove_flow_updates'
203 capability attribute of the device type.
204 :param device: A Voltha.Device object.
205 :param flow_changes: An openflow_v13.FlowChanges object
206 :param group_changes: An openflow_v13.FlowGroupChanges object
207 :return: (Deferred or None)
208 """
209
210 def update_pm_config(device, pm_configs):
211 """
212 Called every time a request is made to change pm collection behavior
213 :param device: A Voltha.Device object
214 :param pm_collection_config: A Pms
215 """
216
217 def receive_packet_out(device_id, egress_port_no, msg):
218 """
219 Pass a packet_out message content to adapter so that it can forward
220 it out to the device. This is only called on root devices.
221 :param device_id: device ID
222 :param egress_port: egress logical port number
223 :param msg: actual message
224 :return: None
225 """
226
227 def suppress_alarm(filter):
228 """
229 Inform an adapter that all incoming alarms should be suppressed
230 :param filter: A Voltha.AlarmFilter object.
231 :return: (Deferred) Shall be fired to acknowledge the suppression.
232 """
233
234 def unsuppress_alarm(filter):
235 """
236 Inform an adapter that all incoming alarms should resume
237 :param filter: A Voltha.AlarmFilter object.
238 :return: (Deferred) Shall be fired to acknowledge the unsuppression.
239 """
240
241 def get_ofp_device_info(device):
242 """
243 Retrieve the OLT device info. This includes the ofp_desc and
244 ofp_switch_features. The existing ofp structures can be used,
245 or all the attributes get added to the Device definition or a new proto
246 definition gets created. This API will allow the Core to create a
247 LogicalDevice associated with this device (OLT only).
248 :param device: device
249 :return: Proto Message (TBD)
250 """
251
252 def get_ofp_port_info(device, port_no):
253 """
254 Retrieve the port info. This includes the ofp_port. The existing ofp
255 structure can be used, or all the attributes get added to the Port
256 definitions or a new proto definition gets created. This API will allow
257 the Core to create a LogicalPort associated with this device.
258 :param device: device
259 :param port_no: port number
260 :return: Proto Message (TBD)
261 """
262
263 def process_inter_adapter_message(msg):
264 """
265 Called when the adapter receives a message that was sent to it directly
266 from another adapter. An adapter is automatically registered for these
267 messages when creating the inter-container kafka proxy. Note that it is
268 the responsibility of the sending and receiving adapters to properly encode
269 and decode the message.
270 :param msg: Proto Message (any)
271 :return: Proto Message Response
272 """
273
274
275class ICoreSouthBoundInterface(Interface):
276 """
277 Represents a Voltha Core. This is used by an adapter to initiate async
278 calls towards Voltha Core.
279 """
280
281 def get_device(device_id):
282 """
283 Retrieve a device using its ID.
284 :param device_id: a device ID
285 :return: Device Object or None
286 """
287
288 def get_child_device(parent_device_id, **kwargs):
289 """
290 Retrieve a child device object belonging to the specified parent
291 device based on some match criteria. The first child device that
292 matches the provided criteria is returned.
293 :param parent_device_id: parent's device protobuf ID
294 :param **kwargs: arbitrary list of match criteria where the Value
295 in each key-value pair must be a protobuf type
296 :return: Child Device Object or None
297 """
298
299 def get_ports(device_id, port_type):
300 """
301 Retrieve all the ports of a given type of a Device.
302 :param device_id: a device ID
303 :param port_type: type of port
304 :return Ports object
305 """
306
307 def get_child_devices(parent_device_id):
308 """
309 Get all child devices given a parent device id
310 :param parent_device_id: The parent device ID
311 :return: Devices object
312 """
313
314 def get_child_device_with_proxy_address(proxy_address):
315 """
316 Get a child device based on its proxy address. Proxy address is
317 defined as {parent id, channel_id}
318 :param proxy_address: A Device.ProxyAddress object
319 :return: Device object or None
320 """
321
322 def device_state_update(device_id,
323 oper_status=None,
324 connect_status=None):
325 """
326 Update a device state.
327 :param device_id: The device ID
328 :param oper_state: Operational state of device
329 :param conn_state: Connection state of device
330 :return: None
331 """
332
333 def child_device_detected(parent_device_id,
334 parent_port_no,
335 child_device_type,
336 channel_id,
337 **kw):
338 """
339 A child device has been detected. Core will create the device along
340 with its unique ID.
341 :param parent_device_id: The parent device ID
342 :param parent_port_no: The parent port number
343 :param device_type: The child device type
344 :param channel_id: A unique identifier for that child device within
345 the parent device (e.g. vlan_id)
346 :param kw: A list of key-value pair where the value is a protobuf
347 message
348 :return: None
349 """
350
351 def device_update(device):
352 """
353 Event corresponding to a device update.
354 :param device: Device Object
355 :return: None
356 """
357
358 def child_device_removed(parent_device_id, child_device_id):
359 """
360 Event indicating a child device has been removed from a parent.
361 :param parent_device_id: Device ID of the parent
362 :param child_device_id: Device ID of the child
363 :return: None
364 """
365
366 def child_devices_state_update(parent_device_id,
367 oper_status=None,
368 connect_status=None,
369 admin_status=None):
370 """
371 Event indicating the status of all child devices have been changed.
372 :param parent_device_id: Device ID of the parent
373 :param oper_status: Operational status
374 :param connect_status: Connection status
375 :param admin_status: Admin status
376 :return: None
377 """
378
379 def child_devices_removed(parent_device_id):
380 """
381 Event indicating all child devices have been removed from a parent.
382 :param parent_device_id: Device ID of the parent device
383 :return: None
384 """
385
386 def device_pm_config_update(device_pm_config, init=False):
387 """
388 Event corresponding to a PM config update of a device.
389 :param device_pm_config: a PmConfigs object
390 :param init: True indicates initializing stage
391 :return: None
392 """
393
394 def port_created(device_id, port):
395 """
396 A port has been created and needs to be added to a device.
397 :param device_id: a device ID
398 :param port: Port object
399 :return None
400 """
401
402 def port_removed(device_id, port):
403 """
404 A port has been removed and it needs to be removed from a Device.
405 :param device_id: a device ID
406 :param port: a Port object
407 :return None
408 """
409
410 def ports_enabled(device_id):
411 """
412 All ports on that device have been re-enabled. The Core will change
413 the admin state to ENABLED and operational state to ACTIVE for all
414 ports on that device.
415 :param device_id: a device ID
416 :return: None
417 """
418
419 def ports_disabled(device_id):
420 """
421 All ports on that device have been disabled. The Core will change the
422 admin status to DISABLED and operational state to UNKNOWN for all
423 ports on that device.
424 :param device_id: a device ID
425 :return: None
426 """
427
428 def ports_oper_status_update(device_id, oper_status):
429 """
430 The operational status of all ports of a Device has been changed.
431 The Core will update the operational status for all ports on the
432 device.
433 :param device_id: a device ID
434 :param oper_status: operational Status
435 :return None
436 """
437
438 def image_download_update(img_dnld):
439 """
440 Event corresponding to an image download update.
441 :param img_dnld: a ImageDownload object
442 :return: None
443 """
444
445 def image_download_deleted(img_dnld):
446 """
447 Event corresponding to the deletion of a downloaded image. The
448 references of this image needs to be removed from the Core.
449 :param img_dnld: a ImageDownload object
450 :return: None
451 """
452
453 def packet_in(device_id, egress_port_no, packet):
454 """
455 Sends a packet to the SDN controller via voltha Core
456 :param device_id: The OLT device ID
457 :param egress_port_no: The port number representing the ONU (cvid)
458 :param packet: The actual packet
459 :return: None
460 """