blob: f52fad1eb41dfeffeb92d39f43c4ca449a4bfde6 [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
Pierb1fe7382018-04-17 17:25:22 +020018import com.google.common.collect.Multimap;
Pier Luigib29144d2018-01-15 18:06:43 +010019import org.onlab.packet.IpAddress;
Pier Ventre10bd8d12016-11-26 21:05:22 -080020import org.onlab.packet.IpPrefix;
Pier96f63cb2018-04-17 16:29:56 +020021import org.onosproject.cluster.NodeId;
Pier Luigib29144d2018-01-15 18:06:43 +010022import org.onosproject.net.ConnectPoint;
Charles Chanc81c45b2016-10-20 17:02:44 -070023import org.onosproject.net.DeviceId;
Saurav Dasc568c342018-01-25 09:49:01 -080024import org.onosproject.net.Link;
25import org.onosproject.net.PortNumber;
Saurav Das7bcbe702017-06-13 15:35:54 -070026import org.onosproject.segmentrouting.grouphandler.NextNeighbors;
Pier Luigi96fe0772018-02-28 12:10:50 +010027import org.onosproject.segmentrouting.mcast.McastRole;
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -070028import org.onosproject.segmentrouting.pwaas.DefaultL2TunnelDescription;
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -080029import org.onosproject.segmentrouting.pwaas.L2Tunnel;
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -070030import org.onosproject.segmentrouting.pwaas.L2TunnelHandler;
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -080031import org.onosproject.segmentrouting.pwaas.L2TunnelPolicy;
Andreas Pantelopouloscd339592018-02-23 14:18:00 -080032import org.onosproject.segmentrouting.pwaas.L2TunnelDescription;
Saurav Das7bcbe702017-06-13 15:35:54 -070033import org.onosproject.segmentrouting.storekey.DestinationSetNextObjectiveStoreKey;
Saurav Dasc88d4662017-05-15 15:34:25 -070034
35import com.google.common.collect.ImmutableMap;
Pier Luigib29144d2018-01-15 18:06:43 +010036import org.onosproject.segmentrouting.storekey.McastStoreKey;
Charles Chanc81c45b2016-10-20 17:02:44 -070037
sangho1e575652015-05-14 00:39:53 -070038import java.util.List;
Charles Chanc81c45b2016-10-20 17:02:44 -070039import java.util.Map;
40import java.util.Set;
sangho1e575652015-05-14 00:39:53 -070041
42/**
43 * Segment Routing Service for REST API.
44 */
45public interface SegmentRoutingService {
Charles Chan5270ed02016-01-30 23:22:37 -080046 /**
Charles Chan5270ed02016-01-30 23:22:37 -080047 * VLAN cross-connect priority.
48 */
49 int XCONNECT_PRIORITY = 1000;
50
51 /**
52 * Default flow priority.
53 */
54 int DEFAULT_PRIORITY = 100;
55
56 /**
57 * Minimum IP priority.
58 *
Charles Chanb54e8ba2016-02-18 10:43:46 -080059 * Should < 0 such that priority of /0 will not conflict with lowest
Charles Chan5270ed02016-01-30 23:22:37 -080060 * priority default entries.
61 */
62 int MIN_IP_PRIORITY = 10;
63
64 /**
65 * Subnet flooding flow priority.
66 */
67 int FLOOD_PRIORITY = 5;
68
sangho1e575652015-05-14 00:39:53 -070069 /**
70 * Returns all tunnels.
71 *
72 * @return list of tunnels
73 */
74 List<Tunnel> getTunnels();
75
76 /**
77 * Creates a tunnel.
78 *
79 * @param tunnel tunnel reference to create
sangho71abe1b2015-06-29 14:58:47 -070080 * @return WRONG_PATH if the tunnel path is wrong, ID_EXISTS if the tunnel ID
81 * exists already, TUNNEL_EXISTS if the same tunnel exists, INTERNAL_ERROR
82 * if the tunnel creation failed internally, SUCCESS if the tunnel is created
83 * successfully
sangho1e575652015-05-14 00:39:53 -070084 */
sangho71abe1b2015-06-29 14:58:47 -070085 TunnelHandler.Result createTunnel(Tunnel tunnel);
sangho1e575652015-05-14 00:39:53 -070086
87 /**
88 * Returns all policies.
89 *
90 * @return list of policy
91 */
92 List<Policy> getPolicies();
93
94 /**
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -070095 * Returns the l2 tunnel descriptions.
96 *
Andreas Pantelopoulos811bbae2018-03-15 16:56:09 -070097 * @param pending if true fetch pending pseudowires, else fetch installed
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -070098 * @return set of l2 tunnel descriptions.
99 */
Andreas Pantelopoulos811bbae2018-03-15 16:56:09 -0700100 Set<L2TunnelDescription> getL2TunnelDescriptions(boolean pending);
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -0700101
102 /**
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700103 * Returns all l2 tunnels of pseudowires.
104 *
105 * @return list of l2 tunnels
106 */
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -0800107 List<L2Tunnel> getL2Tunnels();
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700108
109 /**
110 * Returns all l2 policie of pseudowires.
111 *
112 * @return list of l2 policies.
113 */
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -0800114 List<L2TunnelPolicy> getL2Policies();
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700115
116 /**
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -0700117 * Removes pseudowire.
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700118 *
Andreas Pantelopouloscd339592018-02-23 14:18:00 -0800119 * @param pwId The id of the pseudowire.
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700120 * @return SUCCESS if operation successful or a descriptive error otherwise.
121 */
Andreas Pantelopouloscd339592018-02-23 14:18:00 -0800122 L2TunnelHandler.Result removePseudowire(Integer pwId);
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700123
124 /**
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -0700125 * Adds a Pseudowire to the system.
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700126 *
Andreas Pantelopouloscd339592018-02-23 14:18:00 -0800127 * @param tunnel The pseudowire tunnel.
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700128 * @return SUCCESS if operation is successful or a descriptive error otherwise.
129 */
Andreas Pantelopouloscd339592018-02-23 14:18:00 -0800130 L2TunnelHandler.Result addPseudowire(L2TunnelDescription tunnel);
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700131
132 /**
Andreas Pantelopoulosffe69742018-03-20 13:58:49 -0700133 * Adds a set of pseudowires.
134 *
135 *
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -0700136 * @param l2TunnelDescriptions The pseudowires to add.
137 * @return SUCCESS if ALL pseudowires can be instantiated and are deployed, or a
138 * a descriptive error otherwise, without deploying any pseudowire.
Andreas Pantelopoulosffe69742018-03-20 13:58:49 -0700139 * @deprecated onos-1.12 use addPseudowire instead
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -0700140 */
Andreas Pantelopoulosffe69742018-03-20 13:58:49 -0700141 @Deprecated
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -0700142 L2TunnelHandler.Result addPseudowiresBulk(List<DefaultL2TunnelDescription> l2TunnelDescriptions);
143
144 /**
sangho1e575652015-05-14 00:39:53 -0700145 * Creates a policy.
146 *
147 * @param policy policy reference to create
sangho71abe1b2015-06-29 14:58:47 -0700148 * @return ID_EXISTS if the same policy ID exists,
149 * POLICY_EXISTS if the same policy exists, TUNNEL_NOT_FOUND if the tunnel
150 * does not exists, UNSUPPORTED_TYPE if the policy type is not supported,
151 * SUCCESS if the policy is created successfully.
sangho1e575652015-05-14 00:39:53 -0700152 */
sangho71abe1b2015-06-29 14:58:47 -0700153 PolicyHandler.Result createPolicy(Policy policy);
sangho1e575652015-05-14 00:39:53 -0700154
155 /**
156 * Removes a tunnel.
157 *
158 * @param tunnel tunnel reference to remove
sangho71abe1b2015-06-29 14:58:47 -0700159 * @return TUNNEL_NOT_FOUND if the tunnel to remove does not exists,
160 * INTERNAL_ERROR if the tunnel creation failed internally, SUCCESS
161 * if the tunnel is created successfully.
sangho1e575652015-05-14 00:39:53 -0700162 */
sangho71abe1b2015-06-29 14:58:47 -0700163 TunnelHandler.Result removeTunnel(Tunnel tunnel);
sangho1e575652015-05-14 00:39:53 -0700164
165 /**
166 * Removes a policy.
167 *
168 * @param policy policy reference to remove
sangho71abe1b2015-06-29 14:58:47 -0700169 * @return POLICY_NOT_FOUND if the policy to remove does not exists,
170 * SUCCESS if it is removed successfully
sangho1e575652015-05-14 00:39:53 -0700171 */
sangho71abe1b2015-06-29 14:58:47 -0700172 PolicyHandler.Result removePolicy(Policy policy);
Saurav Das59232cf2016-04-27 18:35:50 -0700173
174 /**
175 * Use current state of the network to repopulate forwarding rules.
176 *
177 */
178 void rerouteNetwork();
Charles Chanc81c45b2016-10-20 17:02:44 -0700179
180 /**
181 * Returns device-subnet mapping.
182 *
183 * @return device-subnet mapping
184 */
Pier Ventre10bd8d12016-11-26 21:05:22 -0800185 Map<DeviceId, Set<IpPrefix>> getDeviceSubnetMap();
Saurav Dasc88d4662017-05-15 15:34:25 -0700186
187 /**
188 * Returns the current ECMP shortest path graph in this controller instance.
189 *
190 * @return ECMP shortest path graph
191 */
192 ImmutableMap<DeviceId, EcmpShortestPathGraph> getCurrentEcmpSpg();
193
194 /**
Saurav Das7bcbe702017-06-13 15:35:54 -0700195 * Returns the destinatiomSet-NextObjective store contents.
Saurav Dasc88d4662017-05-15 15:34:25 -0700196 *
Saurav Das7bcbe702017-06-13 15:35:54 -0700197 * @return current contents of the destinationSetNextObjectiveStore
Saurav Dasc88d4662017-05-15 15:34:25 -0700198 */
Saurav Das7bcbe702017-06-13 15:35:54 -0700199 ImmutableMap<DestinationSetNextObjectiveStoreKey, NextNeighbors> getDestinationSet();
Saurav Dasceccf242017-08-03 18:30:35 -0700200
201 /**
202 * Triggers the verification of all ECMP groups in the specified device.
203 * Adjusts the group buckets if verification finds that there are more or less
204 * buckets than what should be there.
205 *
206 * @param id the device identifier
207 */
208 void verifyGroups(DeviceId id);
Saurav Dasc568c342018-01-25 09:49:01 -0800209
210 /**
211 * Returns the internal link state as seen by this instance of the
212 * controller.
213 *
214 * @return the internal link state
215 */
216 ImmutableMap<Link, Boolean> getSeenLinks();
217
218 /**
219 * Returns the ports administratively disabled by the controller.
220 *
221 * @return a map of devices and port numbers for administratively disabled
222 * ports. Does not include ports manually disabled by the operator.
223 */
224 ImmutableMap<DeviceId, Set<PortNumber>> getDownedPortState();
Pier Luigib29144d2018-01-15 18:06:43 +0100225
226 /**
227 * Returns the associated next ids to the mcast groups or to the single
228 * group if mcastIp is present.
229 *
230 * @param mcastIp the group ip
231 * @return the mapping mcastIp-device to next id
232 */
233 Map<McastStoreKey, Integer> getMcastNextIds(IpAddress mcastIp);
234
235 /**
236 * Returns the associated roles 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 mcast role
Pierb1fe7382018-04-17 17:25:22 +0200241 *
242 * @deprecated in 1.12 ("Magpie") release.
Pier Luigib29144d2018-01-15 18:06:43 +0100243 */
Pierb1fe7382018-04-17 17:25:22 +0200244 @Deprecated
Pier Luigi96fe0772018-02-28 12:10:50 +0100245 Map<McastStoreKey, McastRole> getMcastRoles(IpAddress mcastIp);
Pier Luigib29144d2018-01-15 18:06:43 +0100246
247 /**
248 * Returns the associated paths to the mcast group.
249 *
250 * @param mcastIp the group ip
251 * @return the mapping egress point to mcast path
Pierb1fe7382018-04-17 17:25:22 +0200252 *
253 * @deprecated in 1.12 ("Magpie") release.
Pier Luigib29144d2018-01-15 18:06:43 +0100254 */
Pierb1fe7382018-04-17 17:25:22 +0200255 @Deprecated
Pier Luigib29144d2018-01-15 18:06:43 +0100256 Map<ConnectPoint, List<ConnectPoint>> getMcastPaths(IpAddress mcastIp);
257
Pierb1fe7382018-04-17 17:25:22 +0200258
259 /**
260 * Returns the associated trees to the mcast group.
261 *
262 * @param mcastIp the group ip
263 * @param sourcecp the source connect point
264 * @return the mapping egress point to mcast path
265 */
266 Multimap<ConnectPoint, List<ConnectPoint>> getMcastTrees(IpAddress mcastIp,
267 ConnectPoint sourcecp);
268
Pier96f63cb2018-04-17 16:29:56 +0200269 /**
270 * Return the leaders of the mcast groups.
271 *
272 * @param mcastIp the group ip
273 * @return the mapping group-node
274 */
275 Map<IpAddress, NodeId> getMcastLeaders(IpAddress mcastIp);
Charles Chan8bc75ee2018-04-17 18:56:53 -0700276
277 /**
278 * Returns shouldProgram map.
279 *
280 * @return shouldProgram map
281 */
282 Map<Set<DeviceId>, NodeId> getShouldProgram();
283
284 /**
285 * Returns shouldProgram local cache.
286 *
287 * @return shouldProgram local cache
288 */
289 Map<DeviceId, Boolean> getShouldProgramCache();
sangho1e575652015-05-14 00:39:53 -0700290}