blob: daabb07f6f88746ba0761a12055163126d5519f0 [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 /**
56 * Returns a copy of the pending l2 tunnels that exist in the store.
57 *
58 * @return The l2 tunnels.
59 */
60 List<L2Tunnel> getL2PendingTunnels();
Pier Ventref34966c2016-11-07 16:21:04 -080061
62 /**
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -070063 * Helper function to handle the pw removal.
64 * <p>
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -080065 * This method should for the mastership of the device because it is
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -070066 * used only from network configuration updates, thus we only want
67 * one instance only to program each pseudowire.
Pier Ventre42287df2016-11-09 14:17:26 -080068 *
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -070069 * @param pwToRemove the pseudo wires to remove
Pier Ventre42287df2016-11-09 14:17:26 -080070 */
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -080071 void tearDown(Set<L2TunnelDescription> pwToRemove);
Pier Ventre42287df2016-11-09 14:17:26 -080072
73 /**
Pier Luigi3bfe32c2017-01-30 09:47:36 -080074 * Pwaas pipelines.
Pier Ventre42287df2016-11-09 14:17:26 -080075 */
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -080076 enum Pipeline {
Pier Ventre42287df2016-11-09 14:17:26 -080077 /**
78 * The initiation pipeline.
79 */
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -070080 INITIATION, /**
Pier Ventre42287df2016-11-09 14:17:26 -080081 * The termination pipeline.
82 */
Pier Ventre70d53ba2016-11-17 22:26:29 -080083 TERMINATION
Pier Ventre42287df2016-11-09 14:17:26 -080084 }
85
86 /**
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -070087 * Enum helper to carry results of various operations.
Pier Ventre42287df2016-11-09 14:17:26 -080088 */
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -080089 enum Result {
Pier Ventre42287df2016-11-09 14:17:26 -080090 /**
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -070091 * Happy ending scenario.
Pier Ventre42287df2016-11-09 14:17:26 -080092 */
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -070093 SUCCESS(0, "No error occurred"),
94
Pier Ventre42287df2016-11-09 14:17:26 -080095 /**
96 * We have problems with the supplied parameters.
97 */
98 WRONG_PARAMETERS(1, "Wrong parameters"),
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -070099
Pier Ventre42287df2016-11-09 14:17:26 -0800100 /**
101 * We have an internal error during the deployment
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700102 * or removal phase.
Pier Ventre42287df2016-11-09 14:17:26 -0800103 */
104 INTERNAL_ERROR(3, "Internal error"),
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700105
Pier Ventre42287df2016-11-09 14:17:26 -0800106 /**
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700107 *
Pier Ventre42287df2016-11-09 14:17:26 -0800108 */
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700109 REMOVAL_ERROR(5, "Can not remove pseudowire from network configuration"),
110
111 /**
112 *
113 */
114 ADDITION_ERROR(6, "Can not add pseudowire in network configuration"),
115
116 /**
117 *
118 */
119 CONFIG_NOT_FOUND(7, "Can not find configuration class for pseudowires");
Pier Ventre42287df2016-11-09 14:17:26 -0800120
121 private final int code;
122 private final String description;
Ray Milkey067c44b2018-02-26 12:48:23 -0800123 protected int nextId;
Pier Ventre42287df2016-11-09 14:17:26 -0800124
Pier Ventre70d53ba2016-11-17 22:26:29 -0800125 Result(int code, String description) {
Pier Ventre42287df2016-11-09 14:17:26 -0800126 this.code = code;
127 this.description = description;
128 }
129
130 public String getDescription() {
131 return description;
132 }
133
Pier Ventre42287df2016-11-09 14:17:26 -0800134 @Override
135 public String toString() {
136 return code + ": " + description;
137 }
138 }
139
Pier Ventre70d53ba2016-11-17 22:26:29 -0800140 /**
141 * Enum helper for handling the direction of the pw.
142 */
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -0800143 enum Direction {
Pier Ventre70d53ba2016-11-17 22:26:29 -0800144 /**
145 * The forward direction of the pseudo wire.
146 */
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700147 FWD, /**
Pier Ventre70d53ba2016-11-17 22:26:29 -0800148 * The reverse direction of the pseudo wire.
149 */
Jon Hall8c7b06a2017-02-22 13:37:33 -0800150 REV
Pier Ventre70d53ba2016-11-17 22:26:29 -0800151 }
Pier Ventref34966c2016-11-07 16:21:04 -0800152}