78917c9c807752232c9e8af4d25f007fd1f7446b
[controller.git] / opendaylight / forwardingrulesmanager / api / src / main / java / org / opendaylight / controller / forwardingrulesmanager / IForwardingRulesManager.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.forwardingrulesmanager;
10
11 import java.util.List;
12 import java.util.Map;
13
14 import org.opendaylight.controller.sal.core.Node;
15 import org.opendaylight.controller.sal.core.NodeConnector;
16 import org.opendaylight.controller.sal.utils.Status;
17
18 /**
19  * Interface that describes methods for installing or removing forwarding rules
20  * and to access to the flows database.
21  * 
22  */
23 public interface IForwardingRulesManager {
24
25     /**
26      * It requests FRM to install the passed Flow Entry. FRM will request the
27      * SDN protocol plugin to install the flow on the network node. Based on the
28      * result of this operation FRM will update its database accordingly and
29      * will return the proper {@code Status} code.
30      * 
31      * @param flow
32      *            the flow entry to install
33      * @return the {@code Status} object indicating the result of this action.
34      */
35     public Status installFlowEntry(FlowEntry flow);
36
37     /**
38      * It requests FRM to remove the passed Flow Entry. FRM will request the SDN
39      * protocol plugin to uninstall the flow from the network node. Based on the
40      * result of this operation FRM will update its database accordingly and
41      * will return the proper {@code Status} code.
42      * 
43      * @param flow
44      *            the flow entry to uninstall
45      * @return the {@code Status} object indicating the result of this action
46      */
47     public Status uninstallFlowEntry(FlowEntry flow);
48
49     /**
50      * It requests FRM to replace the currently installed Flow Entry with the
51      * new one. It is up to the SDN protocol plugin to decide how to convey this
52      * message to the network node. It could be a delete + add or a single
53      * modify message depending on the SDN protocol specifications If the
54      * current flow is equal to the new one it will be a no op and success code
55      * is returned.
56      * 
57      * @param current
58      *            the current flow entry to modify
59      * @param newone
60      *            the new flow entry which will replace the current one
61      * @return the {@code Status} object indicating the result of this action
62      */
63     public Status modifyFlowEntry(FlowEntry current, FlowEntry newone);
64
65     /**
66      * It requests the FRM to replace the currently installed Flow Entry with
67      * the new one. The currently installed entry is derived by the Match
68      * portion of the passed Flow. FRM looks in its database for a previously
69      * installed FlowEntry which Match equals the Match of the passed Flow. If
70      * it finds it, it will request the SDN protocol plugin to replace the
71      * existing flow with the new one on the network node. If it does not find
72      * it, it will request plugin to add the new flow. If the passed entry is
73      * not valid an error code is returned. If the existing flow is equal to the
74      * passed one it will be a no op and success code is returned.
75      * 
76      * 
77      * @param newone
78      *            the new flow entry to install
79      * @return the {@code Status} object indicating the result of this action
80      */
81     public Status modifyOrAddFlowEntry(FlowEntry newone);
82
83     /**
84      * It requests FRM to install the passed Flow Entry through an asynchronous
85      * call. A unique request id is returned to the caller. FRM will request the
86      * SDN protocol plugin to install the flow on the network node. As immediate
87      * result of this asynchronous call, FRM will update its flow database as if
88      * the flow was successfully installed.
89      * 
90      * @param flow
91      *            the flow entry to install
92      * @return the status of this request containing the request id associated
93      *         to this asynchronous request
94      */
95     public Status installFlowEntryAsync(FlowEntry flow);
96
97     /**
98      * It requests FRM to remove the passed Flow Entry through an asynchronous
99      * call. A unique request id is returned to the caller. FRM will request the
100      * SDN protocol plugin to uninstall the flow from the network node. As
101      * immediate result of this asynchronous call, FRM will update its flow
102      * database as if the flow was successfully installed.
103      * 
104      * @param flow
105      *            the flow entry to uninstall
106      * @return the status of this request containing the unique id associated to
107      *         this asynchronous request
108      */
109     public Status uninstallFlowEntryAsync(FlowEntry flow);
110
111     /**
112      * It requests FRM to replace the currently installed Flow Entry with the
113      * new one through an asynchronous call. A unique request id is returned to
114      * the caller. It is up to the SDN protocol plugin to decide how to convey
115      * this message to the network node. It could be a delete + add or a single
116      * modify message depending on the SDN protocol specifications. If the
117      * current flow is equal to the new one it will be a no op.
118      * 
119      * @param current
120      *            the current flow entry to modify
121      * @param newone
122      *            the new flow entry which will replace the current one
123      * @return the status of this request containing the request id associated
124      *         to this asynchronous request
125      */
126     public Status modifyFlowEntryAsync(FlowEntry current, FlowEntry newone);
127
128     /**
129      * It requests the FRM to replace the currently installed Flow Entry with
130      * the new one through an asynchronous call. A unique request id is returned
131      * to the caller. The currently installed entry is derived by the Match
132      * portion of the passed Flow. FRM looks in its database for a previously
133      * installed FlowEntry which Match equals the Match of the passed Flow. If
134      * it finds it, it will request the SDN protocol plugin to replace the
135      * existing flow with the new one on the network node. If it does not find
136      * it, it will request plugin to add the new flow. If the passed entry is
137      * not valid a zero request id is returned. If the existing flow is equal to
138      * the passed one it will be a no op.
139      * 
140      * @param newone
141      *            the new flow entry to install
142      * @return the unique id associated to this request. In case of not
143      *         acceptable request -1 will be returned.
144      */
145     public Status modifyOrAddFlowEntryAsync(FlowEntry newone);
146
147     /**
148      * Requests ForwardingRulesManager to solicit the network node to inform
149      * us about the status of his execution on the asynchronous requests that
150      * were sent to it so far. It is a way for an application to poke the
151      * network node in order to get a feedback asap on the asynchronous
152      * requests generated by the application. It is a non-blocking call
153      * and does not guarantee the node will respond in any given time. 
154      * 
155      * @param node
156      *          The network node to solicit a response
157      */
158     public void solicitStatusResponse(Node node);
159
160     /**
161      * Check whether the passed flow entry conflicts with the Container flows
162      * 
163      * @param flow
164      *            the flow entry to test
165      * @return true if conflicts, false otherwise
166      */
167     public boolean checkFlowEntryConflict(FlowEntry flow);
168
169     /**
170      * Returns the list of Flow entries across network nodes which are part of
171      * the same flow group, policy
172      * 
173      * @param group
174      *            the group name
175      * @return the list of flow entries belonging to the specified group
176      */
177     public List<FlowEntry> getFlowEntriesForGroup(String group);
178
179     /**
180      * Add a list of output port to the flow with the specified name on the
181      * specified network node
182      * 
183      * @param node
184      *            the network node
185      * @param flowName
186      *            the flow name
187      * @param dstPort
188      *            the list of ports to be added to the flow output actions
189      */
190     public void addOutputPort(Node node, String flowName,
191             List<NodeConnector> dstPort);
192
193     /**
194      * Remove a list of output port from the flow with the specified name on the
195      * specified network node
196      * 
197      * @param node
198      *            the network node
199      * @param flowName
200      *            the flow name
201      * @param dstPortthe
202      *            list of ports to be removed from the flow output actions
203      */
204     public void removeOutputPort(Node node, String flowName,
205             List<NodeConnector> dstPort);
206
207     /**
208      * Replace the current output port in the specified flow with the specified
209      * one
210      * 
211      * @param node
212      *            the network node
213      * @param groupName
214      *            the group name
215      * @param flowName
216      *            the flow name
217      * @param dstPort
218      *            the new output action port
219      */
220     public void replaceOutputPort(Node node, String flowName,
221             NodeConnector outPort);
222
223     /**
224      * Returns the output port configured on the specified flow
225      * 
226      * @param node
227      *            the network node
228      * @param flowName
229      *            the flow name
230      * @return the output action port for the specified flow
231      */
232     public NodeConnector getOutputPort(Node node, String flowName);
233
234     /**
235      * Returns all the troubleshooting information that applications have set
236      * along with the policy they have configured through forwarding rules
237      * manger.
238      * 
239      * @return the collection of troubleshooting objects
240      */
241     public Map<String, Object> getTSPolicyData();
242
243     /**
244      * Set the troubleshooting information for the policy
245      * 
246      * @param policyname
247      *            the flow group name
248      * @param o
249      *            the object containing the troubleshooting information
250      * @param add
251      *            true for adding, false for removing
252      */
253     public void setTSPolicyData(String policyName, Object o, boolean add);
254
255     /**
256      * Returns the troubleshooting information that was set for the specified
257      * policy
258      * 
259      * @param groupName
260      *            the flows group name
261      * @return the troubleshooting info object
262      */
263     public Object getTSPolicyData(String policyName);
264
265     /**
266      * Returns the specifications of all the flows configured for all the
267      * switches on the current container
268      * 
269      * @return the list of flow configurations present in the database
270      */
271     public List<FlowConfig> getStaticFlows();
272
273     /**
274      * Returns the specifications of all the flows configured for the given
275      * switch on the current container
276      * 
277      * @param node
278      *            the network node identifier
279      * @return the list of {@code FlowConfig} objects
280      */
281     public List<FlowConfig> getStaticFlows(Node node);
282
283     /**
284      * Returns the specification of the flow configured for the given network
285      * node on the current container
286      * 
287      * @param name
288      *            the flow name
289      * @param n
290      *            the network node identifier
291      * @return the {@code FlowConfig} object
292      */
293     public FlowConfig getStaticFlow(String name, Node n);
294
295     /**
296      * Returns the list of names of flows configured for the given Network node
297      * on the current container
298      * 
299      * @param node
300      *            the network node identifier
301      * @return the list of flow names
302      */
303     public List<String> getStaticFlowNamesForNode(Node node);
304
305     /**
306      * Returns the list of Node(s) for which a static flow has been configured
307      * 
308      * @return the list of network nodes
309      */
310     public List<Node> getListNodeWithConfiguredFlows();
311
312     /**
313      * Save the flow configured so far to file
314      * 
315      * @return the {@code Status} object indicating the result of this action.
316      */
317     public Status saveConfig();
318
319     /**
320      * Add a flow specified by the {@code FlowConfig} object on the current
321      * container
322      * 
323      * @param config
324      *            the {@code FlowConfig} object representing the static flow
325      * @param restore
326      *            if set to true, the config object validation will be skipped.
327      *            Used only internally, always set it to false.
328      * @return the {@code Status} object indicating the result of this action.
329      */
330     public Status addStaticFlow(FlowConfig config, boolean restore);
331
332     /**
333      * Remove a flow specified by the {@code FlowConfig} object on the current
334      * container
335      * 
336      * @param config
337      *            the {@code FlowConfig} object representing the static flow
338      * @return the {@code Status} object indicating the result of this action
339      */
340     public Status removeStaticFlow(FlowConfig config);
341
342     /**
343      * Replace the flow identified by the {@code FlowConfig.name} name for the
344      * {@code FlowConfig.node} network node with the new flow specified by
345      * {@code FlowConfig} object
346      * 
347      * @param config
348      *            the {@code FlowConfig} object
349      * @returnthe {@code Status} object indicating the result of this action
350      */
351     public Status modifyStaticFlow(FlowConfig config);
352
353     /**
354      * Remove the flow specified by name on the passed network node
355      * 
356      * @param name
357      *            for the static flow
358      * @param node
359      *            on which the flow is attached
360      * @return the {@code Status} object indicating the result of this action
361      */
362     public Status removeStaticFlow(String name, Node node);
363
364     /**
365      * Toggle the installation status of the specified configured flow If the
366      * flow configuration status is active, this call will change the flow
367      * status to inactive and vice-versa
368      * 
369      * @param configObject
370      *            the {@code FlowConfig} object
371      * @return the {@code Status} object indicating the result of this action
372      */
373     public Status toggleStaticFlowStatus(FlowConfig configObject);
374
375     /**
376      * Toggle the installation status of the specified configured flow If the
377      * flow configuration status is active, this call will change the flow
378      * status to inactive and vice-versa
379      * 
380      * @param name
381      *            for the static flow
382      * @param node
383      *            on which the flow is attached
384      * @return the {@code Status} object indicating the result of this action
385      */
386     public Status toggleStaticFlowStatus(String name, Node node);
387
388     public Map<String, PortGroupConfig> getPortGroupConfigs();
389
390     public boolean addPortGroupConfig(String name, String regex, boolean load);
391
392     public boolean delPortGroupConfig(String name);
393
394     public PortGroupProvider getPortGroupProvider();
395
396 }