blob: 2906411d152c11e50386a06a8a8b00746607eefd [file] [log] [blame]
Phaneendra Manda1ea49142015-10-26 22:33:06 +05301/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Phaneendra Manda1ea49142015-10-26 22:33:06 +05303 *
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 */
16package org.onosproject.vtnrsc;
17
18import java.util.List;
Phaneendra Manda329a1272016-02-10 22:57:00 +053019import java.util.Optional;
20import java.util.Set;
Phaneendra Manda1ea49142015-10-26 22:33:06 +053021
Phaneendra Mandaab7fdfa2016-04-19 01:24:09 +053022import org.onosproject.net.DeviceId;
23
Phaneendra Manda1ea49142015-10-26 22:33:06 +053024/**
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 */
30public 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 Manda329a1272016-02-10 22:57:00 +053077 * 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 Mandaab7fdfa2016-04-19 01:24:09 +053087 * 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 Manda329a1272016-02-10 22:57:00 +0530136 *
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 Mandaab7fdfa2016-04-19 01:24:09 +0530143 * Returns the keys set from load balance id map.
Phaneendra Manda329a1272016-02-10 22:57:00 +0530144 *
145 * @return set of five tuple info
146 */
147 Set<FiveTuple> getLoadBalanceIdMapKeys();
148
149 /**
Phaneendra Mandaab7fdfa2016-04-19 01:24:09 +0530150 * 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 Manda329a1272016-02-10 22:57:00 +0530158 *
159 * @param id load balance id.
160 * @return path containing list of port pairs
161 */
162 List<PortPairId> getLoadBalancePath(LoadBalanceId id);
163
164 /**
Phaneendra Mandaab7fdfa2016-04-19 01:24:09 +0530165 * Returns the load balanced path from five tuple.
Phaneendra Manda329a1272016-02-10 22:57:00 +0530166 *
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 Mandaab7fdfa2016-04-19 01:24:09 +0530173 * Returns the no of load balance paths created.
Phaneendra Manda275ff0c2016-02-25 11:50:24 +0530174 *
175 * @return size of load balanced paths
176 */
177 int getLoadBalancePathSize();
178
179 /**
Phaneendra Manda329a1272016-02-10 22:57:00 +0530180 * 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 Manda1ea49142015-10-26 22:33:06 +0530188 * 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}