blob: f9426c6400d1b358beac332c3a7e6efafa3da2c0 [file] [log] [blame]
Zsolt Haraszti7eeb2b32016-11-06 14:04:55 -08001#
2# Copyright 2016 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
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
92 def deactivate_device(device):
93 """
94 Called if the device is to be deactivate based on a NBI call.
Zsolt Harasztic5c5d102016-12-07 21:12:27 -080095 :param device: A Voltha.Device object.
Zsolt Haraszti7eeb2b32016-11-06 14:04:55 -080096 :return: (Deferred) Shall be fired to acknowledge deactivation.
97 """
98
Zsolt Harasztic5c5d102016-12-07 21:12:27 -080099 def update_flows_bulk(device, flows, groups):
100 """
101 Called after any flow table change, but only if the device supports
102 bulk mode, which is expressed by the 'accepts_bulk_flow_update'
103 capability attribute of the device type.
104 :param device: A Voltha.Device object.
105 :param flows: An openflow_v13.Flows object
106 :param groups: An openflow_v13.Flows object
107 :return: (Deferred or None)
108 """
109
110 def update_flows_incrementally(device, flow_changes, group_changes):
111 """
112 [This mode is not supported yet.]
113 :param device: A Voltha.Device object.
114 :param flow_changes:
115 :param group_changes:
116 :return:
117 """
118
119 def send_proxied_message(proxy_address, msg):
120 """
121 Forward a msg to a child device of device, addressed by the given
122 proxy_address=Device.ProxyAddress().
123 :param proxy_address: Address info for the parent device
124 to route the message to the child device. This was given to the
125 child device by the parent device at the creation of the child
126 device.
127 :param msg: (str) The actual message to send.
128 :return: (Deferred(None) or None) The return of this method should
129 indicate that the message was successfully *sent*.
130 """
131
132 def receive_proxied_message(proxy_address, msg):
133 """
134 Pass an async message (arrived via a proxy) to this device.
135 :param proxy_address: Address info for the parent device
136 to route the message to the child device. This was given to the
137 child device by the parent device at the creation of the child
138 device. Note this is the proxy_address with which the adapter
139 had to register prior to receiving proxied messages.
140 :param msg: (str) The actual message received.
141 :return: None
142 """
143
Zsolt Haraszti7eeb2b32016-11-06 14:04:55 -0800144 # TODO work in progress
145 # ...
Zsolt Haraszti00d9a842016-11-23 11:18:23 -0800146
147
Zsolt Haraszti66862032016-11-28 14:28:39 -0800148class IAdapterAgent(Interface):
Zsolt Haraszti00d9a842016-11-23 11:18:23 -0800149 """
150 This object is passed in to the __init__ function of each adapter,
151 and can be used by the adapter implementation to initiate async calls
152 toward Voltha's CORE via the APIs defined here.
153 """
154
Zsolt Harasztic5c5d102016-12-07 21:12:27 -0800155 def get_device(device_id):
Zsolt Haraszti66862032016-11-28 14:28:39 -0800156 # TODO add doc
157 """"""
158
159 def add_device(device):
160 # TODO add doc
161 """"""
162
163 def update_device(device):
Zsolt Haraszti00d9a842016-11-23 11:18:23 -0800164 # TODO add doc
165 """"""
166
167 def add_port(device_id, port):
168 # TODO add doc
169 """"""
170
171 def create_logical_device(logical_device):
172 # TODO add doc
173 """"""
174
175 def add_logical_port(logical_device_id, port):
176 # TODO add doc
177 """"""
178
Zsolt Haraszti66862032016-11-28 14:28:39 -0800179 def child_device_detected(parent_device_id,
Zsolt Harasztic5c5d102016-12-07 21:12:27 -0800180 parent_port_no,
Zsolt Haraszti66862032016-11-28 14:28:39 -0800181 child_device_type,
182 child_device_address_kw):
183 # TODO add doc
184 """"""
185
Zsolt Harasztic5c5d102016-12-07 21:12:27 -0800186 def send_proxied_message(proxy_address, msg):
187 """
188 Forward a msg to a child device of device, addressed by the given
189 proxy_address=Device.ProxyAddress().
190 :param proxy_address: Address info for the parent device
191 to route the message to the child device. This was given to the
192 child device by the parent device at the creation of the child
193 device.
194 :param msg: (str) The actual message to send.
195 :return: (Deferred(None) or None) The return of this method should
196 indicate that the message was successfully *sent*.
197 """
198
199 def receive_proxied_message(proxy_address, msg):
200 """
201 Pass an async message (arrived via a proxy) to this device.
202 :param proxy_address: Address info for the parent device
203 to route the message to the child device. This was given to the
204 child device by the parent device at the creation of the child
205 device. Note this is the proxy_address with which the adapter
206 had to register prior to receiving proxied messages.
207 :param msg: (str) The actual message received.
208 :return: None
209 """
210
211 def register_for_proxied_messages(proxy_address):
212 """
213 A child device adapter can use this to indicate its intent to
214 receive async messages sent via a parent device. Example: an
215 ONU adapter can use this to register for OMCI messages received
216 via the OLT and the OLT adapter.
217 :param child_device_address: Address info that was given to the
218 child device by the parent device at the creation of the child
219 device. Its uniqueness acts as a router information for the
220 registration.
221 :return: None
222 """
223
224 def unregister_for_proxied_messages(proxy_address):
225 """
226 Cancel a previous registration
227 :return:
228 """
Zsolt Haraszti00d9a842016-11-23 11:18:23 -0800229
230