blob: 39d245bdd8bcb8fdc0379a9fafb931ad3ddc07d6 [file] [log] [blame]
Naoki Shiota2a35b442013-11-26 19:17:38 -08001package net.onrc.onos.ofcontroller.flowprogrammer.web;
2
3import net.floodlightcontroller.core.IOFSwitch;
4
5import org.openflow.util.HexString;
6import org.restlet.resource.Get;
7import org.slf4j.Logger;
8import org.slf4j.LoggerFactory;
9
10/**
11 * FlowProgrammer REST API implementation: Suspend sending message to switch.
12 *
13 * GET /wm/fprog/suspend/{dpid}/json"
14 */
15public class SuspendPusherResource extends PusherResource {
16
17 protected final static Logger log = LoggerFactory.getLogger(SetPushRateResource.class);
18
19 /**
20 * Implement the API.
21 *
22 * @return true if succeeded, false if failed.
23 */
24 @Get("json")
25 public boolean retrieve() {
26 if (! init()) {
27 return false;
28 }
29
30 long dpid;
31 try {
32 dpid = HexString.toLong((String)getRequestAttributes().get("dpid"));
33 } catch (NumberFormatException e) {
34 log.error("Invalid number format");
35 return false;
36 }
37
38 IOFSwitch sw = provider.getSwitches().get(dpid);
39 if (sw == null) {
40 log.error("Invalid dpid");
41 return false;
42 }
43
44 return pusher.suspend(sw);
45 }
46}