blob: 2f7fa32b0c07ae71c8ca41c0ea1503e12b8076a0 [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
Pier Ventre42287df2016-11-09 14:17:26 -080019import java.util.List;
20import java.util.Set;
Pier Ventre42287df2016-11-09 14:17:26 -080021
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -080022public interface L2TunnelHandler {
23 void init();
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -070024
Pier Ventre70d53ba2016-11-17 22:26:29 -080025 /**
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -070026 * Combines policies and tunnels to create descriptions.
27 *
Andreas Pantelopoulos811bbae2018-03-15 16:56:09 -070028 * @param pending if it is true return pending to be installed pseudowires
29 * from the appropriate store, else return installed pseudowires
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -070030 * @return Set of l2 tunnel descriptions.
31 */
Andreas Pantelopoulos811bbae2018-03-15 16:56:09 -070032 Set<L2TunnelDescription> getL2Descriptions(boolean pending);
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -070033
34 /**
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -080035 * Returns a copy of the l2 policies that exist in the store.
Pier Ventre42287df2016-11-09 14:17:26 -080036 *
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -080037 * @return The l2 policies
Pier Ventre42287df2016-11-09 14:17:26 -080038 */
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -080039 List<L2TunnelPolicy> getL2Policies();
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -070040
41 /**
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -080042 * Returns a copy of the l2 tunnels that exist in the store.
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -070043 *
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -080044 * @return The l2 tunnels.
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -070045 */
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -080046 List<L2Tunnel> getL2Tunnels();
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -070047
48 /**
Andreas Pantelopoulos811bbae2018-03-15 16:56:09 -070049 * Returns a copy of the pending l2 policies that exist in the store.
50 *
51 * @return The l2 policies
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -070052 */
Andreas Pantelopoulos811bbae2018-03-15 16:56:09 -070053 List<L2TunnelPolicy> getL2PendingPolicies();
54
55 /**
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -070056 * Helper function to handle the pw removal.
57 * <p>
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -080058 * This method should for the mastership of the device because it is
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -070059 * used only from network configuration updates, thus we only want
60 * one instance only to program each pseudowire.
Pier Ventre42287df2016-11-09 14:17:26 -080061 *
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -070062 * @param pwToRemove the pseudo wires to remove
Andreas Pantelopoulosffe69742018-03-20 13:58:49 -070063 * @deprecated onos-1.12 Do not use this method.
Pier Ventre42287df2016-11-09 14:17:26 -080064 */
Andreas Pantelopoulosffe69742018-03-20 13:58:49 -070065 @Deprecated
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -080066 void tearDown(Set<L2TunnelDescription> pwToRemove);
Pier Ventre42287df2016-11-09 14:17:26 -080067
68 /**
Andreas Pantelopoulosffe69742018-03-20 13:58:49 -070069 * Returns a copy of the pending l2 tunnels that exist in the store.
70 *
71 * @return The l2 tunnels.
72 */
73 List<L2Tunnel> getL2PendingTunnels();
74
75 /**
Andreas Pantelopoulos935d59d2018-03-21 16:44:18 -070076 * Verifies global validity for existing pseudowires, both ones in
77 * the pending store and the ones installed.
78 *
79 * @param pwToAdd the new pseudowire to add
80 * @return a Result describing the outcome
81 */
82 Result verifyGlobalValidity(L2TunnelDescription pwToAdd);
83
84 /**
85 * Check if pseudowire exists in the store.
86 *
87 * @param tunnelId The tunnel id to check for.
88 * @param pending Check in pending store for pseudowires.
89 * @return The result of the operation.
90 */
91 Result checkIfPwExists(long tunnelId, boolean pending);
92
93 /**
Pier Luigi3bfe32c2017-01-30 09:47:36 -080094 * Pwaas pipelines.
Pier Ventre42287df2016-11-09 14:17:26 -080095 */
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -080096 enum Pipeline {
Pier Ventre42287df2016-11-09 14:17:26 -080097 /**
98 * The initiation pipeline.
99 */
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700100 INITIATION, /**
Pier Ventre42287df2016-11-09 14:17:26 -0800101 * The termination pipeline.
102 */
Pier Ventre70d53ba2016-11-17 22:26:29 -0800103 TERMINATION
Pier Ventre42287df2016-11-09 14:17:26 -0800104 }
105
106 /**
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700107 * Enum helper to carry results of various operations.
Pier Ventre42287df2016-11-09 14:17:26 -0800108 */
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -0800109 enum Result {
Pier Ventre42287df2016-11-09 14:17:26 -0800110 /**
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700111 * Happy ending scenario.
Pier Ventre42287df2016-11-09 14:17:26 -0800112 */
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700113 SUCCESS(0, "No error occurred"),
114
Pier Ventre42287df2016-11-09 14:17:26 -0800115 /**
116 * We have problems with the supplied parameters.
117 */
118 WRONG_PARAMETERS(1, "Wrong parameters"),
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700119
Pier Ventre42287df2016-11-09 14:17:26 -0800120 /**
121 * We have an internal error during the deployment
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700122 * or removal phase.
Pier Ventre42287df2016-11-09 14:17:26 -0800123 */
124 INTERNAL_ERROR(3, "Internal error"),
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700125
Pier Ventre42287df2016-11-09 14:17:26 -0800126 /**
Andreas Pantelopoulos935d59d2018-03-21 16:44:18 -0700127 * No path found between the connection points.
Pier Ventre42287df2016-11-09 14:17:26 -0800128 */
Andreas Pantelopoulosffe69742018-03-20 13:58:49 -0700129 PATH_NOT_FOUND(7, "Could not find valid path between connection points!"),
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700130
131 /**
Andreas Pantelopoulos935d59d2018-03-21 16:44:18 -0700132 * Error in global pseudowires configuration.
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700133 */
Andreas Pantelopoulosffe69742018-03-20 13:58:49 -0700134 CONFIGURATION_ERROR(8, "Conflicting pseudowire configurations!");
Pier Ventre42287df2016-11-09 14:17:26 -0800135
136 private final int code;
137 private final String description;
Andreas Pantelopoulosffe69742018-03-20 13:58:49 -0700138
139 private String specificError;
140 public int nextId;
Pier Ventre42287df2016-11-09 14:17:26 -0800141
Pier Ventre70d53ba2016-11-17 22:26:29 -0800142 Result(int code, String description) {
Pier Ventre42287df2016-11-09 14:17:26 -0800143 this.code = code;
144 this.description = description;
145 }
146
Andreas Pantelopoulosffe69742018-03-20 13:58:49 -0700147 public Result appendError(String error) {
148 this.specificError = error;
149 return this;
150 }
151
152 public String getSpecificError() {
153 return specificError;
154 }
155
Pier Ventre42287df2016-11-09 14:17:26 -0800156 public String getDescription() {
157 return description;
158 }
159
Pier Ventre42287df2016-11-09 14:17:26 -0800160 @Override
161 public String toString() {
162 return code + ": " + description;
163 }
164 }
165
Pier Ventre70d53ba2016-11-17 22:26:29 -0800166 /**
167 * Enum helper for handling the direction of the pw.
168 */
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -0800169 enum Direction {
Pier Ventre70d53ba2016-11-17 22:26:29 -0800170 /**
171 * The forward direction of the pseudo wire.
172 */
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700173 FWD, /**
Pier Ventre70d53ba2016-11-17 22:26:29 -0800174 * The reverse direction of the pseudo wire.
175 */
Jon Hall8c7b06a2017-02-22 13:37:33 -0800176 REV
Pier Ventre70d53ba2016-11-17 22:26:29 -0800177 }
Pier Ventref34966c2016-11-07 16:21:04 -0800178}