9d68f84a3ae62dff4e968acba87cb8a4ec5e9b76
[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. This list contains the flows as they were
203      * requested to be installed by the applications, before any merging with
204      * container flow is done.
205      *
206      * @param group
207      *            the group name
208      * @return the original list of flow entries belonging to the specified group
209      */
210     public List<FlowEntry> getFlowEntriesForGroup(String group);
211
212     /**
213      * Returns the list of Flow entries installed in network nodes which are part of
214      * the same flow group, policy. This list contains the effective flows installed
215      * on the nodes after the merging with any possible container flow was performed.
216      * If no container flow are specified, this method returns the same list returned
217      * by getFlowEntriesForGroup(String group).
218      *
219      * @param group
220      *            the group name
221      * @return the list of container flow merged flow entries belonging to the specified group
222      */
223     public List<FlowEntry> getInstalledFlowEntriesForGroup(String policyName);
224
225     /**
226      * Add a list of output port to the flow with the specified name on the
227      * specified network node
228      *
229      * @param node
230      *            the network node
231      * @param flowName
232      *            the flow name
233      * @param dstPort
234      *            the list of ports to be added to the flow output actions
235      */
236     public void addOutputPort(Node node, String flowName, List<NodeConnector> dstPort);
237
238     /**
239      * Remove a list of output port from the flow with the specified name on the
240      * specified network node
241      *
242      * @param node
243      *            the network node
244      * @param flowName
245      *            the flow name
246      * @param dstPortthe
247      *            list of ports to be removed from the flow output actions
248      */
249     public void removeOutputPort(Node node, String flowName, List<NodeConnector> dstPort);
250
251     /**
252      * Replace the current output port in the specified flow with the specified
253      * one
254      *
255      * @param node
256      *            the network node
257      * @param groupName
258      *            the group name
259      * @param flowName
260      *            the flow name
261      * @param dstPort
262      *            the new output action port
263      */
264     public void replaceOutputPort(Node node, String flowName, NodeConnector outPort);
265
266     /**
267      * Returns the output port configured on the specified flow
268      *
269      * @param node
270      *            the network node
271      * @param flowName
272      *            the flow name
273      * @return the output action port for the specified flow
274      */
275     public NodeConnector getOutputPort(Node node, String flowName);
276
277     /**
278      * Returns all the troubleshooting information that applications have set
279      * along with the policy they have configured through forwarding rules
280      * manger.
281      *
282      * @return the collection of troubleshooting objects
283      */
284     public Map<String, Object> getTSPolicyData();
285
286     /**
287      * Set the troubleshooting information for the policy
288      *
289      * @param policyname
290      *            the flow group name
291      * @param o
292      *            the object containing the troubleshooting information
293      * @param add
294      *            true for adding, false for removing
295      */
296     public void setTSPolicyData(String policyName, Object o, boolean add);
297
298     /**
299      * Returns the troubleshooting information that was set for the specified
300      * policy
301      *
302      * @param groupName
303      *            the flows group name
304      * @return the troubleshooting info object
305      */
306     public Object getTSPolicyData(String policyName);
307
308     /**
309      * Returns the specifications of all the flows configured for all the
310      * switches on the current container
311      *
312      * @return the list of flow configurations present in the database
313      */
314     public List<FlowConfig> getStaticFlows();
315
316     /**
317      * Returns the specifications of all the flows configured for the given
318      * switch on the current container
319      *
320      * @param node
321      *            the network node identifier
322      * @return the list of {@code FlowConfig} objects
323      */
324     public List<FlowConfig> getStaticFlows(Node node);
325
326     /**
327      * Returns the specification of the flow configured for the given network
328      * node on the current container
329      *
330      * @param name
331      *            the flow name
332      * @param n
333      *            the network node identifier
334      * @return the {@code FlowConfig} object
335      */
336     public FlowConfig getStaticFlow(String name, Node n);
337
338     /**
339      * Returns the list of names of flows configured for the given Network node
340      * on the current container
341      *
342      * @param node
343      *            the network node identifier
344      * @return the list of flow names
345      */
346     public List<String> getStaticFlowNamesForNode(Node node);
347
348     /**
349      * Returns the list of Node(s) for which a static flow has been configured
350      *
351      * @return the list of network nodes
352      */
353     public List<Node> getListNodeWithConfiguredFlows();
354
355     /**
356      * Save the flow configured so far to file
357      *
358      * @return the {@code Status} object indicating the result of this action.
359      */
360     public Status saveConfig();
361
362     /**
363      * Add a flow specified by the {@code FlowConfig} object on the current
364      * container
365      *
366      * @param config
367      *            the {@code FlowConfig} object representing the static flow
368      * @return the {@code Status} object indicating the result of this action.
369      */
370     public Status addStaticFlow(FlowConfig config);
371
372     /**
373      * Remove a flow specified by the {@code FlowConfig} object on the current
374      * container
375      *
376      * @param config
377      *            the {@code FlowConfig} object representing the static flow
378      * @return the {@code Status} object indicating the result of this action
379      */
380     public Status removeStaticFlow(FlowConfig config);
381
382     /**
383      * Replace the flow identified by the {@code FlowConfig.name} name for the
384      * {@code FlowConfig.node} network node with the new flow specified by
385      * {@code FlowConfig} object
386      *
387      * @param config
388      *            the {@code FlowConfig} object
389      * @returnthe {@code Status} object indicating the result of this action
390      */
391     public Status modifyStaticFlow(FlowConfig config);
392
393     /**
394      * Remove the flow specified by name on the passed network node
395      *
396      * @param name
397      *            for the static flow
398      * @param node
399      *            on which the flow is attached
400      * @return the {@code Status} object indicating the result of this action
401      */
402     public Status removeStaticFlow(String name, Node node);
403
404     /**
405      * Toggle the installation status of the specified configured flow If the
406      * flow configuration status is active, this call will change the flow
407      * status to inactive and vice-versa
408      *
409      * @param configObject
410      *            the {@code FlowConfig} object
411      * @return the {@code Status} object indicating the result of this action
412      */
413     public Status toggleStaticFlowStatus(FlowConfig configObject);
414
415     /**
416      * Toggle the installation status of the specified configured flow If the
417      * flow configuration status is active, this call will change the flow
418      * status to inactive and vice-versa
419      *
420      * @param name
421      *            for the static flow
422      * @param node
423      *            on which the flow is attached
424      * @return the {@code Status} object indicating the result of this action
425      */
426     public Status toggleStaticFlowStatus(String name, Node node);
427
428     public Map<String, PortGroupConfig> getPortGroupConfigs();
429
430     public boolean addPortGroupConfig(String name, String regex, boolean load);
431
432     public boolean delPortGroupConfig(String name);
433
434     public PortGroupProvider getPortGroupProvider();
435
436     /**
437      * Returns the list of Flow entries for a network node.
438      * This list contains the flows as they were
439      * requested to be installed by the applications, before any merging with
440      * container flow is done.
441      *
442      * @param node
443      * @return the original list of flow entries belonging to the specified node
444      */
445     public List<FlowEntry> getFlowEntriesForNode(Node node);
446
447     /**
448      * Returns the list of Flow entries installed in a network node.
449      * This list contains the effective flows installed
450      * on the nodes after the merging with any possible container flow was performed.
451      * If no container flow are specified, this method returns the same list as returned
452      * by getFlowEntriesForNode(Node node).
453      *
454      * @param node
455      * @return the list of container flow merged flow entries belonging to the specified node
456      */
457     public List<FlowEntry> getInstalledFlowEntriesForNode(Node node);
458
459 }