blob: f418c1e0a1b7dfaef18015e2a34679f2f0e5a4d8 [file] [log] [blame]
Pavlin Radoslavov5ab68512013-02-18 09:59:33 -08001package net.floodlightcontroller.flowcache.web;
2
3import net.floodlightcontroller.flowcache.IFlowService;
Pavlin Radoslavova10a9a82013-02-22 11:47:54 -08004import net.floodlightcontroller.util.FlowId;
Pavlin Radoslavov5ab68512013-02-18 09:59:33 -08005
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 DeleteFlowResource extends ServerResource {
13 protected static Logger log = LoggerFactory.getLogger(DeleteFlowResource.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 Radoslavov2013cbb2013-02-26 10:15:18 -080030 FlowId flowId = new FlowId(flowIdStr);
Pavlin Radoslavov5ab68512013-02-18 09:59:33 -080031 log.debug("Delete Flow Id: " + flowIdStr);
32
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080033 // Process the request
Pavlin Radoslavova10a9a82013-02-22 11:47:54 -080034 result = flowService.deleteFlow(flowId);
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080035 return result;
Pavlin Radoslavov5ab68512013-02-18 09:59:33 -080036 }
37}