Add support for deleting or clearing all flows:
web/delete_flow.py all
web/clear_flow.py all
diff --git a/src/main/java/net/floodlightcontroller/flowcache/FlowManager.java b/src/main/java/net/floodlightcontroller/flowcache/FlowManager.java
index cce873a..251620c 100644
--- a/src/main/java/net/floodlightcontroller/flowcache/FlowManager.java
+++ b/src/main/java/net/floodlightcontroller/flowcache/FlowManager.java
@@ -751,6 +751,23 @@
}
/**
+ * Delete all previously added flows.
+ *
+ * @return true on success, otherwise false.
+ */
+ @Override
+ public boolean deleteAllFlows() {
+
+ // Get all flows and delete them one-by-one
+ ArrayList<FlowPath> allFlows = getAllFlows();
+ for (FlowPath flowPath : allFlows) {
+ deleteFlow(flowPath.flowId());
+ }
+
+ return true;
+ }
+
+ /**
* Delete a previously added flow.
*
* @param flowId the Flow ID of the flow to delete.
@@ -813,6 +830,23 @@
}
/**
+ * Clear the state for all previously added flows.
+ *
+ * @return true on success, otherwise false.
+ */
+ @Override
+ public boolean clearAllFlows() {
+
+ // Get all flows and clear them one-by-one
+ ArrayList<FlowPath> allFlows = getAllFlows();
+ for (FlowPath flowPath : allFlows) {
+ clearFlow(flowPath.flowId());
+ }
+
+ return true;
+ }
+
+ /**
* Clear the state for a previously added flow.
*
* @param flowId the Flow ID of the flow to clear.
diff --git a/src/main/java/net/floodlightcontroller/flowcache/IFlowService.java b/src/main/java/net/floodlightcontroller/flowcache/IFlowService.java
index a534410..5e0db35 100644
--- a/src/main/java/net/floodlightcontroller/flowcache/IFlowService.java
+++ b/src/main/java/net/floodlightcontroller/flowcache/IFlowService.java
@@ -29,6 +29,13 @@
String dataPathSummaryStr);
/**
+ * Delete all previously added flows.
+ *
+ * @return true on success, otherwise false.
+ */
+ boolean deleteAllFlows();
+
+ /**
* Delete a previously added flow.
*
* @param flowId the Flow ID of the flow to delete.
@@ -37,6 +44,13 @@
boolean deleteFlow(FlowId flowId);
/**
+ * Clear the state for all previously added flows.
+ *
+ * @return true on success, otherwise false.
+ */
+ boolean clearAllFlows();
+
+ /**
* Clear the state for a previously added flow.
*
* @param flowId the Flow ID of the flow to clear.
diff --git a/src/main/java/net/floodlightcontroller/flowcache/web/ClearFlowResource.java b/src/main/java/net/floodlightcontroller/flowcache/web/ClearFlowResource.java
index 8fff358..7f3b589 100644
--- a/src/main/java/net/floodlightcontroller/flowcache/web/ClearFlowResource.java
+++ b/src/main/java/net/floodlightcontroller/flowcache/web/ClearFlowResource.java
@@ -27,11 +27,16 @@
// Extract the arguments
String flowIdStr = (String) getRequestAttributes().get("flow-id");
- FlowId flowId = new FlowId(flowIdStr);
- log.debug("Clear Flow Id: " + flowIdStr);
// Process the request
- result = flowService.clearFlow(flowId);
+ if (flowIdStr.equals("all")) {
+ log.debug("Clear All Flows");
+ result = flowService.clearAllFlows();
+ } else {
+ FlowId flowId = new FlowId(flowIdStr);
+ log.debug("Clear Flow Id: " + flowIdStr);
+ result = flowService.clearFlow(flowId);
+ }
return result;
}
}
diff --git a/src/main/java/net/floodlightcontroller/flowcache/web/DeleteFlowResource.java b/src/main/java/net/floodlightcontroller/flowcache/web/DeleteFlowResource.java
index f418c1e..ed6f0f7 100644
--- a/src/main/java/net/floodlightcontroller/flowcache/web/DeleteFlowResource.java
+++ b/src/main/java/net/floodlightcontroller/flowcache/web/DeleteFlowResource.java
@@ -27,11 +27,16 @@
// Extract the arguments
String flowIdStr = (String) getRequestAttributes().get("flow-id");
- FlowId flowId = new FlowId(flowIdStr);
- log.debug("Delete Flow Id: " + flowIdStr);
// Process the request
- result = flowService.deleteFlow(flowId);
+ if (flowIdStr.equals("all")) {
+ log.debug("Delete All Flows");
+ result = flowService.deleteAllFlows();
+ } else {
+ FlowId flowId = new FlowId(flowIdStr);
+ log.debug("Delete Flow Id: " + flowIdStr);
+ result = flowService.deleteFlow(flowId);
+ }
return result;
}
}
diff --git a/web/clear_flow.py b/web/clear_flow.py
index 50678e2..db70d40 100755
--- a/web/clear_flow.py
+++ b/web/clear_flow.py
@@ -51,6 +51,7 @@
usage_msg = usage_msg + " Arguments:\n"
usage_msg = usage_msg + " <begin-flow-id> <end-flow-id> Clear all flows in the flow ID range\n"
usage_msg = usage_msg + " <flow-id> Clear a single flow with the flow ID\n"
+ usage_msg = usage_msg + " all Clear all flows\n"
# app.debug = False;
@@ -63,14 +64,18 @@
if len(sys.argv) < 2:
log_error(usage_msg)
exit(1)
- begin_flow_id = int(sys.argv[1], 0)
- if len(sys.argv) >= 3:
- end_flow_id = int(sys.argv[2], 0)
- else:
- end_flow_id = begin_flow_id
- # Do the work
- flow_id = begin_flow_id
- while flow_id <= end_flow_id:
- clear_flow_path(flow_id)
- flow_id = flow_id + 1
+ if (sys.argv[1] == "all"):
+ clear_flow_path(sys.argv[1])
+ else:
+ begin_flow_id = int(sys.argv[1], 0)
+ if len(sys.argv) >= 3:
+ end_flow_id = int(sys.argv[2], 0)
+ else:
+ end_flow_id = begin_flow_id
+
+ # Do the work
+ flow_id = begin_flow_id
+ while flow_id <= end_flow_id:
+ clear_flow_path(flow_id)
+ flow_id = flow_id + 1
diff --git a/web/delete_flow.py b/web/delete_flow.py
index ff4caff..fff9319 100755
--- a/web/delete_flow.py
+++ b/web/delete_flow.py
@@ -51,6 +51,7 @@
usage_msg = usage_msg + " Arguments:\n"
usage_msg = usage_msg + " <begin-flow-id> <end-flow-id> Delete all flows in the flow ID range\n"
usage_msg = usage_msg + " <flow-id> Delete a single flow with the flow ID\n"
+ usage_msg = usage_msg + " all Delete all flows\n"
# app.debug = False;
@@ -63,14 +64,18 @@
if len(sys.argv) < 2:
log_error(usage_msg)
exit(1)
- begin_flow_id = int(sys.argv[1], 0)
- if len(sys.argv) >= 3:
- end_flow_id = int(sys.argv[2], 0)
- else:
- end_flow_id = begin_flow_id
- # Do the work
- flow_id = begin_flow_id
- while flow_id <= end_flow_id:
- delete_flow_path(flow_id)
- flow_id = flow_id + 1
+ if (sys.argv[1] == "all"):
+ delete_flow_path(sys.argv[1])
+ else:
+ begin_flow_id = int(sys.argv[1], 0)
+ if len(sys.argv) >= 3:
+ end_flow_id = int(sys.argv[2], 0)
+ else:
+ end_flow_id = begin_flow_id
+
+ # Do the work
+ flow_id = begin_flow_id
+ while flow_id <= end_flow_id:
+ delete_flow_path(flow_id)
+ flow_id = flow_id + 1