blob: c7016d1197ff46920baa3761f751cbaf028bf26c [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
84 def abandon_device(device):
85 """
86 Make sur ethe adapter no longer looks after device. This is called
87 if device ownership is taken over by another Voltha instance.
88 :param device: A Voltha.Device object.
89 :return: (Deferred) Shall be fired to acknowledge abandonment.
90 """
91
Khen Nursimulud068d812017-03-06 11:44:18 -050092 def disable_device(device):
Zsolt Haraszti7eeb2b32016-11-06 14:04:55 -080093 """
Khen Nursimulud068d812017-03-06 11:44:18 -050094 This is called when a previously enabled device needs to be disabled
95 based on a NBI call.
Zsolt Harasztic5c5d102016-12-07 21:12:27 -080096 :param device: A Voltha.Device object.
Khen Nursimulud068d812017-03-06 11:44:18 -050097 :return: (Deferred) Shall be fired to acknowledge disabling the device.
98 """
99
100 def reenable_device(device):
101 """
102 This is called when a previously disabled device needs to be enabled
103 based on a NBI call.
104 :param device: A Voltha.Device object.
105 :return: (Deferred) Shall be fired to acknowledge re-enabling the
106 device.
107 """
108
109 def reboot_device(device):
110 """
111 This is called to reboot a device based on a NBI call. The admin
112 state of the device will not change after the reboot
113 :param device: A Voltha.Device object.
114 :return: (Deferred) Shall be fired to acknowledge the reboot.
115 """
116
117 def delete_device(device):
118 """
119 This is called to delete a device from the PON based on a NBI call.
120 If the device is an OLT then the whole PON will be deleted.
121 :param device: A Voltha.Device object.
122 :return: (Deferred) Shall be fired to acknowledge the deletion.
123 """
124
125 def get_device_details(device):
126 """
127 This is called to get additional device details based on a NBI call.
128 :param device: A Voltha.Device object.
129 :return: (Deferred) Shall be fired to acknowledge the retrieval of
130 additional details.
Zsolt Haraszti7eeb2b32016-11-06 14:04:55 -0800131 """
132
Zsolt Harasztic5c5d102016-12-07 21:12:27 -0800133 def update_flows_bulk(device, flows, groups):
134 """
135 Called after any flow table change, but only if the device supports
136 bulk mode, which is expressed by the 'accepts_bulk_flow_update'
137 capability attribute of the device type.
138 :param device: A Voltha.Device object.
139 :param flows: An openflow_v13.Flows object
140 :param groups: An openflow_v13.Flows object
141 :return: (Deferred or None)
142 """
143
144 def update_flows_incrementally(device, flow_changes, group_changes):
145 """
146 [This mode is not supported yet.]
147 :param device: A Voltha.Device object.
148 :param flow_changes:
149 :param group_changes:
150 :return:
151 """
152
153 def send_proxied_message(proxy_address, msg):
154 """
155 Forward a msg to a child device of device, addressed by the given
156 proxy_address=Device.ProxyAddress().
157 :param proxy_address: Address info for the parent device
158 to route the message to the child device. This was given to the
159 child device by the parent device at the creation of the child
160 device.
161 :param msg: (str) The actual message to send.
162 :return: (Deferred(None) or None) The return of this method should
163 indicate that the message was successfully *sent*.
164 """
165
166 def receive_proxied_message(proxy_address, msg):
167 """
168 Pass an async message (arrived via a proxy) to this device.
169 :param proxy_address: Address info for the parent device
170 to route the message to the child device. This was given to the
171 child device by the parent device at the creation of the child
172 device. Note this is the proxy_address with which the adapter
173 had to register prior to receiving proxied messages.
174 :param msg: (str) The actual message received.
175 :return: None
176 """
177
Zsolt Haraszti656ecc62016-12-28 15:08:23 -0800178 def receive_packet_out(logical_device_id, egress_port_no, msg):
179 """
180 Pass a packet_out message content to adapter so that it can forward it
181 out to the device. This is only called on root devices.
182 :param logical_device_id:
183 :param egress_port: egress logical port number
184 :param msg: actual message
185 :return: None
186 """
187
Khen Nursimulud068d812017-03-06 11:44:18 -0500188 # TODO work in progress
189 # ...
Zsolt Haraszti00d9a842016-11-23 11:18:23 -0800190
191
Zsolt Haraszti66862032016-11-28 14:28:39 -0800192class IAdapterAgent(Interface):
Zsolt Haraszti00d9a842016-11-23 11:18:23 -0800193 """
194 This object is passed in to the __init__ function of each adapter,
195 and can be used by the adapter implementation to initiate async calls
196 toward Voltha's CORE via the APIs defined here.
197 """
198
Zsolt Harasztic5c5d102016-12-07 21:12:27 -0800199 def get_device(device_id):
Zsolt Haraszti66862032016-11-28 14:28:39 -0800200 # TODO add doc
201 """"""
202
203 def add_device(device):
204 # TODO add doc
205 """"""
206
207 def update_device(device):
Zsolt Haraszti00d9a842016-11-23 11:18:23 -0800208 # TODO add doc
209 """"""
210
211 def add_port(device_id, port):
212 # TODO add doc
213 """"""
214
215 def create_logical_device(logical_device):
216 # TODO add doc
217 """"""
218
219 def add_logical_port(logical_device_id, port):
220 # TODO add doc
221 """"""
222
Zsolt Haraszti66862032016-11-28 14:28:39 -0800223 def child_device_detected(parent_device_id,
Zsolt Harasztic5c5d102016-12-07 21:12:27 -0800224 parent_port_no,
Zsolt Haraszti66862032016-11-28 14:28:39 -0800225 child_device_type,
Zsolt Haraszti89a27302016-12-08 16:53:06 -0800226 proxy_address,
227 **kw):
Zsolt Haraszti66862032016-11-28 14:28:39 -0800228 # TODO add doc
229 """"""
230
Zsolt Harasztic5c5d102016-12-07 21:12:27 -0800231 def send_proxied_message(proxy_address, msg):
232 """
233 Forward a msg to a child device of device, addressed by the given
234 proxy_address=Device.ProxyAddress().
235 :param proxy_address: Address info for the parent device
236 to route the message to the child device. This was given to the
237 child device by the parent device at the creation of the child
238 device.
239 :param msg: (str) The actual message to send.
240 :return: (Deferred(None) or None) The return of this method should
241 indicate that the message was successfully *sent*.
242 """
243
244 def receive_proxied_message(proxy_address, msg):
245 """
246 Pass an async message (arrived via a proxy) to this device.
247 :param proxy_address: Address info for the parent device
248 to route the message to the child device. This was given to the
249 child device by the parent device at the creation of the child
250 device. Note this is the proxy_address with which the adapter
251 had to register prior to receiving proxied messages.
252 :param msg: (str) The actual message received.
253 :return: None
254 """
255
256 def register_for_proxied_messages(proxy_address):
257 """
258 A child device adapter can use this to indicate its intent to
259 receive async messages sent via a parent device. Example: an
260 ONU adapter can use this to register for OMCI messages received
261 via the OLT and the OLT adapter.
262 :param child_device_address: Address info that was given to the
263 child device by the parent device at the creation of the child
264 device. Its uniqueness acts as a router information for the
265 registration.
266 :return: None
267 """
268
269 def unregister_for_proxied_messages(proxy_address):
270 """
271 Cancel a previous registration
272 :return:
273 """
Zsolt Haraszti00d9a842016-11-23 11:18:23 -0800274
Zsolt Haraszti8925d1f2016-12-21 00:45:19 -0800275 def send_packet_in(logical_device_id, logical_port_no, packet):
276 """
277 Forward given packet to the northbound toward an SDN controller.
278 :param device_id: logical device identifier
279 :param logical_port_no: logical port_no (as numbered in openflow)
280 :param packet: the actual packet; can be a serialized string or a scapy
281 Packet.
282 :return: None returned on success
283 """
Zsolt Haraszti00d9a842016-11-23 11:18:23 -0800284
Zsolt Haraszti749b0952017-01-18 09:02:35 -0800285 def submit_kpis(kpi_event_msg):
286 """
287 Submit KPI metrics on behalf of the OLT and its adapter. This can
288 include hardware related metrics, usage and utilization metrics, as
289 well as optional adapter specific metrics.
290 :param kpi_event_msg: A protobuf message of KpiEvent type.
291 :return: None
292 """
Stephane Barbarie52198b92017-03-02 13:44:46 -0500293
294 def submit_alarm(alarm_event_msg):
295 """
296 Submit an alarm on behalf of the OLT and its adapter.
297 :param alarm_event_msg: A protobuf message of AlarmEvent type.
298 :return: None
299 """