blob: 8a4bb9539237e6518dfc8e031cd29717374820b7 [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
22/**
23 * Abstraction of an entity providing Port Chain information.
24 * A Port Chain (Service Function Path) consists of
25 * a set of Neutron ports, to define the sequence of service functions
26 * a set of flow classifiers, to specify the classified traffic flows to enter the chain
27 */
28public interface PortChain {
29
30 /**
31 * Returns the ID of this port chain.
32 *
33 * @return the port chain id
34 */
35 PortChainId portChainId();
36
37 /**
38 * Returns the tenant id of this port chain.
39 *
40 * @return the tenant id
41 */
42 TenantId tenantId();
43
44 /**
45 * Returns the name of this port chain.
46 *
47 * @return name of port chain
48 */
49 String name();
50
51 /**
52 * Returns the description of this port chain.
53 *
54 * @return description of port chain
55 */
56 String description();
57
58 /**
59 * Returns the list of port pair groups associated with
60 * this port chain.
61 *
62 * @return list of port pair groups
63 */
64 List<PortPairGroupId> portPairGroups();
65
66 /**
67 * Returns the list of flow classifiers associated with
68 * this port chain.
69 *
70 * @return list of flow classifiers
71 */
72 List<FlowClassifierId> flowClassifiers();
73
74 /**
Phaneendra Manda329a1272016-02-10 22:57:00 +053075 * Adds a new load balanced path.
76 *
77 * @param fiveTuple five tuple from the packet
78 * @param id load balance path identifier
79 * @param path load balanced path of list of port pairs
80 */
81 void addLoadBalancePath(FiveTuple fiveTuple, LoadBalanceId id,
82 List<PortPairId> path);
83
84 /**
85 * Get the load balance id from five tuple.
86 *
87 * @param fiveTuple five tuple from the packet
88 * @return load balance identifier for the given packet
89 */
90 LoadBalanceId getLoadBalanceId(FiveTuple fiveTuple);
91
92 /**
93 * Get the keys set from load balanced id map.
94 *
95 * @return set of five tuple info
96 */
97 Set<FiveTuple> getLoadBalanceIdMapKeys();
98
99 /**
100 * Get the load balanced path from load balance Id.
101 *
102 * @param id load balance id.
103 * @return path containing list of port pairs
104 */
105 List<PortPairId> getLoadBalancePath(LoadBalanceId id);
106
107 /**
108 * Get the load balanced path from five tuple.
109 *
110 * @param fiveTuple five tuple from the packet
111 * @return path containing list of port pairs
112 */
113 List<PortPairId> getLoadBalancePath(FiveTuple fiveTuple);
114
115 /**
Phaneendra Manda275ff0c2016-02-25 11:50:24 +0530116 * Get the no of load balance paths created.
117 *
118 * @return size of load balanced paths
119 */
120 int getLoadBalancePathSize();
121
122 /**
Phaneendra Manda329a1272016-02-10 22:57:00 +0530123 * Match the given path with existing load balanced paths.
124 *
125 * @param path load balanced path
126 * @return load balance id if the path matches, null otherwise.
127 */
128 Optional<LoadBalanceId> matchPath(List<PortPairId> path);
129
130 /**
Phaneendra Manda1ea49142015-10-26 22:33:06 +0530131 * Returns whether this port chain is an exact match to the port chain given
132 * in the argument.
133 * <p>
134 * Exact match means the port pair groups and flow classifiers match
135 * with the given port chain. It does not consider the port chain id, name
136 * and description.
137 * </p>
138 *
139 * @param portChain other port chain to match against
140 * @return true if the port chains are an exact match, otherwise false
141 */
142 boolean exactMatch(PortChain portChain);
143
144 /**
145 * A port chain builder..
146 */
147 interface Builder {
148
149 /**
150 * Assigns the port chain id to this object.
151 *
152 * @param portChainId the port chain id
153 * @return this the builder object
154 */
155 Builder setId(PortChainId portChainId);
156
157 /**
158 * Assigns tenant id to this object.
159 *
160 * @param tenantId tenant id of the port chain
161 * @return this the builder object
162 */
163 Builder setTenantId(TenantId tenantId);
164
165 /**
166 * Assigns the name to this object.
167 *
168 * @param name name of the port chain
169 * @return this the builder object
170 */
171 Builder setName(String name);
172
173 /**
174 * Assigns the description to this object.
175 *
176 * @param description description of the port chain
177 * @return this the builder object
178 */
179 Builder setDescription(String description);
180
181 /**
182 * Assigns the port pair groups associated with the port chain
183 * to this object.
184 *
185 * @param portPairGroups list of port pair groups
186 * @return this the builder object
187 */
188 Builder setPortPairGroups(List<PortPairGroupId> portPairGroups);
189
190 /**
191 * Assigns the flow classifiers associated with the port chain
192 * to this object.
193 *
194 * @param flowClassifiers list of flow classifiers
195 * @return this the builder object
196 */
197 Builder setFlowClassifiers(List<FlowClassifierId> flowClassifiers);
198
199 /**
200 * Builds a port chain object.
201 *
202 * @return a port chain.
203 */
204 PortChain build();
205 }
206}