Pier Ventre | f34966c | 2016-11-07 16:21:04 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Pier Ventre | f34966c | 2016-11-07 16:21:04 -0800 | [diff] [blame] | 3 | * |
| 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 | |
| 17 | package org.onosproject.segmentrouting.pwaas; |
| 18 | |
Pier Ventre | 42287df | 2016-11-09 14:17:26 -0800 | [diff] [blame] | 19 | import java.util.List; |
| 20 | import java.util.Set; |
Pier Ventre | 42287df | 2016-11-09 14:17:26 -0800 | [diff] [blame] | 21 | |
Andreas Pantelopoulos | b21547d | 2018-02-22 12:32:42 -0800 | [diff] [blame] | 22 | public interface L2TunnelHandler { |
| 23 | void init(); |
Andreas Pantelopoulos | 27532cd | 2017-10-23 12:18:25 -0700 | [diff] [blame] | 24 | |
Pier Ventre | 70d53ba | 2016-11-17 22:26:29 -0800 | [diff] [blame] | 25 | /** |
Andreas Pantelopoulos | ff691b7 | 2018-03-12 16:30:20 -0700 | [diff] [blame] | 26 | * Combines policies and tunnels to create descriptions. |
| 27 | * |
Andreas Pantelopoulos | 811bbae | 2018-03-15 16:56:09 -0700 | [diff] [blame] | 28 | * @param pending if it is true return pending to be installed pseudowires |
| 29 | * from the appropriate store, else return installed pseudowires |
Andreas Pantelopoulos | ff691b7 | 2018-03-12 16:30:20 -0700 | [diff] [blame] | 30 | * @return Set of l2 tunnel descriptions. |
| 31 | */ |
Andreas Pantelopoulos | 811bbae | 2018-03-15 16:56:09 -0700 | [diff] [blame] | 32 | Set<L2TunnelDescription> getL2Descriptions(boolean pending); |
Andreas Pantelopoulos | ff691b7 | 2018-03-12 16:30:20 -0700 | [diff] [blame] | 33 | |
| 34 | /** |
Andreas Pantelopoulos | b21547d | 2018-02-22 12:32:42 -0800 | [diff] [blame] | 35 | * Returns a copy of the l2 policies that exist in the store. |
Pier Ventre | 42287df | 2016-11-09 14:17:26 -0800 | [diff] [blame] | 36 | * |
Andreas Pantelopoulos | b21547d | 2018-02-22 12:32:42 -0800 | [diff] [blame] | 37 | * @return The l2 policies |
Pier Ventre | 42287df | 2016-11-09 14:17:26 -0800 | [diff] [blame] | 38 | */ |
Andreas Pantelopoulos | b21547d | 2018-02-22 12:32:42 -0800 | [diff] [blame] | 39 | List<L2TunnelPolicy> getL2Policies(); |
Andreas Pantelopoulos | 27532cd | 2017-10-23 12:18:25 -0700 | [diff] [blame] | 40 | |
| 41 | /** |
Andreas Pantelopoulos | b21547d | 2018-02-22 12:32:42 -0800 | [diff] [blame] | 42 | * Returns a copy of the l2 tunnels that exist in the store. |
Andreas Pantelopoulos | 27532cd | 2017-10-23 12:18:25 -0700 | [diff] [blame] | 43 | * |
Andreas Pantelopoulos | b21547d | 2018-02-22 12:32:42 -0800 | [diff] [blame] | 44 | * @return The l2 tunnels. |
Andreas Pantelopoulos | 27532cd | 2017-10-23 12:18:25 -0700 | [diff] [blame] | 45 | */ |
Andreas Pantelopoulos | b21547d | 2018-02-22 12:32:42 -0800 | [diff] [blame] | 46 | List<L2Tunnel> getL2Tunnels(); |
Andreas Pantelopoulos | 27532cd | 2017-10-23 12:18:25 -0700 | [diff] [blame] | 47 | |
| 48 | /** |
Andreas Pantelopoulos | 811bbae | 2018-03-15 16:56:09 -0700 | [diff] [blame] | 49 | * Returns a copy of the pending l2 policies that exist in the store. |
| 50 | * |
| 51 | * @return The l2 policies |
Andreas Pantelopoulos | 27532cd | 2017-10-23 12:18:25 -0700 | [diff] [blame] | 52 | */ |
Andreas Pantelopoulos | 811bbae | 2018-03-15 16:56:09 -0700 | [diff] [blame] | 53 | List<L2TunnelPolicy> getL2PendingPolicies(); |
| 54 | |
| 55 | /** |
Andreas Pantelopoulos | 27532cd | 2017-10-23 12:18:25 -0700 | [diff] [blame] | 56 | * Helper function to handle the pw removal. |
| 57 | * <p> |
Andreas Pantelopoulos | b21547d | 2018-02-22 12:32:42 -0800 | [diff] [blame] | 58 | * This method should for the mastership of the device because it is |
Andreas Pantelopoulos | 27532cd | 2017-10-23 12:18:25 -0700 | [diff] [blame] | 59 | * used only from network configuration updates, thus we only want |
| 60 | * one instance only to program each pseudowire. |
Pier Ventre | 42287df | 2016-11-09 14:17:26 -0800 | [diff] [blame] | 61 | * |
Andreas Pantelopoulos | 27532cd | 2017-10-23 12:18:25 -0700 | [diff] [blame] | 62 | * @param pwToRemove the pseudo wires to remove |
Andreas Pantelopoulos | ffe6974 | 2018-03-20 13:58:49 -0700 | [diff] [blame^] | 63 | * @deprecated onos-1.12 Do not use this method. |
Pier Ventre | 42287df | 2016-11-09 14:17:26 -0800 | [diff] [blame] | 64 | */ |
Andreas Pantelopoulos | ffe6974 | 2018-03-20 13:58:49 -0700 | [diff] [blame^] | 65 | @Deprecated |
Andreas Pantelopoulos | b21547d | 2018-02-22 12:32:42 -0800 | [diff] [blame] | 66 | void tearDown(Set<L2TunnelDescription> pwToRemove); |
Pier Ventre | 42287df | 2016-11-09 14:17:26 -0800 | [diff] [blame] | 67 | |
| 68 | /** |
Andreas Pantelopoulos | ffe6974 | 2018-03-20 13:58:49 -0700 | [diff] [blame^] | 69 | * 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 | /** |
Pier Luigi | 3bfe32c | 2017-01-30 09:47:36 -0800 | [diff] [blame] | 76 | * Pwaas pipelines. |
Pier Ventre | 42287df | 2016-11-09 14:17:26 -0800 | [diff] [blame] | 77 | */ |
Andreas Pantelopoulos | b21547d | 2018-02-22 12:32:42 -0800 | [diff] [blame] | 78 | enum Pipeline { |
Pier Ventre | 42287df | 2016-11-09 14:17:26 -0800 | [diff] [blame] | 79 | /** |
| 80 | * The initiation pipeline. |
| 81 | */ |
Andreas Pantelopoulos | 27532cd | 2017-10-23 12:18:25 -0700 | [diff] [blame] | 82 | INITIATION, /** |
Pier Ventre | 42287df | 2016-11-09 14:17:26 -0800 | [diff] [blame] | 83 | * The termination pipeline. |
| 84 | */ |
Pier Ventre | 70d53ba | 2016-11-17 22:26:29 -0800 | [diff] [blame] | 85 | TERMINATION |
Pier Ventre | 42287df | 2016-11-09 14:17:26 -0800 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | /** |
Andreas Pantelopoulos | 27532cd | 2017-10-23 12:18:25 -0700 | [diff] [blame] | 89 | * Enum helper to carry results of various operations. |
Pier Ventre | 42287df | 2016-11-09 14:17:26 -0800 | [diff] [blame] | 90 | */ |
Andreas Pantelopoulos | b21547d | 2018-02-22 12:32:42 -0800 | [diff] [blame] | 91 | enum Result { |
Pier Ventre | 42287df | 2016-11-09 14:17:26 -0800 | [diff] [blame] | 92 | /** |
Andreas Pantelopoulos | 27532cd | 2017-10-23 12:18:25 -0700 | [diff] [blame] | 93 | * Happy ending scenario. |
Pier Ventre | 42287df | 2016-11-09 14:17:26 -0800 | [diff] [blame] | 94 | */ |
Andreas Pantelopoulos | 27532cd | 2017-10-23 12:18:25 -0700 | [diff] [blame] | 95 | SUCCESS(0, "No error occurred"), |
| 96 | |
Pier Ventre | 42287df | 2016-11-09 14:17:26 -0800 | [diff] [blame] | 97 | /** |
| 98 | * We have problems with the supplied parameters. |
| 99 | */ |
| 100 | WRONG_PARAMETERS(1, "Wrong parameters"), |
Andreas Pantelopoulos | 27532cd | 2017-10-23 12:18:25 -0700 | [diff] [blame] | 101 | |
Pier Ventre | 42287df | 2016-11-09 14:17:26 -0800 | [diff] [blame] | 102 | /** |
| 103 | * We have an internal error during the deployment |
Andreas Pantelopoulos | 27532cd | 2017-10-23 12:18:25 -0700 | [diff] [blame] | 104 | * or removal phase. |
Pier Ventre | 42287df | 2016-11-09 14:17:26 -0800 | [diff] [blame] | 105 | */ |
| 106 | INTERNAL_ERROR(3, "Internal error"), |
Andreas Pantelopoulos | 27532cd | 2017-10-23 12:18:25 -0700 | [diff] [blame] | 107 | |
Pier Ventre | 42287df | 2016-11-09 14:17:26 -0800 | [diff] [blame] | 108 | /** |
Andreas Pantelopoulos | 27532cd | 2017-10-23 12:18:25 -0700 | [diff] [blame] | 109 | * |
Pier Ventre | 42287df | 2016-11-09 14:17:26 -0800 | [diff] [blame] | 110 | */ |
Andreas Pantelopoulos | ffe6974 | 2018-03-20 13:58:49 -0700 | [diff] [blame^] | 111 | PATH_NOT_FOUND(7, "Could not find valid path between connection points!"), |
Andreas Pantelopoulos | 27532cd | 2017-10-23 12:18:25 -0700 | [diff] [blame] | 112 | |
| 113 | /** |
| 114 | * |
| 115 | */ |
Andreas Pantelopoulos | ffe6974 | 2018-03-20 13:58:49 -0700 | [diff] [blame^] | 116 | CONFIGURATION_ERROR(8, "Conflicting pseudowire configurations!"); |
Pier Ventre | 42287df | 2016-11-09 14:17:26 -0800 | [diff] [blame] | 117 | |
| 118 | private final int code; |
| 119 | private final String description; |
Andreas Pantelopoulos | ffe6974 | 2018-03-20 13:58:49 -0700 | [diff] [blame^] | 120 | |
| 121 | private String specificError; |
| 122 | public int nextId; |
Pier Ventre | 42287df | 2016-11-09 14:17:26 -0800 | [diff] [blame] | 123 | |
Pier Ventre | 70d53ba | 2016-11-17 22:26:29 -0800 | [diff] [blame] | 124 | Result(int code, String description) { |
Pier Ventre | 42287df | 2016-11-09 14:17:26 -0800 | [diff] [blame] | 125 | this.code = code; |
| 126 | this.description = description; |
| 127 | } |
| 128 | |
Andreas Pantelopoulos | ffe6974 | 2018-03-20 13:58:49 -0700 | [diff] [blame^] | 129 | public Result appendError(String error) { |
| 130 | this.specificError = error; |
| 131 | return this; |
| 132 | } |
| 133 | |
| 134 | public String getSpecificError() { |
| 135 | return specificError; |
| 136 | } |
| 137 | |
Pier Ventre | 42287df | 2016-11-09 14:17:26 -0800 | [diff] [blame] | 138 | public String getDescription() { |
| 139 | return description; |
| 140 | } |
| 141 | |
Pier Ventre | 42287df | 2016-11-09 14:17:26 -0800 | [diff] [blame] | 142 | @Override |
| 143 | public String toString() { |
| 144 | return code + ": " + description; |
| 145 | } |
| 146 | } |
| 147 | |
Pier Ventre | 70d53ba | 2016-11-17 22:26:29 -0800 | [diff] [blame] | 148 | /** |
| 149 | * Enum helper for handling the direction of the pw. |
| 150 | */ |
Andreas Pantelopoulos | b21547d | 2018-02-22 12:32:42 -0800 | [diff] [blame] | 151 | enum Direction { |
Pier Ventre | 70d53ba | 2016-11-17 22:26:29 -0800 | [diff] [blame] | 152 | /** |
| 153 | * The forward direction of the pseudo wire. |
| 154 | */ |
Andreas Pantelopoulos | 27532cd | 2017-10-23 12:18:25 -0700 | [diff] [blame] | 155 | FWD, /** |
Pier Ventre | 70d53ba | 2016-11-17 22:26:29 -0800 | [diff] [blame] | 156 | * The reverse direction of the pseudo wire. |
| 157 | */ |
Jon Hall | 8c7b06a | 2017-02-22 13:37:33 -0800 | [diff] [blame] | 158 | REV |
Pier Ventre | 70d53ba | 2016-11-17 22:26:29 -0800 | [diff] [blame] | 159 | } |
Pier Ventre | f34966c | 2016-11-07 16:21:04 -0800 | [diff] [blame] | 160 | } |