blob: c1d826afae9bd070897098fee9eba7f67e63177b [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 {
14 protected static Logger log = LoggerFactory.getLogger(ClearStaticFlowEntriesResource.class);
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}