blob: ad4f50a0889faf11afa7a1cea42cc84b4e6e3d00 [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 org.onosproject.net.Link;
Pier Ventref34966c2016-11-07 16:21:04 -080020
Pier Ventre42287df2016-11-09 14:17:26 -080021import java.util.List;
22import java.util.Set;
Pier Ventre42287df2016-11-09 14:17:26 -080023
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -080024public interface L2TunnelHandler {
25 void init();
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -070026
Pier Ventre70d53ba2016-11-17 22:26:29 -080027 /**
Andreas Pantelopoulosff691b72018-03-12 16:30:20 -070028 * Combines policies and tunnels to create descriptions.
29 *
30 * @return Set of l2 tunnel descriptions.
31 */
32 Set<L2TunnelDescription> getL2Descriptions();
33
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 /**
49 * Processes a link removal. Finds affected pseudowires and rewires them.
50 * TODO: Make it also take into account failures of links that are used for pw
51 * traffic in the spine.
52 * @param link The link that failed
53 */
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -080054 void processLinkDown(Link link);
Pier Ventref34966c2016-11-07 16:21:04 -080055
56 /**
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -070057 * Helper function to handle the pw removal.
58 * <p>
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -080059 * This method should for the mastership of the device because it is
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -070060 * used only from network configuration updates, thus we only want
61 * one instance only to program each pseudowire.
Pier Ventre42287df2016-11-09 14:17:26 -080062 *
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -070063 * @param pwToRemove the pseudo wires to remove
Pier Ventre42287df2016-11-09 14:17:26 -080064 */
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -080065 void tearDown(Set<L2TunnelDescription> pwToRemove);
Pier Ventre42287df2016-11-09 14:17:26 -080066
67 /**
Pier Luigi3bfe32c2017-01-30 09:47:36 -080068 * Pwaas pipelines.
Pier Ventre42287df2016-11-09 14:17:26 -080069 */
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -080070 enum Pipeline {
Pier Ventre42287df2016-11-09 14:17:26 -080071 /**
72 * The initiation pipeline.
73 */
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -070074 INITIATION, /**
Pier Ventre42287df2016-11-09 14:17:26 -080075 * The termination pipeline.
76 */
Pier Ventre70d53ba2016-11-17 22:26:29 -080077 TERMINATION
Pier Ventre42287df2016-11-09 14:17:26 -080078 }
79
80 /**
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -070081 * Enum helper to carry results of various operations.
Pier Ventre42287df2016-11-09 14:17:26 -080082 */
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -080083 enum Result {
Pier Ventre42287df2016-11-09 14:17:26 -080084 /**
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -070085 * Happy ending scenario.
Pier Ventre42287df2016-11-09 14:17:26 -080086 */
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -070087 SUCCESS(0, "No error occurred"),
88
Pier Ventre42287df2016-11-09 14:17:26 -080089 /**
90 * We have problems with the supplied parameters.
91 */
92 WRONG_PARAMETERS(1, "Wrong parameters"),
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -070093
Pier Ventre42287df2016-11-09 14:17:26 -080094 /**
95 * We have an internal error during the deployment
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -070096 * or removal phase.
Pier Ventre42287df2016-11-09 14:17:26 -080097 */
98 INTERNAL_ERROR(3, "Internal error"),
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -070099
Pier Ventre42287df2016-11-09 14:17:26 -0800100 /**
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700101 *
Pier Ventre42287df2016-11-09 14:17:26 -0800102 */
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700103 REMOVAL_ERROR(5, "Can not remove pseudowire from network configuration"),
104
105 /**
106 *
107 */
108 ADDITION_ERROR(6, "Can not add pseudowire in network configuration"),
109
110 /**
111 *
112 */
113 CONFIG_NOT_FOUND(7, "Can not find configuration class for pseudowires");
Pier Ventre42287df2016-11-09 14:17:26 -0800114
115 private final int code;
116 private final String description;
Ray Milkey067c44b2018-02-26 12:48:23 -0800117 protected int nextId;
Pier Ventre42287df2016-11-09 14:17:26 -0800118
Pier Ventre70d53ba2016-11-17 22:26:29 -0800119 Result(int code, String description) {
Pier Ventre42287df2016-11-09 14:17:26 -0800120 this.code = code;
121 this.description = description;
122 }
123
124 public String getDescription() {
125 return description;
126 }
127
Pier Ventre42287df2016-11-09 14:17:26 -0800128 @Override
129 public String toString() {
130 return code + ": " + description;
131 }
132 }
133
Pier Ventre70d53ba2016-11-17 22:26:29 -0800134 /**
135 * Enum helper for handling the direction of the pw.
136 */
Andreas Pantelopoulosb21547d2018-02-22 12:32:42 -0800137 enum Direction {
Pier Ventre70d53ba2016-11-17 22:26:29 -0800138 /**
139 * The forward direction of the pseudo wire.
140 */
Andreas Pantelopoulos27532cd2017-10-23 12:18:25 -0700141 FWD, /**
Pier Ventre70d53ba2016-11-17 22:26:29 -0800142 * The reverse direction of the pseudo wire.
143 */
Jon Hall8c7b06a2017-02-22 13:37:33 -0800144 REV
Pier Ventre70d53ba2016-11-17 22:26:29 -0800145 }
Pier Ventref34966c2016-11-07 16:21:04 -0800146}