blob: 03ef5b5c235b29e8a7e9c92aa022cc087841a8ca [file] [log] [blame]
sangho27462c62015-05-14 00:39:53 -07001/*
Brian O'Connor0947d7e2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
sangho27462c62015-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
Pier71c55772018-04-17 17:25:22 +020018import com.google.common.collect.Multimap;
Pier Luigi0f9635b2018-01-15 18:06:43 +010019import org.onlab.packet.IpAddress;
Pier Ventreb6a7f342016-11-26 21:05:22 -080020import org.onlab.packet.IpPrefix;
Pierdb27b8d2018-04-17 16:29:56 +020021import org.onosproject.cluster.NodeId;
Pier Luigi0f9635b2018-01-15 18:06:43 +010022import org.onosproject.net.ConnectPoint;
Charles Chand7844e52016-10-20 17:02:44 -070023import org.onosproject.net.DeviceId;
Saurav Das6430f412018-01-25 09:49:01 -080024import org.onosproject.net.Link;
25import org.onosproject.net.PortNumber;
Saurav Das261c3002017-06-13 15:35:54 -070026import org.onosproject.segmentrouting.grouphandler.NextNeighbors;
Pier Luigi69f774d2018-02-28 12:10:50 +010027import org.onosproject.segmentrouting.mcast.McastRole;
Piere99511d2018-04-19 16:47:06 +020028import org.onosproject.segmentrouting.mcast.McastRoleStoreKey;
Andreas Pantelopoulosfc4bc2a2018-03-12 16:30:20 -070029import org.onosproject.segmentrouting.pwaas.DefaultL2TunnelDescription;
Andreas Pantelopoulos4c7de132018-02-22 12:32:42 -080030import org.onosproject.segmentrouting.pwaas.L2Tunnel;
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -070031import org.onosproject.segmentrouting.pwaas.L2TunnelHandler;
Andreas Pantelopoulos4c7de132018-02-22 12:32:42 -080032import org.onosproject.segmentrouting.pwaas.L2TunnelPolicy;
Andreas Pantelopouloscdbb22c2018-02-23 14:18:00 -080033import org.onosproject.segmentrouting.pwaas.L2TunnelDescription;
Saurav Das261c3002017-06-13 15:35:54 -070034import org.onosproject.segmentrouting.storekey.DestinationSetNextObjectiveStoreKey;
Saurav Das62ae6792017-05-15 15:34:25 -070035
36import com.google.common.collect.ImmutableMap;
Piere99511d2018-04-19 16:47:06 +020037import org.onosproject.segmentrouting.mcast.McastStoreKey;
Charles Chand7844e52016-10-20 17:02:44 -070038
sangho27462c62015-05-14 00:39:53 -070039import java.util.List;
Charles Chand7844e52016-10-20 17:02:44 -070040import java.util.Map;
41import java.util.Set;
sangho27462c62015-05-14 00:39:53 -070042
43/**
44 * Segment Routing Service for REST API.
45 */
46public interface SegmentRoutingService {
Charles Chan82ab1932016-01-30 23:22:37 -080047 /**
Charles Chan82ab1932016-01-30 23:22:37 -080048 * VLAN cross-connect priority.
49 */
50 int XCONNECT_PRIORITY = 1000;
51
52 /**
53 * Default flow priority.
54 */
55 int DEFAULT_PRIORITY = 100;
56
57 /**
58 * Minimum IP priority.
59 *
Charles Chand86904c2016-02-18 10:43:46 -080060 * Should < 0 such that priority of /0 will not conflict with lowest
Charles Chan82ab1932016-01-30 23:22:37 -080061 * priority default entries.
62 */
63 int MIN_IP_PRIORITY = 10;
64
65 /**
66 * Subnet flooding flow priority.
67 */
68 int FLOOD_PRIORITY = 5;
69
sangho27462c62015-05-14 00:39:53 -070070 /**
71 * Returns all tunnels.
72 *
73 * @return list of tunnels
74 */
75 List<Tunnel> getTunnels();
76
77 /**
78 * Creates a tunnel.
79 *
80 * @param tunnel tunnel reference to create
sanghobd812f82015-06-29 14:58:47 -070081 * @return WRONG_PATH if the tunnel path is wrong, ID_EXISTS if the tunnel ID
82 * exists already, TUNNEL_EXISTS if the same tunnel exists, INTERNAL_ERROR
83 * if the tunnel creation failed internally, SUCCESS if the tunnel is created
84 * successfully
sangho27462c62015-05-14 00:39:53 -070085 */
sanghobd812f82015-06-29 14:58:47 -070086 TunnelHandler.Result createTunnel(Tunnel tunnel);
sangho27462c62015-05-14 00:39:53 -070087
88 /**
89 * Returns all policies.
90 *
91 * @return list of policy
92 */
93 List<Policy> getPolicies();
94
95 /**
Andreas Pantelopoulosfc4bc2a2018-03-12 16:30:20 -070096 * Returns the l2 tunnel descriptions.
97 *
Andreas Pantelopoulosd988c1a2018-03-15 16:56:09 -070098 * @param pending if true fetch pending pseudowires, else fetch installed
Andreas Pantelopoulosfc4bc2a2018-03-12 16:30:20 -070099 * @return set of l2 tunnel descriptions.
100 */
Andreas Pantelopoulosd988c1a2018-03-15 16:56:09 -0700101 Set<L2TunnelDescription> getL2TunnelDescriptions(boolean pending);
Andreas Pantelopoulosfc4bc2a2018-03-12 16:30:20 -0700102
103 /**
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -0700104 * Returns all l2 tunnels of pseudowires.
105 *
106 * @return list of l2 tunnels
107 */
Andreas Pantelopoulos4c7de132018-02-22 12:32:42 -0800108 List<L2Tunnel> getL2Tunnels();
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -0700109
110 /**
111 * Returns all l2 policie of pseudowires.
112 *
113 * @return list of l2 policies.
114 */
Andreas Pantelopoulos4c7de132018-02-22 12:32:42 -0800115 List<L2TunnelPolicy> getL2Policies();
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -0700116
117 /**
Andreas Pantelopoulosfc4bc2a2018-03-12 16:30:20 -0700118 * Removes pseudowire.
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -0700119 *
Andreas Pantelopouloscdbb22c2018-02-23 14:18:00 -0800120 * @param pwId The id of the pseudowire.
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -0700121 * @return SUCCESS if operation successful or a descriptive error otherwise.
122 */
Andreas Pantelopouloscdbb22c2018-02-23 14:18:00 -0800123 L2TunnelHandler.Result removePseudowire(Integer pwId);
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -0700124
125 /**
Andreas Pantelopoulosfc4bc2a2018-03-12 16:30:20 -0700126 * Adds a Pseudowire to the system.
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -0700127 *
Andreas Pantelopouloscdbb22c2018-02-23 14:18:00 -0800128 * @param tunnel The pseudowire tunnel.
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -0700129 * @return SUCCESS if operation is successful or a descriptive error otherwise.
130 */
Andreas Pantelopouloscdbb22c2018-02-23 14:18:00 -0800131 L2TunnelHandler.Result addPseudowire(L2TunnelDescription tunnel);
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -0700132
133 /**
Andreas Pantelopoulos96851252018-03-20 13:58:49 -0700134 * Adds a set of pseudowires.
135 *
136 *
Andreas Pantelopoulosfc4bc2a2018-03-12 16:30:20 -0700137 * @param l2TunnelDescriptions The pseudowires to add.
138 * @return SUCCESS if ALL pseudowires can be instantiated and are deployed, or a
139 * a descriptive error otherwise, without deploying any pseudowire.
Andreas Pantelopoulos96851252018-03-20 13:58:49 -0700140 * @deprecated onos-1.12 use addPseudowire instead
Andreas Pantelopoulosfc4bc2a2018-03-12 16:30:20 -0700141 */
Andreas Pantelopoulos96851252018-03-20 13:58:49 -0700142 @Deprecated
Andreas Pantelopoulosfc4bc2a2018-03-12 16:30:20 -0700143 L2TunnelHandler.Result addPseudowiresBulk(List<DefaultL2TunnelDescription> l2TunnelDescriptions);
144
145 /**
sangho27462c62015-05-14 00:39:53 -0700146 * Creates a policy.
147 *
148 * @param policy policy reference to create
sanghobd812f82015-06-29 14:58:47 -0700149 * @return ID_EXISTS if the same policy ID exists,
150 * POLICY_EXISTS if the same policy exists, TUNNEL_NOT_FOUND if the tunnel
151 * does not exists, UNSUPPORTED_TYPE if the policy type is not supported,
152 * SUCCESS if the policy is created successfully.
sangho27462c62015-05-14 00:39:53 -0700153 */
sanghobd812f82015-06-29 14:58:47 -0700154 PolicyHandler.Result createPolicy(Policy policy);
sangho27462c62015-05-14 00:39:53 -0700155
156 /**
157 * Removes a tunnel.
158 *
159 * @param tunnel tunnel reference to remove
sanghobd812f82015-06-29 14:58:47 -0700160 * @return TUNNEL_NOT_FOUND if the tunnel to remove does not exists,
161 * INTERNAL_ERROR if the tunnel creation failed internally, SUCCESS
162 * if the tunnel is created successfully.
sangho27462c62015-05-14 00:39:53 -0700163 */
sanghobd812f82015-06-29 14:58:47 -0700164 TunnelHandler.Result removeTunnel(Tunnel tunnel);
sangho27462c62015-05-14 00:39:53 -0700165
166 /**
167 * Removes a policy.
168 *
169 * @param policy policy reference to remove
sanghobd812f82015-06-29 14:58:47 -0700170 * @return POLICY_NOT_FOUND if the policy to remove does not exists,
171 * SUCCESS if it is removed successfully
sangho27462c62015-05-14 00:39:53 -0700172 */
sanghobd812f82015-06-29 14:58:47 -0700173 PolicyHandler.Result removePolicy(Policy policy);
Saurav Das07c74602016-04-27 18:35:50 -0700174
175 /**
176 * Use current state of the network to repopulate forwarding rules.
177 *
178 */
179 void rerouteNetwork();
Charles Chand7844e52016-10-20 17:02:44 -0700180
181 /**
182 * Returns device-subnet mapping.
183 *
184 * @return device-subnet mapping
185 */
Pier Ventreb6a7f342016-11-26 21:05:22 -0800186 Map<DeviceId, Set<IpPrefix>> getDeviceSubnetMap();
Saurav Das62ae6792017-05-15 15:34:25 -0700187
188 /**
189 * Returns the current ECMP shortest path graph in this controller instance.
190 *
191 * @return ECMP shortest path graph
192 */
193 ImmutableMap<DeviceId, EcmpShortestPathGraph> getCurrentEcmpSpg();
194
195 /**
Saurav Das261c3002017-06-13 15:35:54 -0700196 * Returns the destinatiomSet-NextObjective store contents.
Saurav Das62ae6792017-05-15 15:34:25 -0700197 *
Saurav Das261c3002017-06-13 15:35:54 -0700198 * @return current contents of the destinationSetNextObjectiveStore
Saurav Das62ae6792017-05-15 15:34:25 -0700199 */
Saurav Das261c3002017-06-13 15:35:54 -0700200 ImmutableMap<DestinationSetNextObjectiveStoreKey, NextNeighbors> getDestinationSet();
Saurav Dasfbe74572017-08-03 18:30:35 -0700201
202 /**
203 * Triggers the verification of all ECMP groups in the specified device.
204 * Adjusts the group buckets if verification finds that there are more or less
205 * buckets than what should be there.
206 *
207 * @param id the device identifier
208 */
209 void verifyGroups(DeviceId id);
Saurav Das6430f412018-01-25 09:49:01 -0800210
211 /**
212 * Returns the internal link state as seen by this instance of the
213 * controller.
214 *
215 * @return the internal link state
216 */
217 ImmutableMap<Link, Boolean> getSeenLinks();
218
219 /**
220 * Returns the ports administratively disabled by the controller.
221 *
222 * @return a map of devices and port numbers for administratively disabled
223 * ports. Does not include ports manually disabled by the operator.
224 */
225 ImmutableMap<DeviceId, Set<PortNumber>> getDownedPortState();
Pier Luigi0f9635b2018-01-15 18:06:43 +0100226
Piere99511d2018-04-19 16:47:06 +0200227 /**
Pier Luigi0f9635b2018-01-15 18:06:43 +0100228 * Returns the associated next ids to the mcast groups or to the single
229 * group if mcastIp is present.
230 *
231 * @param mcastIp the group ip
232 * @return the mapping mcastIp-device to next id
233 */
234 Map<McastStoreKey, Integer> getMcastNextIds(IpAddress mcastIp);
235
236 /**
237 * Returns the associated roles to the mcast groups or to the single
238 * group if mcastIp is present.
239 *
240 * @param mcastIp the group ip
241 * @return the mapping mcastIp-device to mcast role
Pier71c55772018-04-17 17:25:22 +0200242 *
243 * @deprecated in 1.12 ("Magpie") release.
Pier Luigi0f9635b2018-01-15 18:06:43 +0100244 */
Pier71c55772018-04-17 17:25:22 +0200245 @Deprecated
Pier Luigi69f774d2018-02-28 12:10:50 +0100246 Map<McastStoreKey, McastRole> getMcastRoles(IpAddress mcastIp);
Pier Luigi0f9635b2018-01-15 18:06:43 +0100247
248 /**
Piere99511d2018-04-19 16:47:06 +0200249 * Returns the associated roles to the mcast groups.
250 *
251 * @param mcastIp the group ip
252 * @param sourcecp the source connect point
253 * @return the mapping mcastIp-device to mcast role
254 */
255 Map<McastRoleStoreKey, McastRole> getMcastRoles(IpAddress mcastIp,
256 ConnectPoint sourcecp);
257
258 /**
Pier Luigi0f9635b2018-01-15 18:06:43 +0100259 * Returns the associated paths to the mcast group.
260 *
261 * @param mcastIp the group ip
262 * @return the mapping egress point to mcast path
Pier71c55772018-04-17 17:25:22 +0200263 *
264 * @deprecated in 1.12 ("Magpie") release.
Pier Luigi0f9635b2018-01-15 18:06:43 +0100265 */
Pier71c55772018-04-17 17:25:22 +0200266 @Deprecated
Pier Luigi0f9635b2018-01-15 18:06:43 +0100267 Map<ConnectPoint, List<ConnectPoint>> getMcastPaths(IpAddress mcastIp);
268
Pier71c55772018-04-17 17:25:22 +0200269 /**
270 * Returns the associated trees to the mcast group.
271 *
272 * @param mcastIp the group ip
273 * @param sourcecp the source connect point
274 * @return the mapping egress point to mcast path
275 */
276 Multimap<ConnectPoint, List<ConnectPoint>> getMcastTrees(IpAddress mcastIp,
277 ConnectPoint sourcecp);
278
Pierdb27b8d2018-04-17 16:29:56 +0200279 /**
280 * Return the leaders of the mcast groups.
281 *
282 * @param mcastIp the group ip
283 * @return the mapping group-node
284 */
285 Map<IpAddress, NodeId> getMcastLeaders(IpAddress mcastIp);
Charles Chanb13e0702018-04-17 18:56:53 -0700286
287 /**
288 * Returns shouldProgram map.
289 *
290 * @return shouldProgram map
291 */
292 Map<Set<DeviceId>, NodeId> getShouldProgram();
293
294 /**
295 * Returns shouldProgram local cache.
296 *
297 * @return shouldProgram local cache
298 */
299 Map<DeviceId, Boolean> getShouldProgramCache();
sangho27462c62015-05-14 00:39:53 -0700300}