blob: 537167bec818a8af7ef2f01603ee9576b110e6c0 [file] [log] [blame]
Jonathan Hart23701d12014-04-03 10:45:48 -07001package net.onrc.onos.core.flowprogrammer.web;
Naoki Shiota7b2ab4a2013-12-04 18:05:39 -08002
3import net.floodlightcontroller.core.IOFSwitch;
4
Jonathan Hartc78b8f62014-08-07 22:31:09 -07005import org.projectfloodlight.openflow.util.HexString;
Naoki Shiota7b2ab4a2013-12-04 18:05:39 -08006import org.restlet.resource.Get;
7
8/**
9 * FlowProgrammer REST API implementation: Interrupt synchronization to a switch.
Ray Milkey8e5170e2014-04-02 12:09:55 -070010 * <p/>
11 * GET /wm/fprog/synchronizer/interrupt/{dpid}/json"
Naoki Shiota7b2ab4a2013-12-04 18:05:39 -080012 */
13public class DoInterruptResource extends SynchronizerResource {
14
15 /**
16 * Implement the API.
17 *
18 * @return true if succeeded, false if failed.
19 */
20 @Get("json")
21 public boolean retrieve() {
Ray Milkey8e5170e2014-04-02 12:09:55 -070022 if (!init()) {
23 return false;
24 }
Naoki Shiota7b2ab4a2013-12-04 18:05:39 -080025
Ray Milkey8e5170e2014-04-02 12:09:55 -070026 long dpid;
27 try {
28 dpid = HexString.toLong((String) getRequestAttributes().get("dpid"));
29 } catch (NumberFormatException e) {
30 log.error("Invalid number format");
31 return false;
32 }
33
34 IOFSwitch sw = provider.getSwitches().get(dpid);
35 if (sw == null) {
36 log.error("Invalid dpid");
37 return false;
38 }
39
40 synchronizer.interrupt(sw);
41
42 return true;
Naoki Shiota7b2ab4a2013-12-04 18:05:39 -080043 }
44}