Hongtao Yin

update

added modify and teardown cases
worked with external app for UC1 demo

Change-Id: Ia4c71cb006ff9f9eb7b7ebd43753509e7ad0763b
...@@ -62,6 +62,32 @@ ...@@ -62,6 +62,32 @@
62 <groupId>org.osgi</groupId> 62 <groupId>org.osgi</groupId>
63 <artifactId>org.osgi.core</artifactId> 63 <artifactId>org.osgi.core</artifactId>
64 </dependency> 64 </dependency>
65 +
66 + <dependency>
67 + <groupId>org.onlab.onos</groupId>
68 + <artifactId>onlab-thirdparty</artifactId>
69 + </dependency>
70 +
71 + <dependency>
72 + <groupId>org.onlab.onos</groupId>
73 + <artifactId>onlab-misc</artifactId>
74 + </dependency>
75 +
76 + <dependency>
77 + <groupId>org.onlab.onos</groupId>
78 + <artifactId>onlab-junit</artifactId>
79 + <scope>test</scope>
80 + </dependency>
81 +
82 + <dependency>
83 + <groupId>org.onlab.onos</groupId>
84 + <artifactId>onos-cli</artifactId>
85 + <version>${project.version}</version>
86 + </dependency>
87 + <dependency>
88 + <groupId>org.apache.karaf.shell</groupId>
89 + <artifactId>org.apache.karaf.shell.console</artifactId>
90 + </dependency>
65 </dependencies> 91 </dependencies>
66 92
67 <build> 93 <build>
...@@ -77,6 +103,7 @@ ...@@ -77,6 +103,7 @@
77 ${project.groupId}.${project.artifactId} 103 ${project.groupId}.${project.artifactId}
78 </Bundle-SymbolicName> 104 </Bundle-SymbolicName>
79 <Import-Package> 105 <Import-Package>
106 + org.slf4j,
80 org.osgi.framework, 107 org.osgi.framework,
81 javax.ws.rs,javax.ws.rs.core, 108 javax.ws.rs,javax.ws.rs.core,
82 com.sun.jersey.api.core, 109 com.sun.jersey.api.core,
......
...@@ -16,43 +16,47 @@ ...@@ -16,43 +16,47 @@
16 package org.onlab.onos.calendar; 16 package org.onlab.onos.calendar;
17 17
18 import java.net.URI; 18 import java.net.URI;
19 - 19 +import org.onlab.onos.net.ConnectPoint;
20 +import org.onlab.onos.net.DeviceId;
21 +import org.onlab.onos.net.intent.IntentService;
22 +import org.onlab.rest.BaseResource;
20 import javax.ws.rs.POST; 23 import javax.ws.rs.POST;
21 -import javax.ws.rs.Path; 24 +import javax.ws.rs.DELETE;
22 import javax.ws.rs.PathParam; 25 import javax.ws.rs.PathParam;
23 import javax.ws.rs.core.Response; 26 import javax.ws.rs.core.Response;
24 -
25 import org.onlab.onos.core.ApplicationId; 27 import org.onlab.onos.core.ApplicationId;
26 import org.onlab.onos.core.CoreService; 28 import org.onlab.onos.core.CoreService;
27 -import org.onlab.onos.net.ConnectPoint;
28 -import org.onlab.onos.net.DeviceId;
29 import org.onlab.onos.net.flow.DefaultTrafficSelector; 29 import org.onlab.onos.net.flow.DefaultTrafficSelector;
30 import org.onlab.onos.net.flow.TrafficSelector; 30 import org.onlab.onos.net.flow.TrafficSelector;
31 import org.onlab.onos.net.flow.TrafficTreatment; 31 import org.onlab.onos.net.flow.TrafficTreatment;
32 -import org.onlab.onos.net.intent.Intent; 32 +import org.onlab.onos.net.intent.PointToPointIntent;
33 -import org.onlab.onos.net.intent.IntentService;
34 -import org.onlab.onos.net.intent.PointToPointIntentWithBandwidthConstraint;
35 -import org.onlab.onos.net.resource.BandwidthResourceRequest;
36 import org.onlab.packet.Ethernet; 33 import org.onlab.packet.Ethernet;
37 -import org.onlab.rest.BaseResource;
38 -
39 import static org.onlab.onos.net.PortNumber.portNumber; 34 import static org.onlab.onos.net.PortNumber.portNumber;
40 import static org.onlab.onos.net.flow.DefaultTrafficTreatment.builder; 35 import static org.onlab.onos.net.flow.DefaultTrafficTreatment.builder;
41 36
37 +import static org.slf4j.LoggerFactory.getLogger;
38 +import org.slf4j.Logger;
39 +
42 /** 40 /**
43 * Web resource for triggering calendared intents. 41 * Web resource for triggering calendared intents.
44 */ 42 */
45 -@Path("intent") 43 +@javax.ws.rs.Path("intent")
46 public class BandwidthCalendarResource extends BaseResource { 44 public class BandwidthCalendarResource extends BaseResource {
47 45
46 + private static final Logger log = getLogger(BandwidthCalendarResource.class);
47 +
48 + @javax.ws.rs.Path("/{src}/{dst}/{srcPort}/{dstPort}/{bandwidth}")
48 @POST 49 @POST
49 - @Path("{src}/{dst}/{srcPort}/{dstPort}/{bandwidth}")
50 public Response createIntent(@PathParam("src") String src, 50 public Response createIntent(@PathParam("src") String src,
51 @PathParam("dst") String dst, 51 @PathParam("dst") String dst,
52 @PathParam("srcPort") String srcPort, 52 @PathParam("srcPort") String srcPort,
53 @PathParam("dstPort") String dstPort, 53 @PathParam("dstPort") String dstPort,
54 @PathParam("bandwidth") String bandwidth) { 54 @PathParam("bandwidth") String bandwidth) {
55 - // TODO: implement calls to intent framework 55 +
56 + log.info("Receiving Create Intent request...");
57 + log.info("Path Constraints: Src = {} SrcPort = {} Dest = {} DestPort = {} BW = {}",
58 + src, srcPort, dst, dstPort, bandwidth);
59 +
56 IntentService service = get(IntentService.class); 60 IntentService service = get(IntentService.class);
57 61
58 ConnectPoint srcPoint = new ConnectPoint(deviceId(src), portNumber(srcPort)); 62 ConnectPoint srcPoint = new ConnectPoint(deviceId(src), portNumber(srcPort));
...@@ -61,13 +65,38 @@ public class BandwidthCalendarResource extends BaseResource { ...@@ -61,13 +65,38 @@ public class BandwidthCalendarResource extends BaseResource {
61 TrafficSelector selector = buildTrafficSelector(); 65 TrafficSelector selector = buildTrafficSelector();
62 TrafficTreatment treatment = builder().build(); 66 TrafficTreatment treatment = builder().build();
63 67
64 - Intent intent = new PointToPointIntentWithBandwidthConstraint( 68 + PointToPointIntent intentP2P =
65 - appId(), selector, treatment, 69 + new PointToPointIntent(appId(), selector, treatment,
66 - srcPoint, dstPoint, new BandwidthResourceRequest(Double.parseDouble(bandwidth))); 70 + srcPoint, dstPoint);
67 - service.submit(intent); 71 + service.submit(intentP2P);
72 + log.info("Submitted Calendar App intent: src = " + src + "dest = " + dst
73 + + "srcPort = " + srcPort + "destPort" + dstPort + "intentID = " + intentP2P.id().toString());
74 + String reply = intentP2P.id().toString() + "\n";
68 75
69 - return Response.ok("Yo! We got src=" + srcPoint + "; dst=" + dstPoint + 76 + return Response.ok(reply).build();
70 - "; bw=" + bandwidth + "; intent service " + service).build(); 77 + }
78 +
79 + @javax.ws.rs.Path("/cancellation/{intentId}")
80 + @DELETE
81 + public Response withdrawIntent(@PathParam("intentId") String intentId) {
82 +
83 + log.info("Receiving Teardown request...");
84 + log.info("Withdraw intentId = {} ", intentId);
85 +
86 + String reply = "ok\n";
87 + return Response.ok(reply).build();
88 + }
89 +
90 + @javax.ws.rs.Path("/modification/{intentId}/{bandwidth}")
91 + @POST
92 + public Response modifyBandwidth(@PathParam("intentId") String intentId,
93 + @PathParam("bandwidth") String bandwidth) {
94 +
95 + log.info("Receiving Modify request...");
96 + log.info("Modify bw for intentId = {} with new bandwidth = {}", intentId, bandwidth);
97 +
98 + String reply = "ok\n";
99 + return Response.ok(reply).build();
71 } 100 }
72 101
73 private TrafficSelector buildTrafficSelector() { 102 private TrafficSelector buildTrafficSelector() {
...@@ -86,5 +115,4 @@ public class BandwidthCalendarResource extends BaseResource { ...@@ -86,5 +115,4 @@ public class BandwidthCalendarResource extends BaseResource {
86 protected ApplicationId appId() { 115 protected ApplicationId appId() {
87 return get(CoreService.class).registerApplication("org.onlab.onos.calendar"); 116 return get(CoreService.class).registerApplication("org.onlab.onos.calendar");
88 } 117 }
89 -
90 } 118 }
......