Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 1 | package net.floodlightcontroller.staticflowentry.web; |
| 2 | |
| 3 | import net.floodlightcontroller.core.web.ControllerSwitchesResource; |
| 4 | import net.floodlightcontroller.staticflowentry.IStaticFlowEntryPusherService; |
| 5 | |
| 6 | import org.openflow.util.HexString; |
| 7 | import org.restlet.data.Status; |
| 8 | import org.restlet.resource.Get; |
| 9 | import org.restlet.resource.ServerResource; |
| 10 | import org.slf4j.Logger; |
| 11 | import org.slf4j.LoggerFactory; |
| 12 | |
| 13 | public class ClearStaticFlowEntriesResource extends ServerResource { |
Yuta HIGUCHI | 6ac8d18 | 2013-10-22 15:24:56 -0700 | [diff] [blame] | 14 | protected final static Logger log = LoggerFactory.getLogger(ClearStaticFlowEntriesResource.class); |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 15 | |
| 16 | @Get |
| 17 | public void ClearStaticFlowEntries() { |
| 18 | IStaticFlowEntryPusherService sfpService = |
| 19 | (IStaticFlowEntryPusherService)getContext().getAttributes(). |
| 20 | get(IStaticFlowEntryPusherService.class.getCanonicalName()); |
| 21 | |
| 22 | String param = (String) getRequestAttributes().get("switch"); |
| 23 | if (log.isDebugEnabled()) |
| 24 | log.debug("Clearing all static flow entires for switch: " + param); |
| 25 | |
| 26 | if (param.toLowerCase().equals("all")) { |
| 27 | sfpService.deleteAllFlows(); |
| 28 | } else { |
| 29 | try { |
| 30 | sfpService.deleteFlowsForSwitch(HexString.toLong(param)); |
| 31 | } catch (NumberFormatException e){ |
| 32 | setStatus(Status.CLIENT_ERROR_BAD_REQUEST, |
| 33 | ControllerSwitchesResource.DPID_ERROR); |
| 34 | return; |
| 35 | } |
| 36 | } |
| 37 | } |
| 38 | } |