blob: 3a89a213c86af96c70c6a7c83e1043a1b398b57a [file] [log] [blame]
Pier Ventre6b19e482016-11-07 16:21:04 -08001/*
Brian O'Connor0947d7e2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Pier Ventre6b19e482016-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 Ventref3cf5b92016-11-09 14:17:26 -080019import org.onosproject.net.Link;
Pier Ventre6b19e482016-11-07 16:21:04 -080020import org.onosproject.net.config.NetworkConfigEvent;
Pier Ventre6b19e482016-11-07 16:21:04 -080021
Pier Ventref3cf5b92016-11-09 14:17:26 -080022import java.util.List;
23import java.util.Set;
Pier Ventref3cf5b92016-11-09 14:17:26 -080024
Andreas Pantelopoulos4c7de132018-02-22 12:32:42 -080025public interface L2TunnelHandler {
26 void init();
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -070027
Pier Ventreac3e1d92016-11-17 22:26:29 -080028 /**
Andreas Pantelopoulos4c7de132018-02-22 12:32:42 -080029 * Returns a copy of the l2 policies that exist in the store.
Pier Ventref3cf5b92016-11-09 14:17:26 -080030 *
Andreas Pantelopoulos4c7de132018-02-22 12:32:42 -080031 * @return The l2 policies
Pier Ventref3cf5b92016-11-09 14:17:26 -080032 */
Andreas Pantelopoulos4c7de132018-02-22 12:32:42 -080033 List<L2TunnelPolicy> getL2Policies();
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -070034
35 /**
Andreas Pantelopoulos4c7de132018-02-22 12:32:42 -080036 * Returns a copy of the l2 tunnels that exist in the store.
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -070037 *
Andreas Pantelopoulos4c7de132018-02-22 12:32:42 -080038 * @return The l2 tunnels.
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -070039 */
Andreas Pantelopoulos4c7de132018-02-22 12:32:42 -080040 List<L2Tunnel> getL2Tunnels();
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -070041
42 /**
43 * Processes a link removal. Finds affected pseudowires and rewires them.
44 * TODO: Make it also take into account failures of links that are used for pw
45 * traffic in the spine.
46 * @param link The link that failed
47 */
Andreas Pantelopoulos4c7de132018-02-22 12:32:42 -080048 void processLinkDown(Link link);
Pier Ventre6b19e482016-11-07 16:21:04 -080049
50 /**
51 * Processes Pwaas Config added event.
52 *
Pier Ventref3cf5b92016-11-09 14:17:26 -080053 * @param event network config add event
Pier Ventre6b19e482016-11-07 16:21:04 -080054 */
Andreas Pantelopoulos4c7de132018-02-22 12:32:42 -080055 void processPwaasConfigAdded(NetworkConfigEvent event);
Pier Ventre6b19e482016-11-07 16:21:04 -080056
57 /**
Pier Ventreac3e1d92016-11-17 22:26:29 -080058 * Processes PWaaS Config updated event.
Pier Ventre6b19e482016-11-07 16:21:04 -080059 *
60 * @param event network config updated event
61 */
Andreas Pantelopoulos4c7de132018-02-22 12:32:42 -080062 void processPwaasConfigUpdated(NetworkConfigEvent event);
Pier Ventre6b19e482016-11-07 16:21:04 -080063
64 /**
65 * Processes Pwaas Config removed event.
66 *
67 * @param event network config removed event
68 */
Andreas Pantelopoulos4c7de132018-02-22 12:32:42 -080069 void processPwaasConfigRemoved(NetworkConfigEvent event);
Pier Ventref3cf5b92016-11-09 14:17:26 -080070
71 /**
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -070072 * Helper function to handle the pw removal.
73 * <p>
Andreas Pantelopoulos4c7de132018-02-22 12:32:42 -080074 * This method should for the mastership of the device because it is
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -070075 * used only from network configuration updates, thus we only want
76 * one instance only to program each pseudowire.
Pier Ventref3cf5b92016-11-09 14:17:26 -080077 *
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -070078 * @param pwToRemove the pseudo wires to remove
Pier Ventref3cf5b92016-11-09 14:17:26 -080079 */
Andreas Pantelopoulos4c7de132018-02-22 12:32:42 -080080 void tearDown(Set<L2TunnelDescription> pwToRemove);
Pier Ventref3cf5b92016-11-09 14:17:26 -080081
82 /**
Pier Luigi0be3f0f2017-01-30 09:47:36 -080083 * Pwaas pipelines.
Pier Ventref3cf5b92016-11-09 14:17:26 -080084 */
Andreas Pantelopoulos4c7de132018-02-22 12:32:42 -080085 enum Pipeline {
Pier Ventref3cf5b92016-11-09 14:17:26 -080086 /**
87 * The initiation pipeline.
88 */
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -070089 INITIATION, /**
Pier Ventref3cf5b92016-11-09 14:17:26 -080090 * The termination pipeline.
91 */
Pier Ventreac3e1d92016-11-17 22:26:29 -080092 TERMINATION
Pier Ventref3cf5b92016-11-09 14:17:26 -080093 }
94
95 /**
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -070096 * Enum helper to carry results of various operations.
Pier Ventref3cf5b92016-11-09 14:17:26 -080097 */
Andreas Pantelopoulos4c7de132018-02-22 12:32:42 -080098 enum Result {
Pier Ventref3cf5b92016-11-09 14:17:26 -080099 /**
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -0700100 * Happy ending scenario.
Pier Ventref3cf5b92016-11-09 14:17:26 -0800101 */
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -0700102 SUCCESS(0, "No error occurred"),
103
Pier Ventref3cf5b92016-11-09 14:17:26 -0800104 /**
105 * We have problems with the supplied parameters.
106 */
107 WRONG_PARAMETERS(1, "Wrong parameters"),
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -0700108
Pier Ventref3cf5b92016-11-09 14:17:26 -0800109 /**
110 * We have an internal error during the deployment
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -0700111 * or removal phase.
Pier Ventref3cf5b92016-11-09 14:17:26 -0800112 */
113 INTERNAL_ERROR(3, "Internal error"),
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -0700114
Pier Ventref3cf5b92016-11-09 14:17:26 -0800115 /**
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -0700116 *
Pier Ventref3cf5b92016-11-09 14:17:26 -0800117 */
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -0700118 REMOVAL_ERROR(5, "Can not remove pseudowire from network configuration"),
119
120 /**
121 *
122 */
123 ADDITION_ERROR(6, "Can not add pseudowire in network configuration"),
124
125 /**
126 *
127 */
128 CONFIG_NOT_FOUND(7, "Can not find configuration class for pseudowires");
Pier Ventref3cf5b92016-11-09 14:17:26 -0800129
130 private final int code;
131 private final String description;
Andreas Pantelopoulos4c7de132018-02-22 12:32:42 -0800132 public int nextId;
Pier Ventref3cf5b92016-11-09 14:17:26 -0800133
Pier Ventreac3e1d92016-11-17 22:26:29 -0800134 Result(int code, String description) {
Pier Ventref3cf5b92016-11-09 14:17:26 -0800135 this.code = code;
136 this.description = description;
137 }
138
139 public String getDescription() {
140 return description;
141 }
142
Pier Ventref3cf5b92016-11-09 14:17:26 -0800143 @Override
144 public String toString() {
145 return code + ": " + description;
146 }
147 }
148
Pier Ventreac3e1d92016-11-17 22:26:29 -0800149 /**
150 * Enum helper for handling the direction of the pw.
151 */
Andreas Pantelopoulos4c7de132018-02-22 12:32:42 -0800152 enum Direction {
Pier Ventreac3e1d92016-11-17 22:26:29 -0800153 /**
154 * The forward direction of the pseudo wire.
155 */
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -0700156 FWD, /**
Pier Ventreac3e1d92016-11-17 22:26:29 -0800157 * The reverse direction of the pseudo wire.
158 */
Jon Hall8f867f42017-02-22 13:37:33 -0800159 REV
Pier Ventreac3e1d92016-11-17 22:26:29 -0800160 }
Pier Ventre6b19e482016-11-07 16:21:04 -0800161}