HIGUCHI Yuta | efa5488 | 2013-06-12 13:13:02 -0700 | [diff] [blame^] | 1 | package net.onrc.onos.ofcontroller.flowcache.web; |
Pavlin Radoslavov | 5ab6851 | 2013-02-18 09:59:33 -0800 | [diff] [blame] | 2 | |
Pavlin Radoslavov | a10a9a8 | 2013-02-22 11:47:54 -0800 | [diff] [blame] | 3 | import net.floodlightcontroller.util.FlowId; |
HIGUCHI Yuta | edf81d7 | 2013-06-12 12:06:57 -0700 | [diff] [blame] | 4 | import net.onrc.onos.ofcontroller.flowcache.IFlowService; |
Pavlin Radoslavov | 5ab6851 | 2013-02-18 09:59:33 -0800 | [diff] [blame] | 5 | |
| 6 | import org.openflow.util.HexString; |
| 7 | import org.restlet.resource.Get; |
| 8 | import org.restlet.resource.ServerResource; |
| 9 | import org.slf4j.Logger; |
| 10 | import org.slf4j.LoggerFactory; |
| 11 | |
| 12 | public 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 Radoslavov | 5ab6851 | 2013-02-18 09:59:33 -0800 | [diff] [blame] | 30 | |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 31 | // Process the request |
Pavlin Radoslavov | baea924 | 2013-05-08 00:20:09 +0000 | [diff] [blame] | 32 | if (flowIdStr.equals("all")) { |
| 33 | log.debug("Delete All Flows"); |
| 34 | result = flowService.deleteAllFlows(); |
| 35 | } else { |
| 36 | FlowId flowId = new FlowId(flowIdStr); |
| 37 | log.debug("Delete Flow Id: " + flowIdStr); |
| 38 | result = flowService.deleteFlow(flowId); |
| 39 | } |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 40 | return result; |
Pavlin Radoslavov | 5ab6851 | 2013-02-18 09:59:33 -0800 | [diff] [blame] | 41 | } |
| 42 | } |