blob: 2a003b3ff51e3bacd979eb817cd0e9da09377011 [file] [log] [blame]
Pier Ventref34966c2016-11-07 16:21:04 -08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Pier Ventref34966c2016-11-07 16:21:04 -08003 *
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 */
16
17package org.onosproject.segmentrouting.pwaas;
18
Charles Chand5814aa2018-08-19 19:21:46 -070019import com.google.common.collect.ImmutableMap;
20import org.onosproject.net.flowobjective.NextObjective;
21
Pier Ventre42287df2016-11-09 14:17:26 -080022import java.util.List;
23import java.util.Set;
Pier Ventre42287df2016-11-09 14:17:26 -080024
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -080025public interface L2TunnelHandler {
26 void init();
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -070027
Pier Ventre70d53ba2016-11-17 22:26:29 -080028 /**
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -070029 * Combines policies and tunnels to create descriptions.
30 *
Andreas Pantelopoulos811bbae2018-03-15 16:56:09 -070031 * @param pending if it is true return pending to be installed pseudowires
32 * from the appropriate store, else return installed pseudowires
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -070033 * @return Set of l2 tunnel descriptions.
34 */
Andreas Pantelopoulos811bbae2018-03-15 16:56:09 -070035 Set<L2TunnelDescription> getL2Descriptions(boolean pending);
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -070036
37 /**
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -080038 * Returns a copy of the l2 policies that exist in the store.
Pier Ventre42287df2016-11-09 14:17:26 -080039 *
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -080040 * @return The l2 policies
Pier Ventre42287df2016-11-09 14:17:26 -080041 */
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -080042 List<L2TunnelPolicy> getL2Policies();
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -070043
44 /**
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -080045 * Returns a copy of the l2 tunnels that exist in the store.
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -070046 *
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -080047 * @return The l2 tunnels.
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -070048 */
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -080049 List<L2Tunnel> getL2Tunnels();
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -070050
51 /**
Andreas Pantelopoulos811bbae2018-03-15 16:56:09 -070052 * Returns a copy of the pending l2 policies that exist in the store.
53 *
54 * @return The l2 policies
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -070055 */
Andreas Pantelopoulos811bbae2018-03-15 16:56:09 -070056 List<L2TunnelPolicy> getL2PendingPolicies();
57
58 /**
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -070059 * Helper function to handle the pw removal.
60 * <p>
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -080061 * This method should for the mastership of the device because it is
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -070062 * used only from network configuration updates, thus we only want
63 * one instance only to program each pseudowire.
Pier Ventre42287df2016-11-09 14:17:26 -080064 *
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -070065 * @param pwToRemove the pseudo wires to remove
Andreas Pantelopoulosffe69742018-03-20 13:58:49 -070066 * @deprecated onos-1.12 Do not use this method.
Pier Ventre42287df2016-11-09 14:17:26 -080067 */
Andreas Pantelopoulosffe69742018-03-20 13:58:49 -070068 @Deprecated
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -080069 void tearDown(Set<L2TunnelDescription> pwToRemove);
Pier Ventre42287df2016-11-09 14:17:26 -080070
71 /**
Andreas Pantelopoulosffe69742018-03-20 13:58:49 -070072 * Returns a copy of the pending l2 tunnels that exist in the store.
73 *
74 * @return The l2 tunnels.
75 */
76 List<L2Tunnel> getL2PendingTunnels();
77
78 /**
Andreas Pantelopoulos935d59d2018-03-21 16:44:18 -070079 * Verifies global validity for existing pseudowires, both ones in
80 * the pending store and the ones installed.
81 *
82 * @param pwToAdd the new pseudowire to add
83 * @return a Result describing the outcome
84 */
85 Result verifyGlobalValidity(L2TunnelDescription pwToAdd);
86
87 /**
88 * Check if pseudowire exists in the store.
89 *
90 * @param tunnelId The tunnel id to check for.
91 * @param pending Check in pending store for pseudowires.
92 * @return The result of the operation.
93 */
94 Result checkIfPwExists(long tunnelId, boolean pending);
95
96 /**
Charles Chand5814aa2018-08-19 19:21:46 -070097 * Returns the PW init next objective store.
98 *
99 * @return current contents of the l2InitiationNextObjStore
100 */
101 ImmutableMap<String, NextObjective> getInitNext();
102
103 /**
104 * Returns the PW termination next objective store.
105 *
106 * @return current contents of the l2TerminationNextObjStore
107 */
108 ImmutableMap<String, NextObjective> getTermNext();
109
110 /**
111 * Removes given next ID from both PW init/term next obj store.
112 *
113 * @param nextId next ID
114 */
115 void removeNextId(int nextId);
116
117 /**
Pier Luigi3bfe32c2017-01-30 09:47:36 -0800118 * Pwaas pipelines.
Pier Ventre42287df2016-11-09 14:17:26 -0800119 */
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -0800120 enum Pipeline {
Pier Ventre42287df2016-11-09 14:17:26 -0800121 /**
122 * The initiation pipeline.
123 */
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700124 INITIATION, /**
Pier Ventre42287df2016-11-09 14:17:26 -0800125 * The termination pipeline.
126 */
Pier Ventre70d53ba2016-11-17 22:26:29 -0800127 TERMINATION
Pier Ventre42287df2016-11-09 14:17:26 -0800128 }
129
130 /**
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700131 * Enum helper to carry results of various operations.
Pier Ventre42287df2016-11-09 14:17:26 -0800132 */
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -0800133 enum Result {
Pier Ventre42287df2016-11-09 14:17:26 -0800134 /**
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700135 * Happy ending scenario.
Pier Ventre42287df2016-11-09 14:17:26 -0800136 */
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700137 SUCCESS(0, "No error occurred"),
138
Pier Ventre42287df2016-11-09 14:17:26 -0800139 /**
140 * We have problems with the supplied parameters.
141 */
142 WRONG_PARAMETERS(1, "Wrong parameters"),
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700143
Pier Ventre42287df2016-11-09 14:17:26 -0800144 /**
145 * We have an internal error during the deployment
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700146 * or removal phase.
Pier Ventre42287df2016-11-09 14:17:26 -0800147 */
148 INTERNAL_ERROR(3, "Internal error"),
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700149
Pier Ventre42287df2016-11-09 14:17:26 -0800150 /**
Andreas Pantelopoulos935d59d2018-03-21 16:44:18 -0700151 * No path found between the connection points.
Pier Ventre42287df2016-11-09 14:17:26 -0800152 */
Andreas Pantelopoulosffe69742018-03-20 13:58:49 -0700153 PATH_NOT_FOUND(7, "Could not find valid path between connection points!"),
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700154
155 /**
Andreas Pantelopoulos935d59d2018-03-21 16:44:18 -0700156 * Error in global pseudowires configuration.
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700157 */
Andreas Pantelopoulosffe69742018-03-20 13:58:49 -0700158 CONFIGURATION_ERROR(8, "Conflicting pseudowire configurations!");
Pier Ventre42287df2016-11-09 14:17:26 -0800159
160 private final int code;
161 private final String description;
Andreas Pantelopoulosffe69742018-03-20 13:58:49 -0700162
163 private String specificError;
Andreas Pantelopoulosdaf02c82018-04-04 11:16:56 -0700164 private int nextId;
Pier Ventre42287df2016-11-09 14:17:26 -0800165
Pier Ventre70d53ba2016-11-17 22:26:29 -0800166 Result(int code, String description) {
Pier Ventre42287df2016-11-09 14:17:26 -0800167 this.code = code;
168 this.description = description;
169 }
170
Andreas Pantelopoulosffe69742018-03-20 13:58:49 -0700171 public Result appendError(String error) {
172 this.specificError = error;
173 return this;
174 }
175
176 public String getSpecificError() {
177 return specificError;
178 }
179
Pier Ventre42287df2016-11-09 14:17:26 -0800180 public String getDescription() {
181 return description;
182 }
183
Andreas Pantelopoulosdaf02c82018-04-04 11:16:56 -0700184 public int getNextId() {
185 return nextId;
186 }
187
Ray Milkey6fc64c12018-04-12 09:35:33 -0700188 protected void setNextId(int nextId) {
Andreas Pantelopoulosdaf02c82018-04-04 11:16:56 -0700189 this.nextId = nextId;
190 }
191
Pier Ventre42287df2016-11-09 14:17:26 -0800192 @Override
193 public String toString() {
194 return code + ": " + description;
195 }
196 }
197
Pier Ventre70d53ba2016-11-17 22:26:29 -0800198 /**
199 * Enum helper for handling the direction of the pw.
200 */
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -0800201 enum Direction {
Pier Ventre70d53ba2016-11-17 22:26:29 -0800202 /**
203 * The forward direction of the pseudo wire.
204 */
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700205 FWD, /**
Pier Ventre70d53ba2016-11-17 22:26:29 -0800206 * The reverse direction of the pseudo wire.
207 */
Jon Hall8c7b06a2017-02-22 13:37:33 -0800208 REV
Pier Ventre70d53ba2016-11-17 22:26:29 -0800209 }
Pier Ventref34966c2016-11-07 16:21:04 -0800210}