blob: 0d53c9a5f42afc38e10cf74d69260aa17087f85f [file] [log] [blame]
Jonathan Hart23701d12014-04-03 10:45:48 -07001package net.onrc.onos.core.flowprogrammer.web;
Naoki Shiota2a35b442013-11-26 19:17:38 -08002
Jonathan Hart5302b6c2014-08-13 15:57:59 -07003import net.onrc.onos.core.util.Dpid;
Naoki Shiota2a35b442013-11-26 19:17:38 -08004
Jonathan Hartc78b8f62014-08-07 22:31:09 -07005import org.projectfloodlight.openflow.util.HexString;
Naoki Shiota2a35b442013-11-26 19:17:38 -08006import 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
Ray Milkeyec838942014-04-09 11:28:43 -070017 private static final Logger log = LoggerFactory.getLogger(SetPushRateResource.class);
Naoki Shiota2a35b442013-11-26 19:17:38 -080018
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
Jonathan Hart5302b6c2014-08-13 15:57:59 -070038 return pusher.suspend(new Dpid(dpid));
Naoki Shiota2a35b442013-11-26 19:17:38 -080039 }
40}