Jonathan Hart | 23701d1 | 2014-04-03 10:45:48 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.flowprogrammer.web; |
Naoki Shiota | 2a35b44 | 2013-11-26 19:17:38 -0800 | [diff] [blame] | 2 | |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame] | 3 | import net.onrc.onos.core.util.Dpid; |
Naoki Shiota | 2a35b44 | 2013-11-26 19:17:38 -0800 | [diff] [blame] | 4 | |
Jonathan Hart | c78b8f6 | 2014-08-07 22:31:09 -0700 | [diff] [blame] | 5 | import org.projectfloodlight.openflow.util.HexString; |
Naoki Shiota | 2a35b44 | 2013-11-26 19:17:38 -0800 | [diff] [blame] | 6 | import org.restlet.resource.Get; |
| 7 | import org.slf4j.Logger; |
| 8 | import org.slf4j.LoggerFactory; |
| 9 | |
| 10 | /** |
| 11 | * FlowProgrammer REST API implementation: Suspend sending message to switch. |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 12 | * <p/> |
| 13 | * GET /wm/fprog/pusher/suspend/{dpid}/json" |
Naoki Shiota | 2a35b44 | 2013-11-26 19:17:38 -0800 | [diff] [blame] | 14 | */ |
| 15 | public class SuspendPusherResource extends PusherResource { |
| 16 | |
Ray Milkey | ec83894 | 2014-04-09 11:28:43 -0700 | [diff] [blame] | 17 | private static final Logger log = LoggerFactory.getLogger(SetPushRateResource.class); |
Naoki Shiota | 2a35b44 | 2013-11-26 19:17:38 -0800 | [diff] [blame] | 18 | |
| 19 | /** |
| 20 | * Implement the API. |
| 21 | * |
| 22 | * @return true if succeeded, false if failed. |
| 23 | */ |
| 24 | @Get("json") |
| 25 | public boolean retrieve() { |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 26 | if (!init()) { |
| 27 | return false; |
| 28 | } |
Naoki Shiota | 2a35b44 | 2013-11-26 19:17:38 -0800 | [diff] [blame] | 29 | |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 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 | |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame] | 38 | return pusher.suspend(new Dpid(dpid)); |
Naoki Shiota | 2a35b44 | 2013-11-26 19:17:38 -0800 | [diff] [blame] | 39 | } |
| 40 | } |