blob: 8d6451748c5b2f879ccc8311b024bd98706b1718 [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;
Pier3e793752018-04-19 16:47:06 +020028import org.onosproject.segmentrouting.mcast.McastRoleStoreKey;
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -070029import org.onosproject.segmentrouting.pwaas.DefaultL2TunnelDescription;
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -080030import org.onosproject.segmentrouting.pwaas.L2Tunnel;
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -070031import org.onosproject.segmentrouting.pwaas.L2TunnelHandler;
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -080032import org.onosproject.segmentrouting.pwaas.L2TunnelPolicy;
Andreas Pantelopouloscd339592018-02-23 14:18:00 -080033import org.onosproject.segmentrouting.pwaas.L2TunnelDescription;
Saurav Das7bcbe702017-06-13 15:35:54 -070034import org.onosproject.segmentrouting.storekey.DestinationSetNextObjectiveStoreKey;
Saurav Dasc88d4662017-05-15 15:34:25 -070035
36import com.google.common.collect.ImmutableMap;
Pier3e793752018-04-19 16:47:06 +020037import org.onosproject.segmentrouting.mcast.McastStoreKey;
Charles Chanc81c45b2016-10-20 17:02:44 -070038
sangho1e575652015-05-14 00:39:53 -070039import java.util.List;
Charles Chanc81c45b2016-10-20 17:02:44 -070040import java.util.Map;
41import java.util.Set;
sangho1e575652015-05-14 00:39:53 -070042
43/**
44 * Segment Routing Service for REST API.
45 */
46public interface SegmentRoutingService {
Charles Chan5270ed02016-01-30 23:22:37 -080047 /**
Charles Chanf76de302018-06-15 18:54:18 -070048 * VLAN cross-connect ACL priority.
49 */
50 int XCONNECT_ACL_PRIORITY = 60000;
51
52 /**
53 * VLAN cross-connect Bridging priority.
Charles Chan5270ed02016-01-30 23:22:37 -080054 */
55 int XCONNECT_PRIORITY = 1000;
56
57 /**
58 * Default flow priority.
59 */
60 int DEFAULT_PRIORITY = 100;
61
62 /**
63 * Minimum IP priority.
64 *
Charles Chanb54e8ba2016-02-18 10:43:46 -080065 * Should < 0 such that priority of /0 will not conflict with lowest
Charles Chan5270ed02016-01-30 23:22:37 -080066 * priority default entries.
67 */
68 int MIN_IP_PRIORITY = 10;
69
70 /**
71 * Subnet flooding flow priority.
72 */
73 int FLOOD_PRIORITY = 5;
74
sangho1e575652015-05-14 00:39:53 -070075 /**
76 * Returns all tunnels.
77 *
78 * @return list of tunnels
79 */
80 List<Tunnel> getTunnels();
81
82 /**
83 * Creates a tunnel.
84 *
85 * @param tunnel tunnel reference to create
sangho71abe1b2015-06-29 14:58:47 -070086 * @return WRONG_PATH if the tunnel path is wrong, ID_EXISTS if the tunnel ID
87 * exists already, TUNNEL_EXISTS if the same tunnel exists, INTERNAL_ERROR
88 * if the tunnel creation failed internally, SUCCESS if the tunnel is created
89 * successfully
sangho1e575652015-05-14 00:39:53 -070090 */
sangho71abe1b2015-06-29 14:58:47 -070091 TunnelHandler.Result createTunnel(Tunnel tunnel);
sangho1e575652015-05-14 00:39:53 -070092
93 /**
94 * Returns all policies.
95 *
96 * @return list of policy
97 */
98 List<Policy> getPolicies();
99
100 /**
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -0700101 * Returns the l2 tunnel descriptions.
102 *
Andreas Pantelopoulos811bbae2018-03-15 16:56:09 -0700103 * @param pending if true fetch pending pseudowires, else fetch installed
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -0700104 * @return set of l2 tunnel descriptions.
105 */
Andreas Pantelopoulos811bbae2018-03-15 16:56:09 -0700106 Set<L2TunnelDescription> getL2TunnelDescriptions(boolean pending);
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -0700107
108 /**
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700109 * Returns all l2 tunnels of pseudowires.
110 *
111 * @return list of l2 tunnels
112 */
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -0800113 List<L2Tunnel> getL2Tunnels();
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700114
115 /**
116 * Returns all l2 policie of pseudowires.
117 *
118 * @return list of l2 policies.
119 */
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -0800120 List<L2TunnelPolicy> getL2Policies();
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700121
122 /**
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -0700123 * Removes pseudowire.
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700124 *
Andreas Pantelopouloscd339592018-02-23 14:18:00 -0800125 * @param pwId The id of the pseudowire.
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700126 * @return SUCCESS if operation successful or a descriptive error otherwise.
127 */
Andreas Pantelopouloscd339592018-02-23 14:18:00 -0800128 L2TunnelHandler.Result removePseudowire(Integer pwId);
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700129
130 /**
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -0700131 * Adds a Pseudowire to the system.
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700132 *
Andreas Pantelopouloscd339592018-02-23 14:18:00 -0800133 * @param tunnel The pseudowire tunnel.
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700134 * @return SUCCESS if operation is successful or a descriptive error otherwise.
135 */
Andreas Pantelopouloscd339592018-02-23 14:18:00 -0800136 L2TunnelHandler.Result addPseudowire(L2TunnelDescription tunnel);
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700137
138 /**
Andreas Pantelopoulosffe69742018-03-20 13:58:49 -0700139 * Adds a set of pseudowires.
140 *
141 *
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -0700142 * @param l2TunnelDescriptions The pseudowires to add.
143 * @return SUCCESS if ALL pseudowires can be instantiated and are deployed, or a
144 * a descriptive error otherwise, without deploying any pseudowire.
Andreas Pantelopoulosffe69742018-03-20 13:58:49 -0700145 * @deprecated onos-1.12 use addPseudowire instead
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -0700146 */
Andreas Pantelopoulosffe69742018-03-20 13:58:49 -0700147 @Deprecated
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -0700148 L2TunnelHandler.Result addPseudowiresBulk(List<DefaultL2TunnelDescription> l2TunnelDescriptions);
149
150 /**
sangho1e575652015-05-14 00:39:53 -0700151 * Creates a policy.
152 *
153 * @param policy policy reference to create
sangho71abe1b2015-06-29 14:58:47 -0700154 * @return ID_EXISTS if the same policy ID exists,
155 * POLICY_EXISTS if the same policy exists, TUNNEL_NOT_FOUND if the tunnel
156 * does not exists, UNSUPPORTED_TYPE if the policy type is not supported,
157 * SUCCESS if the policy is created successfully.
sangho1e575652015-05-14 00:39:53 -0700158 */
sangho71abe1b2015-06-29 14:58:47 -0700159 PolicyHandler.Result createPolicy(Policy policy);
sangho1e575652015-05-14 00:39:53 -0700160
161 /**
162 * Removes a tunnel.
163 *
164 * @param tunnel tunnel reference to remove
sangho71abe1b2015-06-29 14:58:47 -0700165 * @return TUNNEL_NOT_FOUND if the tunnel to remove does not exists,
166 * INTERNAL_ERROR if the tunnel creation failed internally, SUCCESS
167 * if the tunnel is created successfully.
sangho1e575652015-05-14 00:39:53 -0700168 */
sangho71abe1b2015-06-29 14:58:47 -0700169 TunnelHandler.Result removeTunnel(Tunnel tunnel);
sangho1e575652015-05-14 00:39:53 -0700170
171 /**
172 * Removes a policy.
173 *
174 * @param policy policy reference to remove
sangho71abe1b2015-06-29 14:58:47 -0700175 * @return POLICY_NOT_FOUND if the policy to remove does not exists,
176 * SUCCESS if it is removed successfully
sangho1e575652015-05-14 00:39:53 -0700177 */
sangho71abe1b2015-06-29 14:58:47 -0700178 PolicyHandler.Result removePolicy(Policy policy);
Saurav Das59232cf2016-04-27 18:35:50 -0700179
180 /**
181 * Use current state of the network to repopulate forwarding rules.
182 *
183 */
184 void rerouteNetwork();
Charles Chanc81c45b2016-10-20 17:02:44 -0700185
186 /**
187 * Returns device-subnet mapping.
188 *
189 * @return device-subnet mapping
190 */
Pier Ventre10bd8d12016-11-26 21:05:22 -0800191 Map<DeviceId, Set<IpPrefix>> getDeviceSubnetMap();
Saurav Dasc88d4662017-05-15 15:34:25 -0700192
193 /**
194 * Returns the current ECMP shortest path graph in this controller instance.
195 *
196 * @return ECMP shortest path graph
197 */
198 ImmutableMap<DeviceId, EcmpShortestPathGraph> getCurrentEcmpSpg();
199
200 /**
Saurav Das7bcbe702017-06-13 15:35:54 -0700201 * Returns the destinatiomSet-NextObjective store contents.
Saurav Dasc88d4662017-05-15 15:34:25 -0700202 *
Saurav Das7bcbe702017-06-13 15:35:54 -0700203 * @return current contents of the destinationSetNextObjectiveStore
Saurav Dasc88d4662017-05-15 15:34:25 -0700204 */
Saurav Das7bcbe702017-06-13 15:35:54 -0700205 ImmutableMap<DestinationSetNextObjectiveStoreKey, NextNeighbors> getDestinationSet();
Saurav Dasceccf242017-08-03 18:30:35 -0700206
207 /**
208 * Triggers the verification of all ECMP groups in the specified device.
209 * Adjusts the group buckets if verification finds that there are more or less
210 * buckets than what should be there.
211 *
212 * @param id the device identifier
213 */
214 void verifyGroups(DeviceId id);
Saurav Dasc568c342018-01-25 09:49:01 -0800215
216 /**
217 * Returns the internal link state as seen by this instance of the
218 * controller.
219 *
220 * @return the internal link state
221 */
222 ImmutableMap<Link, Boolean> getSeenLinks();
223
224 /**
225 * Returns the ports administratively disabled by the controller.
226 *
227 * @return a map of devices and port numbers for administratively disabled
228 * ports. Does not include ports manually disabled by the operator.
229 */
230 ImmutableMap<DeviceId, Set<PortNumber>> getDownedPortState();
Pier Luigib29144d2018-01-15 18:06:43 +0100231
Pier3e793752018-04-19 16:47:06 +0200232 /**
Pier Luigib29144d2018-01-15 18:06:43 +0100233 * Returns the associated next ids to the mcast groups or to the single
234 * group if mcastIp is present.
235 *
236 * @param mcastIp the group ip
237 * @return the mapping mcastIp-device to next id
238 */
239 Map<McastStoreKey, Integer> getMcastNextIds(IpAddress mcastIp);
240
241 /**
242 * Returns the associated roles to the mcast groups or to the single
243 * group if mcastIp is present.
244 *
245 * @param mcastIp the group ip
246 * @return the mapping mcastIp-device to mcast role
Pierb1fe7382018-04-17 17:25:22 +0200247 *
248 * @deprecated in 1.12 ("Magpie") release.
Pier Luigib29144d2018-01-15 18:06:43 +0100249 */
Pierb1fe7382018-04-17 17:25:22 +0200250 @Deprecated
Pier Luigi96fe0772018-02-28 12:10:50 +0100251 Map<McastStoreKey, McastRole> getMcastRoles(IpAddress mcastIp);
Pier Luigib29144d2018-01-15 18:06:43 +0100252
253 /**
Pier3e793752018-04-19 16:47:06 +0200254 * Returns the associated roles to the mcast groups.
255 *
256 * @param mcastIp the group ip
257 * @param sourcecp the source connect point
258 * @return the mapping mcastIp-device to mcast role
259 */
260 Map<McastRoleStoreKey, McastRole> getMcastRoles(IpAddress mcastIp,
261 ConnectPoint sourcecp);
262
263 /**
Pier Luigib29144d2018-01-15 18:06:43 +0100264 * Returns the associated paths to the mcast group.
265 *
266 * @param mcastIp the group ip
267 * @return the mapping egress point to mcast path
Pierb1fe7382018-04-17 17:25:22 +0200268 *
269 * @deprecated in 1.12 ("Magpie") release.
Pier Luigib29144d2018-01-15 18:06:43 +0100270 */
Pierb1fe7382018-04-17 17:25:22 +0200271 @Deprecated
Pier Luigib29144d2018-01-15 18:06:43 +0100272 Map<ConnectPoint, List<ConnectPoint>> getMcastPaths(IpAddress mcastIp);
273
Pierb1fe7382018-04-17 17:25:22 +0200274 /**
275 * Returns the associated trees to the mcast group.
276 *
277 * @param mcastIp the group ip
278 * @param sourcecp the source connect point
279 * @return the mapping egress point to mcast path
280 */
281 Multimap<ConnectPoint, List<ConnectPoint>> getMcastTrees(IpAddress mcastIp,
282 ConnectPoint sourcecp);
283
Pier96f63cb2018-04-17 16:29:56 +0200284 /**
285 * Return the leaders of the mcast groups.
286 *
287 * @param mcastIp the group ip
288 * @return the mapping group-node
289 */
290 Map<IpAddress, NodeId> getMcastLeaders(IpAddress mcastIp);
Charles Chan8bc75ee2018-04-17 18:56:53 -0700291
292 /**
293 * Returns shouldProgram map.
294 *
295 * @return shouldProgram map
296 */
297 Map<Set<DeviceId>, NodeId> getShouldProgram();
298
299 /**
300 * Returns shouldProgram local cache.
301 *
302 * @return shouldProgram local cache
303 */
304 Map<DeviceId, Boolean> getShouldProgramCache();
sangho1e575652015-05-14 00:39:53 -0700305}