blob: d01e25961ef00141ef8d9fa42453a822753220ff [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.
Ray Milkey8e5170e2014-04-02 12:09:55 -070012 * <p/>
13 * GET /wm/fprog/pusher/suspend/{dpid}/json"
Naoki Shiota2a35b442013-11-26 19:17:38 -080014 */
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() {
Ray Milkey8e5170e2014-04-02 12:09:55 -070026 if (!init()) {
27 return false;
28 }
Naoki Shiota2a35b442013-11-26 19:17:38 -080029
Ray Milkey8e5170e2014-04-02 12:09:55 -070030 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);
Naoki Shiota2a35b442013-11-26 19:17:38 -080045 }
46}