blob: 74db140f3b5137153990bc83c71b8b580a1cd188 [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;
Ruchi Sahotaef0761c2019-01-28 01:08:18 +000045import org.onosproject.segmentrouting.storekey.MacVlanNextObjectiveStoreKey;
Charles Chanc81c45b2016-10-20 17:02:44 -070046
sangho1e575652015-05-14 00:39:53 -070047import java.util.List;
Charles Chanc81c45b2016-10-20 17:02:44 -070048import java.util.Map;
Charles Chanc7b3c452018-06-19 20:31:57 -070049import java.util.Optional;
Charles Chanc81c45b2016-10-20 17:02:44 -070050import java.util.Set;
sangho1e575652015-05-14 00:39:53 -070051
52/**
53 * Segment Routing Service for REST API.
54 */
55public interface SegmentRoutingService {
Charles Chan5270ed02016-01-30 23:22:37 -080056 /**
Charles Chanf76de302018-06-15 18:54:18 -070057 * VLAN cross-connect ACL priority.
Charles Chanc7b3c452018-06-19 20:31:57 -070058 *
59 * @deprecated in ONOS 1.12. Replaced by {@link org.onosproject.segmentrouting.xconnect.api.XconnectService}
Charles Chanf76de302018-06-15 18:54:18 -070060 */
Charles Chanc7b3c452018-06-19 20:31:57 -070061 @Deprecated
Charles Chanf76de302018-06-15 18:54:18 -070062 int XCONNECT_ACL_PRIORITY = 60000;
63
64 /**
65 * VLAN cross-connect Bridging priority.
Charles Chanc7b3c452018-06-19 20:31:57 -070066 *
67 * @deprecated in ONOS 1.12. Replaced by {@link org.onosproject.segmentrouting.xconnect.api.XconnectService}
Charles Chan5270ed02016-01-30 23:22:37 -080068 */
Charles Chanc7b3c452018-06-19 20:31:57 -070069 @Deprecated
Charles Chan5270ed02016-01-30 23:22:37 -080070 int XCONNECT_PRIORITY = 1000;
71
72 /**
73 * Default flow priority.
74 */
75 int DEFAULT_PRIORITY = 100;
76
77 /**
78 * Minimum IP priority.
79 *
Charles Chanb54e8ba2016-02-18 10:43:46 -080080 * Should < 0 such that priority of /0 will not conflict with lowest
Charles Chan5270ed02016-01-30 23:22:37 -080081 * priority default entries.
82 */
83 int MIN_IP_PRIORITY = 10;
84
85 /**
86 * Subnet flooding flow priority.
87 */
88 int FLOOD_PRIORITY = 5;
89
sangho1e575652015-05-14 00:39:53 -070090 /**
91 * Returns all tunnels.
92 *
93 * @return list of tunnels
94 */
95 List<Tunnel> getTunnels();
96
97 /**
98 * Creates a tunnel.
99 *
100 * @param tunnel tunnel reference to create
sangho71abe1b2015-06-29 14:58:47 -0700101 * @return WRONG_PATH if the tunnel path is wrong, ID_EXISTS if the tunnel ID
102 * exists already, TUNNEL_EXISTS if the same tunnel exists, INTERNAL_ERROR
103 * if the tunnel creation failed internally, SUCCESS if the tunnel is created
104 * successfully
sangho1e575652015-05-14 00:39:53 -0700105 */
sangho71abe1b2015-06-29 14:58:47 -0700106 TunnelHandler.Result createTunnel(Tunnel tunnel);
sangho1e575652015-05-14 00:39:53 -0700107
108 /**
109 * Returns all policies.
110 *
111 * @return list of policy
112 */
113 List<Policy> getPolicies();
114
115 /**
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -0700116 * Returns the l2 tunnel descriptions.
117 *
Andreas Pantelopoulos811bbae2018-03-15 16:56:09 -0700118 * @param pending if true fetch pending pseudowires, else fetch installed
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -0700119 * @return set of l2 tunnel descriptions.
120 */
Andreas Pantelopoulos811bbae2018-03-15 16:56:09 -0700121 Set<L2TunnelDescription> getL2TunnelDescriptions(boolean pending);
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -0700122
123 /**
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700124 * Returns all l2 tunnels of pseudowires.
125 *
126 * @return list of l2 tunnels
127 */
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -0800128 List<L2Tunnel> getL2Tunnels();
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700129
130 /**
131 * Returns all l2 policie of pseudowires.
132 *
133 * @return list of l2 policies.
134 */
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -0800135 List<L2TunnelPolicy> getL2Policies();
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700136
137 /**
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -0700138 * Removes pseudowire.
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700139 *
Andreas Pantelopouloscd339592018-02-23 14:18:00 -0800140 * @param pwId The id of the pseudowire.
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700141 * @return SUCCESS if operation successful or a descriptive error otherwise.
142 */
Andreas Pantelopouloscd339592018-02-23 14:18:00 -0800143 L2TunnelHandler.Result removePseudowire(Integer pwId);
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700144
145 /**
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -0700146 * Adds a Pseudowire to the system.
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700147 *
Andreas Pantelopouloscd339592018-02-23 14:18:00 -0800148 * @param tunnel The pseudowire tunnel.
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700149 * @return SUCCESS if operation is successful or a descriptive error otherwise.
150 */
Andreas Pantelopouloscd339592018-02-23 14:18:00 -0800151 L2TunnelHandler.Result addPseudowire(L2TunnelDescription tunnel);
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700152
153 /**
Andreas Pantelopoulosffe69742018-03-20 13:58:49 -0700154 * Adds a set of pseudowires.
155 *
156 *
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -0700157 * @param l2TunnelDescriptions The pseudowires to add.
158 * @return SUCCESS if ALL pseudowires can be instantiated and are deployed, or a
159 * a descriptive error otherwise, without deploying any pseudowire.
Andreas Pantelopoulosffe69742018-03-20 13:58:49 -0700160 * @deprecated onos-1.12 use addPseudowire instead
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -0700161 */
Andreas Pantelopoulosffe69742018-03-20 13:58:49 -0700162 @Deprecated
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -0700163 L2TunnelHandler.Result addPseudowiresBulk(List<DefaultL2TunnelDescription> l2TunnelDescriptions);
164
165 /**
sangho1e575652015-05-14 00:39:53 -0700166 * Creates a policy.
167 *
168 * @param policy policy reference to create
sangho71abe1b2015-06-29 14:58:47 -0700169 * @return ID_EXISTS if the same policy ID exists,
170 * POLICY_EXISTS if the same policy exists, TUNNEL_NOT_FOUND if the tunnel
171 * does not exists, UNSUPPORTED_TYPE if the policy type is not supported,
172 * SUCCESS if the policy is created successfully.
sangho1e575652015-05-14 00:39:53 -0700173 */
sangho71abe1b2015-06-29 14:58:47 -0700174 PolicyHandler.Result createPolicy(Policy policy);
sangho1e575652015-05-14 00:39:53 -0700175
176 /**
177 * Removes a tunnel.
178 *
179 * @param tunnel tunnel reference to remove
sangho71abe1b2015-06-29 14:58:47 -0700180 * @return TUNNEL_NOT_FOUND if the tunnel to remove does not exists,
181 * INTERNAL_ERROR if the tunnel creation failed internally, SUCCESS
182 * if the tunnel is created successfully.
sangho1e575652015-05-14 00:39:53 -0700183 */
sangho71abe1b2015-06-29 14:58:47 -0700184 TunnelHandler.Result removeTunnel(Tunnel tunnel);
sangho1e575652015-05-14 00:39:53 -0700185
186 /**
187 * Removes a policy.
188 *
189 * @param policy policy reference to remove
sangho71abe1b2015-06-29 14:58:47 -0700190 * @return POLICY_NOT_FOUND if the policy to remove does not exists,
191 * SUCCESS if it is removed successfully
sangho1e575652015-05-14 00:39:53 -0700192 */
sangho71abe1b2015-06-29 14:58:47 -0700193 PolicyHandler.Result removePolicy(Policy policy);
Saurav Das59232cf2016-04-27 18:35:50 -0700194
195 /**
196 * Use current state of the network to repopulate forwarding rules.
197 *
198 */
199 void rerouteNetwork();
Charles Chanc81c45b2016-10-20 17:02:44 -0700200
201 /**
202 * Returns device-subnet mapping.
203 *
204 * @return device-subnet mapping
205 */
Pier Ventre10bd8d12016-11-26 21:05:22 -0800206 Map<DeviceId, Set<IpPrefix>> getDeviceSubnetMap();
Saurav Dasc88d4662017-05-15 15:34:25 -0700207
208 /**
209 * Returns the current ECMP shortest path graph in this controller instance.
210 *
211 * @return ECMP shortest path graph
212 */
213 ImmutableMap<DeviceId, EcmpShortestPathGraph> getCurrentEcmpSpg();
214
215 /**
Saurav Das7bcbe702017-06-13 15:35:54 -0700216 * Returns the destinatiomSet-NextObjective store contents.
Saurav Dasc88d4662017-05-15 15:34:25 -0700217 *
Charles Chand5814aa2018-08-19 19:21:46 -0700218 * @return current contents of the dstNextObjStore
Saurav Dasc88d4662017-05-15 15:34:25 -0700219 */
Charles Chand5814aa2018-08-19 19:21:46 -0700220 ImmutableMap<DestinationSetNextObjectiveStoreKey, NextNeighbors> getDstNextObjStore();
221
222 /**
223 * Returns the VLAN next objective store.
224 *
225 * @return current contents of the vlanNextObjStore
226 */
227 ImmutableMap<VlanNextObjectiveStoreKey, Integer> getVlanNextObjStore();
228
229 /**
Ruchi Sahotaef0761c2019-01-28 01:08:18 +0000230 * Returns the Mac Vlan next objective store.
231 *
232 * @return current contents of the macVlanNextObjStore
233 */
234 ImmutableMap<MacVlanNextObjectiveStoreKey, Integer> getMacVlanNextObjStore();
235
236 /**
Charles Chand5814aa2018-08-19 19:21:46 -0700237 * Returns the port next objective store.
238 *
239 * @return current contents of the portNextObjStore
240 */
241 ImmutableMap<PortNextObjectiveStoreKey, Integer> getPortNextObjStore();
242
243 /**
244 * Returns the associated next ids to the mcast groups or to the single
245 * group if mcastIp is present.
246 *
247 * @param mcastIp the group ip
248 * @return the mapping mcastIp-device to next id
249 */
250 Map<McastStoreKey, Integer> getMcastNextIds(IpAddress mcastIp);
251
252 /**
253 * Returns the PW init next objective store.
254 *
255 * @return current contents of the l2InitiationNextObjStore
256 */
257 ImmutableMap<String, NextObjective> getPwInitNext();
258
259 /**
260 * Returns the PW termination next objective store.
261 *
262 * @return current contents of the l2TerminationNextObjStore
263 */
264 ImmutableMap<String, NextObjective> getPwTermNext();
265
266 /**
267 * Removes all entries in dst/vlan/port/mcast NextObjectiveStore that are associated with the given nextId.
268 *
269 * @param nextId nextId
270 */
271 void invalidateNextObj(int nextId);
Saurav Dasceccf242017-08-03 18:30:35 -0700272
273 /**
274 * Triggers the verification of all ECMP groups in the specified device.
275 * Adjusts the group buckets if verification finds that there are more or less
276 * buckets than what should be there.
277 *
278 * @param id the device identifier
279 */
280 void verifyGroups(DeviceId id);
Saurav Dasc568c342018-01-25 09:49:01 -0800281
282 /**
283 * Returns the internal link state as seen by this instance of the
284 * controller.
285 *
286 * @return the internal link state
287 */
288 ImmutableMap<Link, Boolean> getSeenLinks();
289
290 /**
291 * Returns the ports administratively disabled by the controller.
292 *
293 * @return a map of devices and port numbers for administratively disabled
294 * ports. Does not include ports manually disabled by the operator.
295 */
296 ImmutableMap<DeviceId, Set<PortNumber>> getDownedPortState();
Pier Luigib29144d2018-01-15 18:06:43 +0100297
Pier3e793752018-04-19 16:47:06 +0200298 /**
Pier Luigib29144d2018-01-15 18:06:43 +0100299 * Returns the associated roles to the mcast groups or to the single
300 * group if mcastIp is present.
301 *
302 * @param mcastIp the group ip
303 * @return the mapping mcastIp-device to mcast role
Pierb1fe7382018-04-17 17:25:22 +0200304 *
305 * @deprecated in 1.12 ("Magpie") release.
Pier Luigib29144d2018-01-15 18:06:43 +0100306 */
Pierb1fe7382018-04-17 17:25:22 +0200307 @Deprecated
Pier Luigi96fe0772018-02-28 12:10:50 +0100308 Map<McastStoreKey, McastRole> getMcastRoles(IpAddress mcastIp);
Pier Luigib29144d2018-01-15 18:06:43 +0100309
310 /**
Pier3e793752018-04-19 16:47:06 +0200311 * Returns the associated roles to the mcast groups.
312 *
313 * @param mcastIp the group ip
314 * @param sourcecp the source connect point
315 * @return the mapping mcastIp-device to mcast role
316 */
317 Map<McastRoleStoreKey, McastRole> getMcastRoles(IpAddress mcastIp,
318 ConnectPoint sourcecp);
319
320 /**
Pier Luigib29144d2018-01-15 18:06:43 +0100321 * Returns the associated paths to the mcast group.
322 *
323 * @param mcastIp the group ip
324 * @return the mapping egress point to mcast path
Pierb1fe7382018-04-17 17:25:22 +0200325 *
326 * @deprecated in 1.12 ("Magpie") release.
Pier Luigib29144d2018-01-15 18:06:43 +0100327 */
Pierb1fe7382018-04-17 17:25:22 +0200328 @Deprecated
Pier Luigib29144d2018-01-15 18:06:43 +0100329 Map<ConnectPoint, List<ConnectPoint>> getMcastPaths(IpAddress mcastIp);
330
Pierb1fe7382018-04-17 17:25:22 +0200331 /**
332 * Returns the associated trees to the mcast group.
333 *
334 * @param mcastIp the group ip
335 * @param sourcecp the source connect point
336 * @return the mapping egress point to mcast path
337 */
338 Multimap<ConnectPoint, List<ConnectPoint>> getMcastTrees(IpAddress mcastIp,
339 ConnectPoint sourcecp);
340
Pier96f63cb2018-04-17 16:29:56 +0200341 /**
342 * Return the leaders of the mcast groups.
343 *
344 * @param mcastIp the group ip
345 * @return the mapping group-node
346 */
347 Map<IpAddress, NodeId> getMcastLeaders(IpAddress mcastIp);
Charles Chan8bc75ee2018-04-17 18:56:53 -0700348
349 /**
350 * Returns shouldProgram map.
351 *
352 * @return shouldProgram map
353 */
354 Map<Set<DeviceId>, NodeId> getShouldProgram();
355
356 /**
357 * Returns shouldProgram local cache.
358 *
359 * @return shouldProgram local cache
360 */
361 Map<DeviceId, Boolean> getShouldProgramCache();
Charles Chanc7b3c452018-06-19 20:31:57 -0700362
363 /**
jayakumarthazhath655b9a82018-10-01 00:51:54 +0530364 * Returns whether instance should program device or not.
365 *
366 * @param deviceId .
367 * @return boolean status saying instance should program device or not.
368 */
369 boolean shouldProgram(DeviceId deviceId);
370
371 /**
Charles Chanc7b3c452018-06-19 20:31:57 -0700372 * Gets application id.
373 *
374 * @return application id
375 */
376 default ApplicationId appId() {
377 throw new NotImplementedException("appId not implemented");
378 }
379
380 /**
381 * Returns internal VLAN for untagged hosts on given connect point.
382 * <p>
383 * The internal VLAN is either vlan-untagged for an access port,
384 * or vlan-native for a trunk port.
385 *
386 * @param connectPoint connect point
387 * @return internal VLAN or null if both vlan-untagged and vlan-native are undefined
388 */
389 @Beta
390 default VlanId getInternalVlanId(ConnectPoint connectPoint) {
391 throw new NotImplementedException("getInternalVlanId not implemented");
392 }
393
394
395 /**
396 * Returns optional pair device ID of given device.
397 *
398 * @param deviceId device ID
399 * @return optional pair device ID. Might be empty if pair device is not configured
400 */
401 @Beta
402 default Optional<DeviceId> getPairDeviceId(DeviceId deviceId) {
403 throw new NotImplementedException("getPairDeviceId not implemented");
404 }
405
406
407 /**
408 * Returns optional pair device local port of given device.
409 *
410 * @param deviceId device ID
411 * @return optional pair device ID. Might be empty if pair device is not configured
412 */
413 @Beta
414 default Optional<PortNumber> getPairLocalPort(DeviceId deviceId) {
415 throw new NotImplementedException("getPairLocalPort not implemented");
416 }
sangho1e575652015-05-14 00:39:53 -0700417}