blob: feec225e9f5b22e476eae7814c6325902a42ee02 [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.
95 :return: (Deferred) Shall be fired to acknowledge deactivation.
96 """
97
98 # TODO work in progress
99 # ...
Zsolt Haraszti00d9a842016-11-23 11:18:23 -0800100
101
Zsolt Haraszti66862032016-11-28 14:28:39 -0800102class IAdapterAgent(Interface):
Zsolt Haraszti00d9a842016-11-23 11:18:23 -0800103 """
104 This object is passed in to the __init__ function of each adapter,
105 and can be used by the adapter implementation to initiate async calls
106 toward Voltha's CORE via the APIs defined here.
107 """
108
Zsolt Haraszti66862032016-11-28 14:28:39 -0800109 def get_device(selfdevice_id):
110 # TODO add doc
111 """"""
112
113 def add_device(device):
114 # TODO add doc
115 """"""
116
117 def update_device(device):
Zsolt Haraszti00d9a842016-11-23 11:18:23 -0800118 # TODO add doc
119 """"""
120
121 def add_port(device_id, port):
122 # TODO add doc
123 """"""
124
125 def create_logical_device(logical_device):
126 # TODO add doc
127 """"""
128
129 def add_logical_port(logical_device_id, port):
130 # TODO add doc
131 """"""
132
Zsolt Haraszti66862032016-11-28 14:28:39 -0800133 def child_device_detected(parent_device_id,
134 child_device_type,
135 child_device_address_kw):
136 # TODO add doc
137 """"""
138
Zsolt Haraszti00d9a842016-11-23 11:18:23 -0800139 # TODO work in progress
140 pass
141
142