Phaneendra Manda | 1ea4914 | 2015-10-26 22:33:06 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Phaneendra Manda | 1ea4914 | 2015-10-26 22:33:06 +0530 | [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 | package org.onosproject.vtnrsc; |
| 17 | |
| 18 | import java.util.List; |
Phaneendra Manda | 329a127 | 2016-02-10 22:57:00 +0530 | [diff] [blame] | 19 | import java.util.Optional; |
| 20 | import java.util.Set; |
Phaneendra Manda | 1ea4914 | 2015-10-26 22:33:06 +0530 | [diff] [blame] | 21 | |
Phaneendra Manda | ab7fdfa | 2016-04-19 01:24:09 +0530 | [diff] [blame^] | 22 | import org.onosproject.net.DeviceId; |
| 23 | |
Phaneendra Manda | 1ea4914 | 2015-10-26 22:33:06 +0530 | [diff] [blame] | 24 | /** |
| 25 | * Abstraction of an entity providing Port Chain information. |
| 26 | * A Port Chain (Service Function Path) consists of |
| 27 | * a set of Neutron ports, to define the sequence of service functions |
| 28 | * a set of flow classifiers, to specify the classified traffic flows to enter the chain |
| 29 | */ |
| 30 | public interface PortChain { |
| 31 | |
| 32 | /** |
| 33 | * Returns the ID of this port chain. |
| 34 | * |
| 35 | * @return the port chain id |
| 36 | */ |
| 37 | PortChainId portChainId(); |
| 38 | |
| 39 | /** |
| 40 | * Returns the tenant id of this port chain. |
| 41 | * |
| 42 | * @return the tenant id |
| 43 | */ |
| 44 | TenantId tenantId(); |
| 45 | |
| 46 | /** |
| 47 | * Returns the name of this port chain. |
| 48 | * |
| 49 | * @return name of port chain |
| 50 | */ |
| 51 | String name(); |
| 52 | |
| 53 | /** |
| 54 | * Returns the description of this port chain. |
| 55 | * |
| 56 | * @return description of port chain |
| 57 | */ |
| 58 | String description(); |
| 59 | |
| 60 | /** |
| 61 | * Returns the list of port pair groups associated with |
| 62 | * this port chain. |
| 63 | * |
| 64 | * @return list of port pair groups |
| 65 | */ |
| 66 | List<PortPairGroupId> portPairGroups(); |
| 67 | |
| 68 | /** |
| 69 | * Returns the list of flow classifiers associated with |
| 70 | * this port chain. |
| 71 | * |
| 72 | * @return list of flow classifiers |
| 73 | */ |
| 74 | List<FlowClassifierId> flowClassifiers(); |
| 75 | |
| 76 | /** |
Phaneendra Manda | 329a127 | 2016-02-10 22:57:00 +0530 | [diff] [blame] | 77 | * Adds a new load balanced path. |
| 78 | * |
| 79 | * @param fiveTuple five tuple from the packet |
| 80 | * @param id load balance path identifier |
| 81 | * @param path load balanced path of list of port pairs |
| 82 | */ |
| 83 | void addLoadBalancePath(FiveTuple fiveTuple, LoadBalanceId id, |
| 84 | List<PortPairId> path); |
| 85 | |
| 86 | /** |
Phaneendra Manda | ab7fdfa | 2016-04-19 01:24:09 +0530 | [diff] [blame^] | 87 | * Adds sfc classifiers to the given load balance id for a port chain. |
| 88 | * |
| 89 | * @param id load balance path identifier |
| 90 | * @param classifierList list of classifier devices |
| 91 | */ |
| 92 | void addSfcClassifiers(LoadBalanceId id, List<DeviceId> classifierList); |
| 93 | |
| 94 | /** |
| 95 | * Adds sfc forwarders to the given load balance id for a port chain. |
| 96 | * |
| 97 | * @param id load balance path identifier |
| 98 | * @param forwarderList list of forwarder devices |
| 99 | */ |
| 100 | void addSfcForwarders(LoadBalanceId id, List<DeviceId> forwarderList); |
| 101 | |
| 102 | /** |
| 103 | * Removes sfc classifiers to the given load balance id for a port chain. |
| 104 | * |
| 105 | * @param id load balance path identifier |
| 106 | * @param classifierList list of classifier devices |
| 107 | */ |
| 108 | void removeSfcClassifiers(LoadBalanceId id, List<DeviceId> classifierList); |
| 109 | |
| 110 | /** |
| 111 | * Removes sfc forwarders to the given load balance id for a port chain. |
| 112 | * |
| 113 | * @param id load balance path identifier |
| 114 | * @param forwarderList list of forwarder devices |
| 115 | */ |
| 116 | void removeSfcForwarders(LoadBalanceId id, List<DeviceId> forwarderList); |
| 117 | |
| 118 | /** |
| 119 | * Returns sfc classifiers to the given load balance id for a port chain. |
| 120 | * |
| 121 | * @param id load balance path identifier |
| 122 | * @return list of classifier devices |
| 123 | */ |
| 124 | List<DeviceId> getSfcClassifiers(LoadBalanceId id); |
| 125 | |
| 126 | /** |
| 127 | * Returns sfc forwarders to the given load balance id for a port chain. |
| 128 | * |
| 129 | * @param id load balance path identifier |
| 130 | * @return list of forwarder devices |
| 131 | */ |
| 132 | List<DeviceId> getSfcForwarders(LoadBalanceId id); |
| 133 | |
| 134 | /** |
| 135 | * Returns the load balance id from five tuple. |
Phaneendra Manda | 329a127 | 2016-02-10 22:57:00 +0530 | [diff] [blame] | 136 | * |
| 137 | * @param fiveTuple five tuple from the packet |
| 138 | * @return load balance identifier for the given packet |
| 139 | */ |
| 140 | LoadBalanceId getLoadBalanceId(FiveTuple fiveTuple); |
| 141 | |
| 142 | /** |
Phaneendra Manda | ab7fdfa | 2016-04-19 01:24:09 +0530 | [diff] [blame^] | 143 | * Returns the keys set from load balance id map. |
Phaneendra Manda | 329a127 | 2016-02-10 22:57:00 +0530 | [diff] [blame] | 144 | * |
| 145 | * @return set of five tuple info |
| 146 | */ |
| 147 | Set<FiveTuple> getLoadBalanceIdMapKeys(); |
| 148 | |
| 149 | /** |
Phaneendra Manda | ab7fdfa | 2016-04-19 01:24:09 +0530 | [diff] [blame^] | 150 | * Returns the keys set from load balance path map. |
| 151 | * |
| 152 | * @return set of load balance id's |
| 153 | */ |
| 154 | Set<LoadBalanceId> getLoadBalancePathMapKeys(); |
| 155 | |
| 156 | /** |
| 157 | * Returns the load balanced path from load balance Id. |
Phaneendra Manda | 329a127 | 2016-02-10 22:57:00 +0530 | [diff] [blame] | 158 | * |
| 159 | * @param id load balance id. |
| 160 | * @return path containing list of port pairs |
| 161 | */ |
| 162 | List<PortPairId> getLoadBalancePath(LoadBalanceId id); |
| 163 | |
| 164 | /** |
Phaneendra Manda | ab7fdfa | 2016-04-19 01:24:09 +0530 | [diff] [blame^] | 165 | * Returns the load balanced path from five tuple. |
Phaneendra Manda | 329a127 | 2016-02-10 22:57:00 +0530 | [diff] [blame] | 166 | * |
| 167 | * @param fiveTuple five tuple from the packet |
| 168 | * @return path containing list of port pairs |
| 169 | */ |
| 170 | List<PortPairId> getLoadBalancePath(FiveTuple fiveTuple); |
| 171 | |
| 172 | /** |
Phaneendra Manda | ab7fdfa | 2016-04-19 01:24:09 +0530 | [diff] [blame^] | 173 | * Returns the no of load balance paths created. |
Phaneendra Manda | 275ff0c | 2016-02-25 11:50:24 +0530 | [diff] [blame] | 174 | * |
| 175 | * @return size of load balanced paths |
| 176 | */ |
| 177 | int getLoadBalancePathSize(); |
| 178 | |
| 179 | /** |
Phaneendra Manda | 329a127 | 2016-02-10 22:57:00 +0530 | [diff] [blame] | 180 | * Match the given path with existing load balanced paths. |
| 181 | * |
| 182 | * @param path load balanced path |
| 183 | * @return load balance id if the path matches, null otherwise. |
| 184 | */ |
| 185 | Optional<LoadBalanceId> matchPath(List<PortPairId> path); |
| 186 | |
| 187 | /** |
Phaneendra Manda | 1ea4914 | 2015-10-26 22:33:06 +0530 | [diff] [blame] | 188 | * Returns whether this port chain is an exact match to the port chain given |
| 189 | * in the argument. |
| 190 | * <p> |
| 191 | * Exact match means the port pair groups and flow classifiers match |
| 192 | * with the given port chain. It does not consider the port chain id, name |
| 193 | * and description. |
| 194 | * </p> |
| 195 | * |
| 196 | * @param portChain other port chain to match against |
| 197 | * @return true if the port chains are an exact match, otherwise false |
| 198 | */ |
| 199 | boolean exactMatch(PortChain portChain); |
| 200 | |
| 201 | /** |
| 202 | * A port chain builder.. |
| 203 | */ |
| 204 | interface Builder { |
| 205 | |
| 206 | /** |
| 207 | * Assigns the port chain id to this object. |
| 208 | * |
| 209 | * @param portChainId the port chain id |
| 210 | * @return this the builder object |
| 211 | */ |
| 212 | Builder setId(PortChainId portChainId); |
| 213 | |
| 214 | /** |
| 215 | * Assigns tenant id to this object. |
| 216 | * |
| 217 | * @param tenantId tenant id of the port chain |
| 218 | * @return this the builder object |
| 219 | */ |
| 220 | Builder setTenantId(TenantId tenantId); |
| 221 | |
| 222 | /** |
| 223 | * Assigns the name to this object. |
| 224 | * |
| 225 | * @param name name of the port chain |
| 226 | * @return this the builder object |
| 227 | */ |
| 228 | Builder setName(String name); |
| 229 | |
| 230 | /** |
| 231 | * Assigns the description to this object. |
| 232 | * |
| 233 | * @param description description of the port chain |
| 234 | * @return this the builder object |
| 235 | */ |
| 236 | Builder setDescription(String description); |
| 237 | |
| 238 | /** |
| 239 | * Assigns the port pair groups associated with the port chain |
| 240 | * to this object. |
| 241 | * |
| 242 | * @param portPairGroups list of port pair groups |
| 243 | * @return this the builder object |
| 244 | */ |
| 245 | Builder setPortPairGroups(List<PortPairGroupId> portPairGroups); |
| 246 | |
| 247 | /** |
| 248 | * Assigns the flow classifiers associated with the port chain |
| 249 | * to this object. |
| 250 | * |
| 251 | * @param flowClassifiers list of flow classifiers |
| 252 | * @return this the builder object |
| 253 | */ |
| 254 | Builder setFlowClassifiers(List<FlowClassifierId> flowClassifiers); |
| 255 | |
| 256 | /** |
| 257 | * Builds a port chain object. |
| 258 | * |
| 259 | * @return a port chain. |
| 260 | */ |
| 261 | PortChain build(); |
| 262 | } |
| 263 | } |