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