blob: ba870104565334ffcc83f151b9fc8752c9d82994 [file] [log] [blame]
Phaneendra Manda1ea49142015-10-26 22:33:06 +05301/*
2 * Copyright 2015 Open Networking Laboratory
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 */
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 /**
116 * Match the given path with existing load balanced paths.
117 *
118 * @param path load balanced path
119 * @return load balance id if the path matches, null otherwise.
120 */
121 Optional<LoadBalanceId> matchPath(List<PortPairId> path);
122
123 /**
Phaneendra Manda1ea49142015-10-26 22:33:06 +0530124 * Returns whether this port chain is an exact match to the port chain given
125 * in the argument.
126 * <p>
127 * Exact match means the port pair groups and flow classifiers match
128 * with the given port chain. It does not consider the port chain id, name
129 * and description.
130 * </p>
131 *
132 * @param portChain other port chain to match against
133 * @return true if the port chains are an exact match, otherwise false
134 */
135 boolean exactMatch(PortChain portChain);
136
137 /**
138 * A port chain builder..
139 */
140 interface Builder {
141
142 /**
143 * Assigns the port chain id to this object.
144 *
145 * @param portChainId the port chain id
146 * @return this the builder object
147 */
148 Builder setId(PortChainId portChainId);
149
150 /**
151 * Assigns tenant id to this object.
152 *
153 * @param tenantId tenant id of the port chain
154 * @return this the builder object
155 */
156 Builder setTenantId(TenantId tenantId);
157
158 /**
159 * Assigns the name to this object.
160 *
161 * @param name name of the port chain
162 * @return this the builder object
163 */
164 Builder setName(String name);
165
166 /**
167 * Assigns the description to this object.
168 *
169 * @param description description of the port chain
170 * @return this the builder object
171 */
172 Builder setDescription(String description);
173
174 /**
175 * Assigns the port pair groups associated with the port chain
176 * to this object.
177 *
178 * @param portPairGroups list of port pair groups
179 * @return this the builder object
180 */
181 Builder setPortPairGroups(List<PortPairGroupId> portPairGroups);
182
183 /**
184 * Assigns the flow classifiers associated with the port chain
185 * to this object.
186 *
187 * @param flowClassifiers list of flow classifiers
188 * @return this the builder object
189 */
190 Builder setFlowClassifiers(List<FlowClassifierId> flowClassifiers);
191
192 /**
193 * Builds a port chain object.
194 *
195 * @return a port chain.
196 */
197 PortChain build();
198 }
199}