blob: 772103689c05f9d8cb7a3724ed48ba276fc42296 [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;
Harshada Chaundkarb42abd42019-07-02 16:01:24 +000032import org.onosproject.segmentrouting.mcast.McastFilteringObjStoreKey;
Pier Luigi96fe0772018-02-28 12:10:50 +010033import org.onosproject.segmentrouting.mcast.McastRole;
Pier3e793752018-04-19 16:47:06 +020034import org.onosproject.segmentrouting.mcast.McastRoleStoreKey;
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -070035import org.onosproject.segmentrouting.pwaas.DefaultL2TunnelDescription;
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -080036import org.onosproject.segmentrouting.pwaas.L2Tunnel;
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -070037import org.onosproject.segmentrouting.pwaas.L2TunnelHandler;
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -080038import org.onosproject.segmentrouting.pwaas.L2TunnelPolicy;
Andreas Pantelopouloscd339592018-02-23 14:18:00 -080039import org.onosproject.segmentrouting.pwaas.L2TunnelDescription;
Saurav Das7bcbe702017-06-13 15:35:54 -070040import org.onosproject.segmentrouting.storekey.DestinationSetNextObjectiveStoreKey;
Saurav Dasc88d4662017-05-15 15:34:25 -070041
42import com.google.common.collect.ImmutableMap;
Pier3e793752018-04-19 16:47:06 +020043import org.onosproject.segmentrouting.mcast.McastStoreKey;
Charles Chand5814aa2018-08-19 19:21:46 -070044import org.onosproject.segmentrouting.storekey.PortNextObjectiveStoreKey;
45import org.onosproject.segmentrouting.storekey.VlanNextObjectiveStoreKey;
Ruchi Sahotaef0761c2019-01-28 01:08:18 +000046import org.onosproject.segmentrouting.storekey.MacVlanNextObjectiveStoreKey;
Charles Chanc81c45b2016-10-20 17:02:44 -070047
sangho1e575652015-05-14 00:39:53 -070048import java.util.List;
Charles Chanc81c45b2016-10-20 17:02:44 -070049import java.util.Map;
Charles Chanc7b3c452018-06-19 20:31:57 -070050import java.util.Optional;
Charles Chanc81c45b2016-10-20 17:02:44 -070051import java.util.Set;
sangho1e575652015-05-14 00:39:53 -070052
53/**
54 * Segment Routing Service for REST API.
55 */
56public interface SegmentRoutingService {
Charles Chan5270ed02016-01-30 23:22:37 -080057 /**
Charles Chanf76de302018-06-15 18:54:18 -070058 * VLAN cross-connect ACL priority.
Charles Chanc7b3c452018-06-19 20:31:57 -070059 *
60 * @deprecated in ONOS 1.12. Replaced by {@link org.onosproject.segmentrouting.xconnect.api.XconnectService}
Charles Chanf76de302018-06-15 18:54:18 -070061 */
Charles Chanc7b3c452018-06-19 20:31:57 -070062 @Deprecated
Charles Chanf76de302018-06-15 18:54:18 -070063 int XCONNECT_ACL_PRIORITY = 60000;
64
65 /**
66 * VLAN cross-connect Bridging priority.
Charles Chanc7b3c452018-06-19 20:31:57 -070067 *
68 * @deprecated in ONOS 1.12. Replaced by {@link org.onosproject.segmentrouting.xconnect.api.XconnectService}
Charles Chan5270ed02016-01-30 23:22:37 -080069 */
Charles Chanc7b3c452018-06-19 20:31:57 -070070 @Deprecated
Charles Chan5270ed02016-01-30 23:22:37 -080071 int XCONNECT_PRIORITY = 1000;
72
73 /**
74 * Default flow priority.
75 */
76 int DEFAULT_PRIORITY = 100;
77
78 /**
79 * Minimum IP priority.
80 *
Charles Chanb54e8ba2016-02-18 10:43:46 -080081 * Should < 0 such that priority of /0 will not conflict with lowest
Charles Chan5270ed02016-01-30 23:22:37 -080082 * priority default entries.
83 */
84 int MIN_IP_PRIORITY = 10;
85
86 /**
87 * Subnet flooding flow priority.
88 */
89 int FLOOD_PRIORITY = 5;
90
sangho1e575652015-05-14 00:39:53 -070091 /**
92 * Returns all tunnels.
93 *
94 * @return list of tunnels
95 */
96 List<Tunnel> getTunnels();
97
98 /**
99 * Creates a tunnel.
100 *
101 * @param tunnel tunnel reference to create
sangho71abe1b2015-06-29 14:58:47 -0700102 * @return WRONG_PATH if the tunnel path is wrong, ID_EXISTS if the tunnel ID
103 * exists already, TUNNEL_EXISTS if the same tunnel exists, INTERNAL_ERROR
104 * if the tunnel creation failed internally, SUCCESS if the tunnel is created
105 * successfully
sangho1e575652015-05-14 00:39:53 -0700106 */
sangho71abe1b2015-06-29 14:58:47 -0700107 TunnelHandler.Result createTunnel(Tunnel tunnel);
sangho1e575652015-05-14 00:39:53 -0700108
109 /**
110 * Returns all policies.
111 *
112 * @return list of policy
113 */
114 List<Policy> getPolicies();
115
116 /**
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -0700117 * Returns the l2 tunnel descriptions.
118 *
Andreas Pantelopoulos811bbae2018-03-15 16:56:09 -0700119 * @param pending if true fetch pending pseudowires, else fetch installed
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -0700120 * @return set of l2 tunnel descriptions.
121 */
Andreas Pantelopoulos811bbae2018-03-15 16:56:09 -0700122 Set<L2TunnelDescription> getL2TunnelDescriptions(boolean pending);
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -0700123
124 /**
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700125 * Returns all l2 tunnels of pseudowires.
126 *
127 * @return list of l2 tunnels
128 */
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -0800129 List<L2Tunnel> getL2Tunnels();
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700130
131 /**
132 * Returns all l2 policie of pseudowires.
133 *
134 * @return list of l2 policies.
135 */
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -0800136 List<L2TunnelPolicy> getL2Policies();
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700137
138 /**
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -0700139 * Removes pseudowire.
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700140 *
Andreas Pantelopouloscd339592018-02-23 14:18:00 -0800141 * @param pwId The id of the pseudowire.
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700142 * @return SUCCESS if operation successful or a descriptive error otherwise.
143 */
Andreas Pantelopouloscd339592018-02-23 14:18:00 -0800144 L2TunnelHandler.Result removePseudowire(Integer pwId);
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700145
146 /**
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -0700147 * Adds a Pseudowire to the system.
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700148 *
Andreas Pantelopouloscd339592018-02-23 14:18:00 -0800149 * @param tunnel The pseudowire tunnel.
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700150 * @return SUCCESS if operation is successful or a descriptive error otherwise.
151 */
Andreas Pantelopouloscd339592018-02-23 14:18:00 -0800152 L2TunnelHandler.Result addPseudowire(L2TunnelDescription tunnel);
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700153
154 /**
Andreas Pantelopoulosffe69742018-03-20 13:58:49 -0700155 * Adds a set of pseudowires.
156 *
157 *
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -0700158 * @param l2TunnelDescriptions The pseudowires to add.
159 * @return SUCCESS if ALL pseudowires can be instantiated and are deployed, or a
160 * a descriptive error otherwise, without deploying any pseudowire.
Andreas Pantelopoulosffe69742018-03-20 13:58:49 -0700161 * @deprecated onos-1.12 use addPseudowire instead
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -0700162 */
Andreas Pantelopoulosffe69742018-03-20 13:58:49 -0700163 @Deprecated
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -0700164 L2TunnelHandler.Result addPseudowiresBulk(List<DefaultL2TunnelDescription> l2TunnelDescriptions);
165
166 /**
sangho1e575652015-05-14 00:39:53 -0700167 * Creates a policy.
168 *
169 * @param policy policy reference to create
sangho71abe1b2015-06-29 14:58:47 -0700170 * @return ID_EXISTS if the same policy ID exists,
171 * POLICY_EXISTS if the same policy exists, TUNNEL_NOT_FOUND if the tunnel
172 * does not exists, UNSUPPORTED_TYPE if the policy type is not supported,
173 * SUCCESS if the policy is created successfully.
sangho1e575652015-05-14 00:39:53 -0700174 */
sangho71abe1b2015-06-29 14:58:47 -0700175 PolicyHandler.Result createPolicy(Policy policy);
sangho1e575652015-05-14 00:39:53 -0700176
177 /**
178 * Removes a tunnel.
179 *
180 * @param tunnel tunnel reference to remove
sangho71abe1b2015-06-29 14:58:47 -0700181 * @return TUNNEL_NOT_FOUND if the tunnel to remove does not exists,
182 * INTERNAL_ERROR if the tunnel creation failed internally, SUCCESS
183 * if the tunnel is created successfully.
sangho1e575652015-05-14 00:39:53 -0700184 */
sangho71abe1b2015-06-29 14:58:47 -0700185 TunnelHandler.Result removeTunnel(Tunnel tunnel);
sangho1e575652015-05-14 00:39:53 -0700186
187 /**
188 * Removes a policy.
189 *
190 * @param policy policy reference to remove
sangho71abe1b2015-06-29 14:58:47 -0700191 * @return POLICY_NOT_FOUND if the policy to remove does not exists,
192 * SUCCESS if it is removed successfully
sangho1e575652015-05-14 00:39:53 -0700193 */
sangho71abe1b2015-06-29 14:58:47 -0700194 PolicyHandler.Result removePolicy(Policy policy);
Saurav Das59232cf2016-04-27 18:35:50 -0700195
196 /**
197 * Use current state of the network to repopulate forwarding rules.
198 *
199 */
200 void rerouteNetwork();
Charles Chanc81c45b2016-10-20 17:02:44 -0700201
202 /**
203 * Returns device-subnet mapping.
204 *
205 * @return device-subnet mapping
206 */
Pier Ventre10bd8d12016-11-26 21:05:22 -0800207 Map<DeviceId, Set<IpPrefix>> getDeviceSubnetMap();
Saurav Dasc88d4662017-05-15 15:34:25 -0700208
209 /**
210 * Returns the current ECMP shortest path graph in this controller instance.
211 *
212 * @return ECMP shortest path graph
213 */
214 ImmutableMap<DeviceId, EcmpShortestPathGraph> getCurrentEcmpSpg();
215
216 /**
Saurav Das7bcbe702017-06-13 15:35:54 -0700217 * Returns the destinatiomSet-NextObjective store contents.
Saurav Dasc88d4662017-05-15 15:34:25 -0700218 *
Charles Chand5814aa2018-08-19 19:21:46 -0700219 * @return current contents of the dstNextObjStore
Saurav Dasc88d4662017-05-15 15:34:25 -0700220 */
Charles Chand5814aa2018-08-19 19:21:46 -0700221 ImmutableMap<DestinationSetNextObjectiveStoreKey, NextNeighbors> getDstNextObjStore();
222
223 /**
224 * Returns the VLAN next objective store.
225 *
226 * @return current contents of the vlanNextObjStore
227 */
228 ImmutableMap<VlanNextObjectiveStoreKey, Integer> getVlanNextObjStore();
229
230 /**
Ruchi Sahotaef0761c2019-01-28 01:08:18 +0000231 * Returns the Mac Vlan next objective store.
232 *
233 * @return current contents of the macVlanNextObjStore
234 */
235 ImmutableMap<MacVlanNextObjectiveStoreKey, Integer> getMacVlanNextObjStore();
236
237 /**
Charles Chand5814aa2018-08-19 19:21:46 -0700238 * Returns the port next objective store.
239 *
240 * @return current contents of the portNextObjStore
241 */
242 ImmutableMap<PortNextObjectiveStoreKey, Integer> getPortNextObjStore();
243
244 /**
245 * Returns the associated next ids to the mcast groups or to the single
246 * group if mcastIp is present.
247 *
248 * @param mcastIp the group ip
249 * @return the mapping mcastIp-device to next id
250 */
251 Map<McastStoreKey, Integer> getMcastNextIds(IpAddress mcastIp);
252
253 /**
254 * Returns the PW init next objective store.
255 *
256 * @return current contents of the l2InitiationNextObjStore
257 */
258 ImmutableMap<String, NextObjective> getPwInitNext();
259
260 /**
261 * Returns the PW termination next objective store.
262 *
263 * @return current contents of the l2TerminationNextObjStore
264 */
265 ImmutableMap<String, NextObjective> getPwTermNext();
266
267 /**
268 * Removes all entries in dst/vlan/port/mcast NextObjectiveStore that are associated with the given nextId.
269 *
270 * @param nextId nextId
271 */
272 void invalidateNextObj(int nextId);
Saurav Dasceccf242017-08-03 18:30:35 -0700273
274 /**
275 * Triggers the verification of all ECMP groups in the specified device.
276 * Adjusts the group buckets if verification finds that there are more or less
277 * buckets than what should be there.
278 *
279 * @param id the device identifier
280 */
281 void verifyGroups(DeviceId id);
Saurav Dasc568c342018-01-25 09:49:01 -0800282
283 /**
284 * Returns the internal link state as seen by this instance of the
285 * controller.
286 *
287 * @return the internal link state
288 */
289 ImmutableMap<Link, Boolean> getSeenLinks();
290
291 /**
292 * Returns the ports administratively disabled by the controller.
293 *
294 * @return a map of devices and port numbers for administratively disabled
295 * ports. Does not include ports manually disabled by the operator.
296 */
297 ImmutableMap<DeviceId, Set<PortNumber>> getDownedPortState();
Pier Luigib29144d2018-01-15 18:06:43 +0100298
Pier3e793752018-04-19 16:47:06 +0200299 /**
Pier3e793752018-04-19 16:47:06 +0200300 * Returns the associated roles to the mcast groups.
301 *
302 * @param mcastIp the group ip
303 * @param sourcecp the source connect point
304 * @return the mapping mcastIp-device to mcast role
305 */
306 Map<McastRoleStoreKey, McastRole> getMcastRoles(IpAddress mcastIp,
307 ConnectPoint sourcecp);
308
309 /**
Pierb1fe7382018-04-17 17:25:22 +0200310 * Returns the associated trees to the mcast group.
311 *
312 * @param mcastIp the group ip
313 * @param sourcecp the source connect point
314 * @return the mapping egress point to mcast path
315 */
316 Multimap<ConnectPoint, List<ConnectPoint>> getMcastTrees(IpAddress mcastIp,
317 ConnectPoint sourcecp);
318
Pier96f63cb2018-04-17 16:29:56 +0200319 /**
320 * Return the leaders of the mcast groups.
321 *
322 * @param mcastIp the group ip
323 * @return the mapping group-node
324 */
325 Map<IpAddress, NodeId> getMcastLeaders(IpAddress mcastIp);
Charles Chan8bc75ee2018-04-17 18:56:53 -0700326
327 /**
328 * Returns shouldProgram map.
329 *
330 * @return shouldProgram map
331 */
332 Map<Set<DeviceId>, NodeId> getShouldProgram();
333
334 /**
335 * Returns shouldProgram local cache.
336 *
337 * @return shouldProgram local cache
338 */
339 Map<DeviceId, Boolean> getShouldProgramCache();
Charles Chanc7b3c452018-06-19 20:31:57 -0700340
341 /**
jayakumarthazhath655b9a82018-10-01 00:51:54 +0530342 * Returns whether instance should program device or not.
343 *
344 * @param deviceId .
345 * @return boolean status saying instance should program device or not.
346 */
347 boolean shouldProgram(DeviceId deviceId);
348
349 /**
Harshada Chaundkarb42abd42019-07-02 16:01:24 +0000350 * Returns the mcast filtering obj.
351 *
352 * @return the mapping group-node
353 */
354 Map<DeviceId, List<McastFilteringObjStoreKey>> getMcastFilters();
355
356 /**
Charles Chanc7b3c452018-06-19 20:31:57 -0700357 * Gets application id.
358 *
359 * @return application id
360 */
361 default ApplicationId appId() {
362 throw new NotImplementedException("appId not implemented");
363 }
364
365 /**
366 * Returns internal VLAN for untagged hosts on given connect point.
367 * <p>
368 * The internal VLAN is either vlan-untagged for an access port,
369 * or vlan-native for a trunk port.
370 *
371 * @param connectPoint connect point
372 * @return internal VLAN or null if both vlan-untagged and vlan-native are undefined
373 */
374 @Beta
375 default VlanId getInternalVlanId(ConnectPoint connectPoint) {
376 throw new NotImplementedException("getInternalVlanId not implemented");
377 }
378
379
380 /**
381 * Returns optional pair device ID of given device.
382 *
383 * @param deviceId device ID
384 * @return optional pair device ID. Might be empty if pair device is not configured
385 */
386 @Beta
387 default Optional<DeviceId> getPairDeviceId(DeviceId deviceId) {
388 throw new NotImplementedException("getPairDeviceId not implemented");
389 }
390
391
392 /**
393 * Returns optional pair device local port of given device.
394 *
395 * @param deviceId device ID
396 * @return optional pair device ID. Might be empty if pair device is not configured
397 */
398 @Beta
399 default Optional<PortNumber> getPairLocalPort(DeviceId deviceId) {
400 throw new NotImplementedException("getPairLocalPort not implemented");
401 }
Harshada Chaundkarb42abd42019-07-02 16:01:24 +0000402
sangho1e575652015-05-14 00:39:53 -0700403}