blob: 9c348ff6c7cf6e2e42fd2428695cc04457a8d5b4 [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.protocol.OFBarrierReply;
6import org.openflow.util.HexString;
7import org.restlet.resource.Get;
8
9/**
10 * FlowProgrammer REST API implementation: Send barrier message to switch.
11 *
12 * GET /wm/fprog/barrier/{dpid}/json"
13 */
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() {
22 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 }
32
33 IOFSwitch sw = provider.getSwitches().get(dpid);
34 if (sw == null) {
35 log.error("Invalid dpid");
36 return null;
37 }
38
39 return pusher.barrier(sw);
40 }
41}