blob: f103e9919b793374457af032b28ca4c1507427fe [file] [log] [blame]
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -08001package net.floodlightcontroller.staticflowentry.web;
2
3import net.floodlightcontroller.core.web.ControllerSwitchesResource;
4import net.floodlightcontroller.staticflowentry.IStaticFlowEntryPusherService;
5
6import org.openflow.util.HexString;
7import org.restlet.data.Status;
8import org.restlet.resource.Get;
9import org.restlet.resource.ServerResource;
10import org.slf4j.Logger;
11import org.slf4j.LoggerFactory;
12
13public class ClearStaticFlowEntriesResource extends ServerResource {
Yuta HIGUCHI6ac8d182013-10-22 15:24:56 -070014 protected final static Logger log = LoggerFactory.getLogger(ClearStaticFlowEntriesResource.class);
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080015
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}