blob: f97ea9c9712e9ef5ed4b0e74c00eb36632806b21 [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
Brian O'Connorc67f9fa2014-08-07 18:17:46 -07005import org.projectfloodlight.openflow.protocol.OFBarrierReply;
Jonathan Hartc78b8f62014-08-07 22:31:09 -07006import org.projectfloodlight.openflow.util.HexString;
Naoki Shiota2a35b442013-11-26 19:17:38 -08007import org.restlet.resource.Get;
8
9/**
10 * FlowProgrammer REST API implementation: Send barrier message to switch.
Ray Milkey8e5170e2014-04-02 12:09:55 -070011 * <p/>
12 * GET /wm/fprog/pusher/barrier/{dpid}/json"
Naoki Shiota2a35b442013-11-26 19:17:38 -080013 */
14public class SendBarrierResource extends PusherResource {
15 /**
16 * Implement the API.
17 *
18 * @return true if succeeded, false if failed.
19 */
20 @Get("json")
21 public OFBarrierReply retrieve() {
Ray Milkey8e5170e2014-04-02 12:09:55 -070022 if (!init()) {
23 return null;
24 }
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 null;
31 }
Naoki Shiota2a35b442013-11-26 19:17:38 -080032
Jonathan Hart5302b6c2014-08-13 15:57:59 -070033 return pusher.barrier(new Dpid(dpid));
Naoki Shiota2a35b442013-11-26 19:17:38 -080034 }
35}