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 | |
| 3 | import net.floodlightcontroller.core.IOFSwitch; |
| 4 | |
| 5 | import org.openflow.util.HexString; |
| 6 | import org.restlet.resource.Get; |
| 7 | |
| 8 | /** |
| 9 | * FlowProgrammer REST API implementation: Resume sending message to switch. |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 10 | * <p/> |
| 11 | * GET /wm/fprog/pusher/resume/{dpid}/json" |
Naoki Shiota | 2a35b44 | 2013-11-26 19:17:38 -0800 | [diff] [blame] | 12 | */ |
| 13 | public class ResumePusherResource extends PusherResource { |
| 14 | /** |
| 15 | * Implement the API. |
| 16 | * |
| 17 | * @return true if succeeded, false if failed. |
| 18 | */ |
| 19 | @Get("json") |
| 20 | public boolean retrieve() { |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 21 | if (!init()) { |
| 22 | return false; |
| 23 | } |
Naoki Shiota | 2a35b44 | 2013-11-26 19:17:38 -0800 | [diff] [blame] | 24 | |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 25 | long dpid; |
| 26 | try { |
| 27 | dpid = HexString.toLong((String) getRequestAttributes().get("dpid")); |
| 28 | } catch (NumberFormatException e) { |
| 29 | log.error("Invalid number format"); |
| 30 | return false; |
| 31 | } |
| 32 | |
| 33 | IOFSwitch sw = provider.getSwitches().get(dpid); |
| 34 | if (sw == null) { |
| 35 | log.error("Invalid dpid"); |
| 36 | return false; |
| 37 | } |
| 38 | |
| 39 | return pusher.resume(sw); |
Naoki Shiota | 2a35b44 | 2013-11-26 19:17:38 -0800 | [diff] [blame] | 40 | } |
| 41 | } |