blob: e51bc9dff6c47f5ee4baa06aafc6c2c5fee2eb73 [file] [log] [blame]
HIGUCHI Yutaefa54882013-06-12 13:13:02 -07001package net.onrc.onos.ofcontroller.flowcache.web;
Pavlin Radoslavov916832f2013-03-14 17:48:41 -07002
HIGUCHI Yutaedf81d72013-06-12 12:06:57 -07003import net.onrc.onos.ofcontroller.flowcache.IFlowService;
HIGUCHI Yuta356086e2013-06-12 15:21:19 -07004import net.onrc.onos.ofcontroller.util.FlowId;
Pavlin Radoslavov916832f2013-03-14 17:48:41 -07005
6import org.openflow.util.HexString;
7import org.restlet.resource.Get;
8import org.restlet.resource.ServerResource;
9import org.slf4j.Logger;
10import org.slf4j.LoggerFactory;
11
12public class ClearFlowResource extends ServerResource {
13 protected static Logger log = LoggerFactory.getLogger(ClearFlowResource.class);
14
15 @Get("json")
16 public Boolean retrieve() {
17 Boolean result = false;
18
19 IFlowService flowService =
20 (IFlowService)getContext().getAttributes().
21 get(IFlowService.class.getCanonicalName());
22
23 if (flowService == null) {
24 log.debug("ONOS Flow Service not found");
25 return result;
26 }
27
28 // Extract the arguments
29 String flowIdStr = (String) getRequestAttributes().get("flow-id");
Pavlin Radoslavov916832f2013-03-14 17:48:41 -070030
31 // Process the request
Pavlin Radoslavovbaea9242013-05-08 00:20:09 +000032 if (flowIdStr.equals("all")) {
33 log.debug("Clear All Flows");
34 result = flowService.clearAllFlows();
35 } else {
36 FlowId flowId = new FlowId(flowIdStr);
37 log.debug("Clear Flow Id: " + flowIdStr);
38 result = flowService.clearFlow(flowId);
39 }
Pavlin Radoslavov916832f2013-03-14 17:48:41 -070040 return result;
41 }
42}