blob: fcdc07ee487a6e3e4dda835be37445349669100b [file] [log] [blame]
wei wei89ddc322015-03-22 16:29:04 -05001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
wei wei89ddc322015-03-22 16:29:04 -05003 *
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 */
Thomas Vachuskabf916ea2015-05-20 18:24:34 -070016package org.onosproject.incubator.net.tunnel;
wei wei89ddc322015-03-22 16:29:04 -050017
18import java.util.Collection;
19
Brian O'Connor2bed5ce2015-06-25 15:10:28 -040020import com.google.common.annotations.Beta;
jcc4a20a5f2015-04-30 15:43:39 +080021import org.onosproject.core.ApplicationId;
Thomas Vachuska42e8cce2015-07-29 19:25:18 -070022import org.onosproject.event.ListenerService;
samuel7a5691a2015-05-23 00:36:32 +080023import org.onosproject.incubator.net.tunnel.Tunnel.Type;
jcc4a20a5f2015-04-30 15:43:39 +080024import org.onosproject.net.Annotations;
cheng fan35dc0f22015-06-10 06:02:47 +080025import org.onosproject.net.DeviceId;
Avantika-Huaweie10a6e92016-04-06 21:06:41 +053026import org.onosproject.net.ElementId;
27import org.onosproject.net.Path;
wei wei89ddc322015-03-22 16:29:04 -050028
29/**
jcc4a20a5f2015-04-30 15:43:39 +080030 * Service for interacting with the inventory of tunnels.
wei wei89ddc322015-03-22 16:29:04 -050031 */
Brian O'Connor2bed5ce2015-06-25 15:10:28 -040032@Beta
Thomas Vachuska42e8cce2015-07-29 19:25:18 -070033public interface TunnelService
34 extends ListenerService<TunnelEvent, TunnelListener> {
wei wei89ddc322015-03-22 16:29:04 -050035
36 /**
jcc4a20a5f2015-04-30 15:43:39 +080037 * Borrows a specific tunnel. Annotations parameter is reserved.If there
38 * is no tunnel in the store, returns a "null" object, and record the tunnel subscription.
39 * Where tunnel is created, ONOS notifies this consumer actively.
wei wei89ddc322015-03-22 16:29:04 -050040 *
jcc4a20a5f2015-04-30 15:43:39 +080041 * @param consumerId a tunnel consumer
42 * @param tunnelId tunnel identify generated by onos
43 * @param annotations Annotations
44 * @return Tunnel subscribed tunnel
wei wei89ddc322015-03-22 16:29:04 -050045 */
jcc4a20a5f2015-04-30 15:43:39 +080046 Tunnel borrowTunnel(ApplicationId consumerId, TunnelId tunnelId,
47 Annotations... annotations);
wei wei89ddc322015-03-22 16:29:04 -050048
49 /**
jcc4a20a5f2015-04-30 15:43:39 +080050 * Borrows a specific tunnel by tunnelName. Annotations parameter is reserved.If there
51 * is no tunnel in the store, return a "null" object, and record the tunnel subscription.
52 * Where tunnel is created, ONOS notifies this consumer actively.
wei wei89ddc322015-03-22 16:29:04 -050053 *
jcc4a20a5f2015-04-30 15:43:39 +080054 * @param consumerId a tunnel consumer
55 * @param tunnelName tunnel name
56 * @param annotations Annotations
57 * @return collection of subscribed Tunnels
wei wei89ddc322015-03-22 16:29:04 -050058 */
jcc4a20a5f2015-04-30 15:43:39 +080059 Collection<Tunnel> borrowTunnel(ApplicationId consumerId, TunnelName tunnelName,
60 Annotations... annotations);
wei wei89ddc322015-03-22 16:29:04 -050061
62 /**
jcc4a20a5f2015-04-30 15:43:39 +080063 * Borrows all tunnels between source and destination. Annotations
64 * parameter is reserved.If there is no any tunnel in the store, return a
65 * empty collection,and record the tunnel subscription. Where tunnel is created, ONOS
66 * notifies this consumer actively. Otherwise ONOS core returns all the
67 * tunnels, consumer determined which one to use.
wei wei89ddc322015-03-22 16:29:04 -050068 *
jcc4a20a5f2015-04-30 15:43:39 +080069 * @param consumerId a tunnel consumer
70 * @param src a source point of tunnel.
71 * @param dst a destination point of tunnel
72 * @param annotations Annotations
73 * @return collection of subscribed Tunnels
wei wei89ddc322015-03-22 16:29:04 -050074 */
jcc4a20a5f2015-04-30 15:43:39 +080075 Collection<Tunnel> borrowTunnel(ApplicationId consumerId, TunnelEndPoint src,
76 TunnelEndPoint dst, Annotations... annotations);
wei wei89ddc322015-03-22 16:29:04 -050077
78 /**
jcc4a20a5f2015-04-30 15:43:39 +080079 * Borrows all specified type tunnels between source and destination.
80 * Annotations parameter is reserved.If there is no any tunnel in the store,
81 * return a empty collection, and record the tunnel subscription. Where tunnel is
82 * created, ONOS notifies this consumer actively. Otherwise,ONOS core returns
83 * all available tunnels, consumer determined which one to use.
wei wei89ddc322015-03-22 16:29:04 -050084 *
jcc4a20a5f2015-04-30 15:43:39 +080085 * @param consumerId a tunnel consumer
86 * @param src a source point of tunnel.
87 * @param dst a destination point of tunnel
wei wei89ddc322015-03-22 16:29:04 -050088 * @param type tunnel type
jcc4a20a5f2015-04-30 15:43:39 +080089 * @param annotations Annotations
90 * @return collection of available Tunnels
wei wei89ddc322015-03-22 16:29:04 -050091 */
jcc4a20a5f2015-04-30 15:43:39 +080092 Collection<Tunnel> borrowTunnel(ApplicationId consumerId, TunnelEndPoint src,
samuel7a5691a2015-05-23 00:36:32 +080093 TunnelEndPoint dst, Type type,
jcc4a20a5f2015-04-30 15:43:39 +080094 Annotations... annotations);
wei wei89ddc322015-03-22 16:29:04 -050095
96 /**
Avantika-Huaweie10a6e92016-04-06 21:06:41 +053097 * Creates a tunnel with given path and default initial state. The state changes
98 * in due course of time based on changes happening in the network.
99 *
100 * @param producerId a tunnel producer
101 * @param srcElementId element id of the source
102 * @param tunnel to be created
103 * @param path path of the tunnel
104 * @return generated tunnel identity
105 */
106 TunnelId setupTunnel(ApplicationId producerId, ElementId srcElementId, Tunnel tunnel, Path path);
107
108 /**
109 * Triggers removal of specified tunnel.
110 *
111 * @param producerId a tunnel producer
112 * @param tunnelId identity for the tunnel to be triggered for removal
113 * @return success or failure
114 */
115 boolean downTunnel(ApplicationId producerId, TunnelId tunnelId);
116
117 /**
jcc4a20a5f2015-04-30 15:43:39 +0800118 * Returns back a specific tunnel to store.
wei wei89ddc322015-03-22 16:29:04 -0500119 *
jcc4a20a5f2015-04-30 15:43:39 +0800120 * @param consumerId a tunnel consumer
121 * @param tunnelId tunnel identify generated by ONOS
122 * @param annotations Annotations
123 * @return success or fail
wei wei89ddc322015-03-22 16:29:04 -0500124 */
jcc4a20a5f2015-04-30 15:43:39 +0800125 boolean returnTunnel(ApplicationId consumerId, TunnelId tunnelId,
126 Annotations... annotations);
wei wei89ddc322015-03-22 16:29:04 -0500127
128 /**
jcc4a20a5f2015-04-30 15:43:39 +0800129 * Returns all specific name tunnel back store. Annotations parameter is reserved.if there
130 * is no tunnel in the store, return a "null" object, and record the tunnel subscription.
131 * Where tunnel is created, ONOS notifies this consumer actively.
wei wei89ddc322015-03-22 16:29:04 -0500132 *
jcc4a20a5f2015-04-30 15:43:39 +0800133 * @param consumerId a tunnel consumer
134 * @param tunnelName tunnel name
135 * @param annotations Annotations
136 * @return boolean
wei wei89ddc322015-03-22 16:29:04 -0500137 */
jcc4a20a5f2015-04-30 15:43:39 +0800138 boolean returnTunnel(ApplicationId consumerId, TunnelName tunnelName,
139 Annotations... annotations);
140
141 /**
142 * Returns all specific type tunnels between source and destination back
143 * store. Annotations parameter is reserved.
144 *
145 * @param consumerId a tunnel consumer
146 * @param src a source point of tunnel.
147 * @param dst a destination point of tunnel
148 * @param type tunnel type
149 * @param annotations Annotations
150 * @return success or fail
151 */
152 boolean returnTunnel(ApplicationId consumerId, TunnelEndPoint src,
samuel7a5691a2015-05-23 00:36:32 +0800153 TunnelEndPoint dst, Type type,
jcc4a20a5f2015-04-30 15:43:39 +0800154 Annotations... annotations);
155
156 /**
157 * Returns all tunnels between source and destination back the store.
158 * Annotations parameter is reserved.
159 *
160 * @param consumerId a tunnel consumer
161 * @param src a source point of tunnel.
162 * @param dst a destination point of tunnel.
163 * @param annotations Annotations
164 * @return success or fail
165 */
166 boolean returnTunnel(ApplicationId consumerId, TunnelEndPoint src,
167 TunnelEndPoint dst, Annotations... annotations);
168
169 /**
170 * Returns a tunnel by a specific tunnel identity.
171 *
172 * @param tunnelId tunnel identify generated by tunnel producer
173 * @return Tunnel
174 */
175 Tunnel queryTunnel(TunnelId tunnelId);
176
177 /**
178 * Returns all tunnel subscription record by consumer.
179 *
180 * @param consumerId consumer identity
181 * @return Collection of TunnelSubscription
182 */
183 Collection<TunnelSubscription> queryTunnelSubscription(ApplicationId consumerId);
184
185 /**
186 * Returns all specified type tunnels.
187 *
188 * @param type tunnel type
189 * @return Collection of tunnels
190 */
samuel7a5691a2015-05-23 00:36:32 +0800191 Collection<Tunnel> queryTunnel(Type type);
jcc4a20a5f2015-04-30 15:43:39 +0800192
193 /**
194 * Returns all tunnels between source point and destination point.
195 *
196 * @param src a source point of tunnel.
197 * @param dst a destination point of tunnel.
198 * @return Collection of tunnels
199 */
200 Collection<Tunnel> queryTunnel(TunnelEndPoint src, TunnelEndPoint dst);
201
202 /**
203 * Returns all tunnels.
204 *
samuel7a5691a2015-05-23 00:36:32 +0800205 * @return Collection of tunnels
206 */
207 Collection<Tunnel> queryAllTunnels();
208
209 /**
210 * Returns all tunnels.
211 *
jcc4a20a5f2015-04-30 15:43:39 +0800212 * @return all tunnels
213 */
214 int tunnelCount();
wei wei89ddc322015-03-22 16:29:04 -0500215
216 /**
cheng fan35dc0f22015-06-10 06:02:47 +0800217 * Returns the collection of tunnels applied on the specified device.
218 *
219 * @param deviceId device identifier
220 * @return collection of tunnels
221 */
222 Iterable<Tunnel> getTunnels(DeviceId deviceId);
223
wei wei89ddc322015-03-22 16:29:04 -0500224}