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