blob: a29b7844ab29820b35c77100858951f345d73b06 [file] [log] [blame]
sangho1e575652015-05-14 00:39:53 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
sangho1e575652015-05-14 00:39:53 -07003 *
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 */
16package org.onosproject.segmentrouting;
17
Charles Chanc7b3c452018-06-19 20:31:57 -070018import com.google.common.annotations.Beta;
Pierb1fe7382018-04-17 17:25:22 +020019import com.google.common.collect.Multimap;
Charles Chanc7b3c452018-06-19 20:31:57 -070020import org.apache.commons.lang3.NotImplementedException;
Pier Luigib29144d2018-01-15 18:06:43 +010021import org.onlab.packet.IpAddress;
Pier Ventre10bd8d12016-11-26 21:05:22 -080022import org.onlab.packet.IpPrefix;
Charles Chanc7b3c452018-06-19 20:31:57 -070023import org.onlab.packet.VlanId;
Pier96f63cb2018-04-17 16:29:56 +020024import org.onosproject.cluster.NodeId;
Charles Chanc7b3c452018-06-19 20:31:57 -070025import org.onosproject.core.ApplicationId;
Pier Luigib29144d2018-01-15 18:06:43 +010026import org.onosproject.net.ConnectPoint;
Charles Chanc81c45b2016-10-20 17:02:44 -070027import org.onosproject.net.DeviceId;
Saurav Dasc568c342018-01-25 09:49:01 -080028import org.onosproject.net.Link;
29import org.onosproject.net.PortNumber;
Charles Chand5814aa2018-08-19 19:21:46 -070030import org.onosproject.net.flowobjective.NextObjective;
Saurav Das7bcbe702017-06-13 15:35:54 -070031import org.onosproject.segmentrouting.grouphandler.NextNeighbors;
Pier Luigi96fe0772018-02-28 12:10:50 +010032import org.onosproject.segmentrouting.mcast.McastRole;
Pier3e793752018-04-19 16:47:06 +020033import org.onosproject.segmentrouting.mcast.McastRoleStoreKey;
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -070034import org.onosproject.segmentrouting.pwaas.DefaultL2TunnelDescription;
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -080035import org.onosproject.segmentrouting.pwaas.L2Tunnel;
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -070036import org.onosproject.segmentrouting.pwaas.L2TunnelHandler;
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -080037import org.onosproject.segmentrouting.pwaas.L2TunnelPolicy;
Andreas Pantelopouloscd339592018-02-23 14:18:00 -080038import org.onosproject.segmentrouting.pwaas.L2TunnelDescription;
Saurav Das7bcbe702017-06-13 15:35:54 -070039import org.onosproject.segmentrouting.storekey.DestinationSetNextObjectiveStoreKey;
Saurav Dasc88d4662017-05-15 15:34:25 -070040
41import com.google.common.collect.ImmutableMap;
Pier3e793752018-04-19 16:47:06 +020042import org.onosproject.segmentrouting.mcast.McastStoreKey;
Charles Chand5814aa2018-08-19 19:21:46 -070043import org.onosproject.segmentrouting.storekey.PortNextObjectiveStoreKey;
44import org.onosproject.segmentrouting.storekey.VlanNextObjectiveStoreKey;
Charles Chanc81c45b2016-10-20 17:02:44 -070045
sangho1e575652015-05-14 00:39:53 -070046import java.util.List;
Charles Chanc81c45b2016-10-20 17:02:44 -070047import java.util.Map;
Charles Chanc7b3c452018-06-19 20:31:57 -070048import java.util.Optional;
Charles Chanc81c45b2016-10-20 17:02:44 -070049import java.util.Set;
sangho1e575652015-05-14 00:39:53 -070050
51/**
52 * Segment Routing Service for REST API.
53 */
54public interface SegmentRoutingService {
Charles Chan5270ed02016-01-30 23:22:37 -080055 /**
Charles Chanf76de302018-06-15 18:54:18 -070056 * VLAN cross-connect ACL priority.
Charles Chanc7b3c452018-06-19 20:31:57 -070057 *
58 * @deprecated in ONOS 1.12. Replaced by {@link org.onosproject.segmentrouting.xconnect.api.XconnectService}
Charles Chanf76de302018-06-15 18:54:18 -070059 */
Charles Chanc7b3c452018-06-19 20:31:57 -070060 @Deprecated
Charles Chanf76de302018-06-15 18:54:18 -070061 int XCONNECT_ACL_PRIORITY = 60000;
62
63 /**
64 * VLAN cross-connect Bridging priority.
Charles Chanc7b3c452018-06-19 20:31:57 -070065 *
66 * @deprecated in ONOS 1.12. Replaced by {@link org.onosproject.segmentrouting.xconnect.api.XconnectService}
Charles Chan5270ed02016-01-30 23:22:37 -080067 */
Charles Chanc7b3c452018-06-19 20:31:57 -070068 @Deprecated
Charles Chan5270ed02016-01-30 23:22:37 -080069 int XCONNECT_PRIORITY = 1000;
70
71 /**
72 * Default flow priority.
73 */
74 int DEFAULT_PRIORITY = 100;
75
76 /**
77 * Minimum IP priority.
78 *
Charles Chanb54e8ba2016-02-18 10:43:46 -080079 * Should < 0 such that priority of /0 will not conflict with lowest
Charles Chan5270ed02016-01-30 23:22:37 -080080 * priority default entries.
81 */
82 int MIN_IP_PRIORITY = 10;
83
84 /**
85 * Subnet flooding flow priority.
86 */
87 int FLOOD_PRIORITY = 5;
88
sangho1e575652015-05-14 00:39:53 -070089 /**
90 * Returns all tunnels.
91 *
92 * @return list of tunnels
93 */
94 List<Tunnel> getTunnels();
95
96 /**
97 * Creates a tunnel.
98 *
99 * @param tunnel tunnel reference to create
sangho71abe1b2015-06-29 14:58:47 -0700100 * @return WRONG_PATH if the tunnel path is wrong, ID_EXISTS if the tunnel ID
101 * exists already, TUNNEL_EXISTS if the same tunnel exists, INTERNAL_ERROR
102 * if the tunnel creation failed internally, SUCCESS if the tunnel is created
103 * successfully
sangho1e575652015-05-14 00:39:53 -0700104 */
sangho71abe1b2015-06-29 14:58:47 -0700105 TunnelHandler.Result createTunnel(Tunnel tunnel);
sangho1e575652015-05-14 00:39:53 -0700106
107 /**
108 * Returns all policies.
109 *
110 * @return list of policy
111 */
112 List<Policy> getPolicies();
113
114 /**
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -0700115 * Returns the l2 tunnel descriptions.
116 *
Andreas Pantelopoulos811bbae2018-03-15 16:56:09 -0700117 * @param pending if true fetch pending pseudowires, else fetch installed
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -0700118 * @return set of l2 tunnel descriptions.
119 */
Andreas Pantelopoulos811bbae2018-03-15 16:56:09 -0700120 Set<L2TunnelDescription> getL2TunnelDescriptions(boolean pending);
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -0700121
122 /**
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700123 * Returns all l2 tunnels of pseudowires.
124 *
125 * @return list of l2 tunnels
126 */
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -0800127 List<L2Tunnel> getL2Tunnels();
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700128
129 /**
130 * Returns all l2 policie of pseudowires.
131 *
132 * @return list of l2 policies.
133 */
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -0800134 List<L2TunnelPolicy> getL2Policies();
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700135
136 /**
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -0700137 * Removes pseudowire.
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700138 *
Andreas Pantelopouloscd339592018-02-23 14:18:00 -0800139 * @param pwId The id of the pseudowire.
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700140 * @return SUCCESS if operation successful or a descriptive error otherwise.
141 */
Andreas Pantelopouloscd339592018-02-23 14:18:00 -0800142 L2TunnelHandler.Result removePseudowire(Integer pwId);
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700143
144 /**
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -0700145 * Adds a Pseudowire to the system.
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700146 *
Andreas Pantelopouloscd339592018-02-23 14:18:00 -0800147 * @param tunnel The pseudowire tunnel.
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700148 * @return SUCCESS if operation is successful or a descriptive error otherwise.
149 */
Andreas Pantelopouloscd339592018-02-23 14:18:00 -0800150 L2TunnelHandler.Result addPseudowire(L2TunnelDescription tunnel);
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700151
152 /**
Andreas Pantelopoulosffe69742018-03-20 13:58:49 -0700153 * Adds a set of pseudowires.
154 *
155 *
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -0700156 * @param l2TunnelDescriptions The pseudowires to add.
157 * @return SUCCESS if ALL pseudowires can be instantiated and are deployed, or a
158 * a descriptive error otherwise, without deploying any pseudowire.
Andreas Pantelopoulosffe69742018-03-20 13:58:49 -0700159 * @deprecated onos-1.12 use addPseudowire instead
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -0700160 */
Andreas Pantelopoulosffe69742018-03-20 13:58:49 -0700161 @Deprecated
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -0700162 L2TunnelHandler.Result addPseudowiresBulk(List<DefaultL2TunnelDescription> l2TunnelDescriptions);
163
164 /**
sangho1e575652015-05-14 00:39:53 -0700165 * Creates a policy.
166 *
167 * @param policy policy reference to create
sangho71abe1b2015-06-29 14:58:47 -0700168 * @return ID_EXISTS if the same policy ID exists,
169 * POLICY_EXISTS if the same policy exists, TUNNEL_NOT_FOUND if the tunnel
170 * does not exists, UNSUPPORTED_TYPE if the policy type is not supported,
171 * SUCCESS if the policy is created successfully.
sangho1e575652015-05-14 00:39:53 -0700172 */
sangho71abe1b2015-06-29 14:58:47 -0700173 PolicyHandler.Result createPolicy(Policy policy);
sangho1e575652015-05-14 00:39:53 -0700174
175 /**
176 * Removes a tunnel.
177 *
178 * @param tunnel tunnel reference to remove
sangho71abe1b2015-06-29 14:58:47 -0700179 * @return TUNNEL_NOT_FOUND if the tunnel to remove does not exists,
180 * INTERNAL_ERROR if the tunnel creation failed internally, SUCCESS
181 * if the tunnel is created successfully.
sangho1e575652015-05-14 00:39:53 -0700182 */
sangho71abe1b2015-06-29 14:58:47 -0700183 TunnelHandler.Result removeTunnel(Tunnel tunnel);
sangho1e575652015-05-14 00:39:53 -0700184
185 /**
186 * Removes a policy.
187 *
188 * @param policy policy reference to remove
sangho71abe1b2015-06-29 14:58:47 -0700189 * @return POLICY_NOT_FOUND if the policy to remove does not exists,
190 * SUCCESS if it is removed successfully
sangho1e575652015-05-14 00:39:53 -0700191 */
sangho71abe1b2015-06-29 14:58:47 -0700192 PolicyHandler.Result removePolicy(Policy policy);
Saurav Das59232cf2016-04-27 18:35:50 -0700193
194 /**
195 * Use current state of the network to repopulate forwarding rules.
196 *
197 */
198 void rerouteNetwork();
Charles Chanc81c45b2016-10-20 17:02:44 -0700199
200 /**
201 * Returns device-subnet mapping.
202 *
203 * @return device-subnet mapping
204 */
Pier Ventre10bd8d12016-11-26 21:05:22 -0800205 Map<DeviceId, Set<IpPrefix>> getDeviceSubnetMap();
Saurav Dasc88d4662017-05-15 15:34:25 -0700206
207 /**
208 * Returns the current ECMP shortest path graph in this controller instance.
209 *
210 * @return ECMP shortest path graph
211 */
212 ImmutableMap<DeviceId, EcmpShortestPathGraph> getCurrentEcmpSpg();
213
214 /**
Saurav Das7bcbe702017-06-13 15:35:54 -0700215 * Returns the destinatiomSet-NextObjective store contents.
Saurav Dasc88d4662017-05-15 15:34:25 -0700216 *
Charles Chand5814aa2018-08-19 19:21:46 -0700217 * @return current contents of the dstNextObjStore
Saurav Dasc88d4662017-05-15 15:34:25 -0700218 */
Charles Chand5814aa2018-08-19 19:21:46 -0700219 ImmutableMap<DestinationSetNextObjectiveStoreKey, NextNeighbors> getDstNextObjStore();
220
221 /**
222 * Returns the VLAN next objective store.
223 *
224 * @return current contents of the vlanNextObjStore
225 */
226 ImmutableMap<VlanNextObjectiveStoreKey, Integer> getVlanNextObjStore();
227
228 /**
229 * Returns the port next objective store.
230 *
231 * @return current contents of the portNextObjStore
232 */
233 ImmutableMap<PortNextObjectiveStoreKey, Integer> getPortNextObjStore();
234
235 /**
236 * Returns the associated next ids to the mcast groups or to the single
237 * group if mcastIp is present.
238 *
239 * @param mcastIp the group ip
240 * @return the mapping mcastIp-device to next id
241 */
242 Map<McastStoreKey, Integer> getMcastNextIds(IpAddress mcastIp);
243
244 /**
245 * Returns the PW init next objective store.
246 *
247 * @return current contents of the l2InitiationNextObjStore
248 */
249 ImmutableMap<String, NextObjective> getPwInitNext();
250
251 /**
252 * Returns the PW termination next objective store.
253 *
254 * @return current contents of the l2TerminationNextObjStore
255 */
256 ImmutableMap<String, NextObjective> getPwTermNext();
257
258 /**
259 * Removes all entries in dst/vlan/port/mcast NextObjectiveStore that are associated with the given nextId.
260 *
261 * @param nextId nextId
262 */
263 void invalidateNextObj(int nextId);
Saurav Dasceccf242017-08-03 18:30:35 -0700264
265 /**
266 * Triggers the verification of all ECMP groups in the specified device.
267 * Adjusts the group buckets if verification finds that there are more or less
268 * buckets than what should be there.
269 *
270 * @param id the device identifier
271 */
272 void verifyGroups(DeviceId id);
Saurav Dasc568c342018-01-25 09:49:01 -0800273
274 /**
275 * Returns the internal link state as seen by this instance of the
276 * controller.
277 *
278 * @return the internal link state
279 */
280 ImmutableMap<Link, Boolean> getSeenLinks();
281
282 /**
283 * Returns the ports administratively disabled by the controller.
284 *
285 * @return a map of devices and port numbers for administratively disabled
286 * ports. Does not include ports manually disabled by the operator.
287 */
288 ImmutableMap<DeviceId, Set<PortNumber>> getDownedPortState();
Pier Luigib29144d2018-01-15 18:06:43 +0100289
Pier3e793752018-04-19 16:47:06 +0200290 /**
Pier Luigib29144d2018-01-15 18:06:43 +0100291 * Returns the associated roles to the mcast groups or to the single
292 * group if mcastIp is present.
293 *
294 * @param mcastIp the group ip
295 * @return the mapping mcastIp-device to mcast role
Pierb1fe7382018-04-17 17:25:22 +0200296 *
297 * @deprecated in 1.12 ("Magpie") release.
Pier Luigib29144d2018-01-15 18:06:43 +0100298 */
Pierb1fe7382018-04-17 17:25:22 +0200299 @Deprecated
Pier Luigi96fe0772018-02-28 12:10:50 +0100300 Map<McastStoreKey, McastRole> getMcastRoles(IpAddress mcastIp);
Pier Luigib29144d2018-01-15 18:06:43 +0100301
302 /**
Pier3e793752018-04-19 16:47:06 +0200303 * Returns the associated roles to the mcast groups.
304 *
305 * @param mcastIp the group ip
306 * @param sourcecp the source connect point
307 * @return the mapping mcastIp-device to mcast role
308 */
309 Map<McastRoleStoreKey, McastRole> getMcastRoles(IpAddress mcastIp,
310 ConnectPoint sourcecp);
311
312 /**
Pier Luigib29144d2018-01-15 18:06:43 +0100313 * Returns the associated paths to the mcast group.
314 *
315 * @param mcastIp the group ip
316 * @return the mapping egress point to mcast path
Pierb1fe7382018-04-17 17:25:22 +0200317 *
318 * @deprecated in 1.12 ("Magpie") release.
Pier Luigib29144d2018-01-15 18:06:43 +0100319 */
Pierb1fe7382018-04-17 17:25:22 +0200320 @Deprecated
Pier Luigib29144d2018-01-15 18:06:43 +0100321 Map<ConnectPoint, List<ConnectPoint>> getMcastPaths(IpAddress mcastIp);
322
Pierb1fe7382018-04-17 17:25:22 +0200323 /**
324 * Returns the associated trees to the mcast group.
325 *
326 * @param mcastIp the group ip
327 * @param sourcecp the source connect point
328 * @return the mapping egress point to mcast path
329 */
330 Multimap<ConnectPoint, List<ConnectPoint>> getMcastTrees(IpAddress mcastIp,
331 ConnectPoint sourcecp);
332
Pier96f63cb2018-04-17 16:29:56 +0200333 /**
334 * Return the leaders of the mcast groups.
335 *
336 * @param mcastIp the group ip
337 * @return the mapping group-node
338 */
339 Map<IpAddress, NodeId> getMcastLeaders(IpAddress mcastIp);
Charles Chan8bc75ee2018-04-17 18:56:53 -0700340
341 /**
342 * Returns shouldProgram map.
343 *
344 * @return shouldProgram map
345 */
346 Map<Set<DeviceId>, NodeId> getShouldProgram();
347
348 /**
349 * Returns shouldProgram local cache.
350 *
351 * @return shouldProgram local cache
352 */
353 Map<DeviceId, Boolean> getShouldProgramCache();
Charles Chanc7b3c452018-06-19 20:31:57 -0700354
355 /**
356 * Gets application id.
357 *
358 * @return application id
359 */
360 default ApplicationId appId() {
361 throw new NotImplementedException("appId not implemented");
362 }
363
364 /**
365 * Returns internal VLAN for untagged hosts on given connect point.
366 * <p>
367 * The internal VLAN is either vlan-untagged for an access port,
368 * or vlan-native for a trunk port.
369 *
370 * @param connectPoint connect point
371 * @return internal VLAN or null if both vlan-untagged and vlan-native are undefined
372 */
373 @Beta
374 default VlanId getInternalVlanId(ConnectPoint connectPoint) {
375 throw new NotImplementedException("getInternalVlanId not implemented");
376 }
377
378
379 /**
380 * Returns optional pair device ID of given device.
381 *
382 * @param deviceId device ID
383 * @return optional pair device ID. Might be empty if pair device is not configured
384 */
385 @Beta
386 default Optional<DeviceId> getPairDeviceId(DeviceId deviceId) {
387 throw new NotImplementedException("getPairDeviceId not implemented");
388 }
389
390
391 /**
392 * Returns optional pair device local port of given device.
393 *
394 * @param deviceId device ID
395 * @return optional pair device ID. Might be empty if pair device is not configured
396 */
397 @Beta
398 default Optional<PortNumber> getPairLocalPort(DeviceId deviceId) {
399 throw new NotImplementedException("getPairLocalPort not implemented");
400 }
sangho1e575652015-05-14 00:39:53 -0700401}