Thomas Vachuska | 140d585 | 2014-10-16 12:17:45 -0700 | [diff] [blame^] | 1 | package org.onlab.onos.calendar; |
| 2 | |
| 3 | import org.onlab.onos.net.ConnectPoint; |
| 4 | import org.onlab.onos.net.DeviceId; |
| 5 | import org.onlab.onos.net.intent.IntentService; |
| 6 | import org.onlab.rest.BaseResource; |
| 7 | |
| 8 | import javax.ws.rs.POST; |
| 9 | import javax.ws.rs.Path; |
| 10 | import javax.ws.rs.PathParam; |
| 11 | import javax.ws.rs.core.Response; |
| 12 | import java.net.URI; |
| 13 | |
| 14 | import static org.onlab.onos.net.PortNumber.portNumber; |
| 15 | |
| 16 | /** |
| 17 | * Web resource for triggering calendared intents. |
| 18 | */ |
| 19 | @Path("intent") |
| 20 | public class BandwidthCalendarResource extends BaseResource { |
| 21 | |
| 22 | @POST |
| 23 | @Path("{src}/{dst}/{srcPort}/{dstPort}/{bandwidth}") |
| 24 | public Response createIntent(@PathParam("src") String src, |
| 25 | @PathParam("dst") String dst, |
| 26 | @PathParam("srcPort") String srcPort, |
| 27 | @PathParam("dstPort") String dstPort, |
| 28 | @PathParam("bandwidth") String bandwidth) { |
| 29 | // TODO: implement calls to intent framework |
| 30 | IntentService service = get(IntentService.class); |
| 31 | |
| 32 | ConnectPoint srcPoint = new ConnectPoint(deviceId(src), portNumber(srcPort)); |
| 33 | ConnectPoint dstPoint = new ConnectPoint(deviceId(dst), portNumber(dstPort)); |
| 34 | |
| 35 | return Response.ok("Yo! We got src=" + srcPoint + "; dst=" + dstPoint + |
| 36 | "; bw=" + bandwidth + "; intent service " + service).build(); |
| 37 | } |
| 38 | |
| 39 | private DeviceId deviceId(String dpid) { |
| 40 | return DeviceId.deviceId(URI.create("of:" + dpid)); |
| 41 | } |
| 42 | |
| 43 | } |