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