Ray Milkey
Committed by Gerrit Code Review

[Falcon] Add REST APIs for the OLT app

Change-Id: If0be7113e26b4311cb0e7496e370158d6672f1c7
1 <?xml version="1.0" encoding="UTF-8"?> 1 <?xml version="1.0" encoding="UTF-8"?>
2 <!-- 2 <!--
3 - ~ Copyright 2014 Open Networking Laboratory 3 + ~ Copyright 2015 Open Networking Laboratory
4 ~ 4 ~
5 ~ Licensed under the Apache License, Version 2.0 (the "License"); 5 ~ Licensed under the Apache License, Version 2.0 (the "License");
6 ~ you may not use this file except in compliance with the License. 6 ~ you may not use this file except in compliance with the License.
...@@ -16,23 +16,29 @@ ...@@ -16,23 +16,29 @@
16 --> 16 -->
17 <project xmlns="http://maven.apache.org/POM/4.0.0" 17 <project xmlns="http://maven.apache.org/POM/4.0.0"
18 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 18 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19 - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 19 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
20 - <modelVersion>4.0.0</modelVersion>
21 -
22 <parent> 20 <parent>
23 <groupId>org.onosproject</groupId> 21 <groupId>org.onosproject</groupId>
24 <artifactId>onos-apps</artifactId> 22 <artifactId>onos-apps</artifactId>
25 <version>1.5.0-SNAPSHOT</version> 23 <version>1.5.0-SNAPSHOT</version>
26 <relativePath>../pom.xml</relativePath> 24 <relativePath>../pom.xml</relativePath>
27 </parent> 25 </parent>
26 + <modelVersion>4.0.0</modelVersion>
28 27
29 <artifactId>onos-app-olt</artifactId> 28 <artifactId>onos-app-olt</artifactId>
30 - <packaging>bundle</packaging>
31 29
32 - <description>OLT application</description> 30 + <packaging>bundle</packaging>
31 + <description>OLT application for CORD</description>
33 32
34 <properties> 33 <properties>
35 <onos.app.name>org.onosproject.olt</onos.app.name> 34 <onos.app.name>org.onosproject.olt</onos.app.name>
35 + <web.context>/onos/olt</web.context>
36 + <api.version>1.0.0</api.version>
37 + <api.title>ONOS OLT REST API</api.title>
38 + <api.description>
39 + APIs for interacting with the CORD OLT application.
40 + </api.description>
41 + <api.package>org.onosproject.olt</api.package>
36 </properties> 42 </properties>
37 43
38 <dependencies> 44 <dependencies>
...@@ -41,27 +47,90 @@ ...@@ -41,27 +47,90 @@
41 <artifactId>onos-cli</artifactId> 47 <artifactId>onos-cli</artifactId>
42 <version>${project.version}</version> 48 <version>${project.version}</version>
43 </dependency> 49 </dependency>
50 +
44 <dependency> 51 <dependency>
45 <groupId>org.apache.karaf.shell</groupId> 52 <groupId>org.apache.karaf.shell</groupId>
46 <artifactId>org.apache.karaf.shell.console</artifactId> 53 <artifactId>org.apache.karaf.shell.console</artifactId>
47 </dependency> 54 </dependency>
48 - <dependency>
49 - <groupId>com.google.guava</groupId>
50 - <artifactId>guava</artifactId>
51 - </dependency>
52 - <dependency>
53 - <groupId>org.onosproject</groupId>
54 - <artifactId>onlab-misc</artifactId>
55 - </dependency>
56 <dependency> 55 <dependency>
57 - <groupId>org.apache.felix</groupId> 56 + <groupId>org.onosproject</groupId>
58 - <artifactId>org.apache.felix.scr</artifactId> 57 + <artifactId>onos-rest</artifactId>
59 - <version>1.8.2</version> 58 + <version>${project.version}</version>
60 </dependency> 59 </dependency>
61 <dependency> 60 <dependency>
61 + <groupId>org.onosproject</groupId>
62 + <artifactId>onlab-rest</artifactId>
63 + <version>${project.version}</version>
64 + </dependency>
65 + <dependency>
66 + <groupId>javax.ws.rs</groupId>
67 + <artifactId>jsr311-api</artifactId>
68 + <version>1.1.1</version>
69 + </dependency>
70 + <dependency>
71 + <groupId>com.sun.jersey</groupId>
72 + <artifactId>jersey-servlet</artifactId>
73 + </dependency>
74 + <dependency>
75 + <groupId>com.fasterxml.jackson.core</groupId>
76 + <artifactId>jackson-databind</artifactId>
77 + </dependency>
78 +
79 + <dependency>
80 + <groupId>com.fasterxml.jackson.core</groupId>
81 + <artifactId>jackson-annotations</artifactId>
82 + </dependency>
83 +
84 + <dependency>
62 <groupId>org.osgi</groupId> 85 <groupId>org.osgi</groupId>
63 <artifactId>org.osgi.compendium</artifactId> 86 <artifactId>org.osgi.compendium</artifactId>
64 - <version>5.0.0</version> 87 + </dependency>
88 + <dependency>
89 + <groupId>org.osgi</groupId>
90 + <artifactId>org.osgi.core</artifactId>
65 </dependency> 91 </dependency>
66 </dependencies> 92 </dependencies>
93 +
94 + <build>
95 + <plugins>
96 + <plugin>
97 + <groupId>org.apache.felix</groupId>
98 + <artifactId>maven-bundle-plugin</artifactId>
99 + <extensions>true</extensions>
100 + <configuration>
101 + <instructions>
102 + <_wab>src/main/webapp/</_wab>
103 + <Include-Resource>
104 + WEB-INF/classes/apidoc/swagger.json=target/swagger.json,
105 + {maven-resources}
106 + </Include-Resource>
107 + <Bundle-SymbolicName>
108 + ${project.groupId}.${project.artifactId}
109 + </Bundle-SymbolicName>
110 + <Import-Package>
111 + org.slf4j,
112 + org.osgi.framework,
113 + org.osgi.service.*,
114 + javax.ws.rs,
115 + javax.ws.rs.core,
116 + com.sun.jersey.api.core,
117 + com.sun.jersey.spi.container.servlet,
118 + com.sun.jersey.server.impl.container.servlet,
119 + com.fasterxml.jackson.databind,
120 + com.fasterxml.jackson.databind.node,
121 + org.apache.karaf.shell.commands,
122 + org.apache.commons.lang.math.*,
123 + com.google.common.*,
124 + org.onlab.packet.*,
125 + org.onlab.rest.*,
126 + org.onosproject.*,
127 + org.onlab.util.*,
128 + org.jboss.netty.util.*
129 + </Import-Package>
130 + <Web-ContextPath>${web.context}</Web-ContextPath>
131 + </instructions>
132 + </configuration>
133 + </plugin>
134 + </plugins>
135 + </build>
67 </project> 136 </project>
......
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.olt.rest;
17 +
18 +import javax.ws.rs.DELETE;
19 +import javax.ws.rs.POST;
20 +import javax.ws.rs.Path;
21 +import javax.ws.rs.PathParam;
22 +import javax.ws.rs.Produces;
23 +import javax.ws.rs.core.MediaType;
24 +import javax.ws.rs.core.Response;
25 +
26 +import org.onlab.packet.VlanId;
27 +import org.onosproject.net.ConnectPoint;
28 +import org.onosproject.net.DeviceId;
29 +import org.onosproject.net.PortNumber;
30 +import org.onosproject.olt.AccessDeviceService;
31 +import org.onosproject.rest.AbstractWebResource;
32 +
33 +/**
34 + * OLT REST APIs.
35 + */
36 +
37 +@Path("oltapp")
38 +public class OltWebResource extends AbstractWebResource {
39 +
40 + /**
41 + * Provision a subscriber.
42 + *
43 + * @return 200 OK
44 + */
45 + @POST
46 + @Produces(MediaType.APPLICATION_JSON)
47 + @Path("{device}/{port}/{vlan}")
48 + public Response provisionSubscriber(
49 + @PathParam("device")String device,
50 + @PathParam("port")long port,
51 + @PathParam("vlan")short vlan) {
52 + AccessDeviceService service = get(AccessDeviceService.class);
53 + DeviceId deviceId = DeviceId.deviceId(device);
54 + PortNumber portNumber = PortNumber.portNumber(port);
55 + VlanId vlanId = VlanId.vlanId(vlan);
56 + ConnectPoint connectPoint = new ConnectPoint(deviceId, portNumber);
57 + service.provisionSubscriber(connectPoint, vlanId);
58 + return ok("").build();
59 + }
60 +
61 + /**
62 + * Remove the provisioning for a subscriber.
63 + */
64 + @DELETE
65 + @Produces(MediaType.APPLICATION_JSON)
66 + @Path("{device}/{port}")
67 + public Response removeSubscriber(
68 + @PathParam("device")String device,
69 + @PathParam("port")long port) {
70 + AccessDeviceService service = get(AccessDeviceService.class);
71 + DeviceId deviceId = DeviceId.deviceId(device);
72 + PortNumber portNumber = PortNumber.portNumber(port);
73 + ConnectPoint connectPoint = new ConnectPoint(deviceId, portNumber);
74 + service.removeSubscriber(connectPoint);
75 + return ok("").build();
76 + }
77 +}
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +/**
18 + * REST APIs for the OLT application.
19 + */
20 +package org.onosproject.olt.rest;
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<!--
3 + ~ Copyright 2015 Open Networking Laboratory
4 + ~
5 + ~ Licensed under the Apache License, Version 2.0 (the "License");
6 + ~ you may not use this file except in compliance with the License.
7 + ~ You may obtain a copy of the License at
8 + ~
9 + ~ http://www.apache.org/licenses/LICENSE-2.0
10 + ~
11 + ~ Unless required by applicable law or agreed to in writing, software
12 + ~ distributed under the License is distributed on an "AS IS" BASIS,
13 + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 + ~ See the License for the specific language governing permissions and
15 + ~ limitations under the License.
16 + -->
17 +<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
18 + xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
19 + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
20 + id="ONOS" version="2.5">
21 + <display-name>OLT REST API v1.0</display-name>
22 +
23 + <servlet>
24 + <servlet-name>JAX-RS Service</servlet-name>
25 + <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
26 + <init-param>
27 + <param-name>com.sun.jersey.config.property.resourceConfigClass</param-name>
28 + <param-value>com.sun.jersey.api.core.ClassNamesResourceConfig</param-value>
29 + </init-param>
30 + <init-param>
31 + <param-name>com.sun.jersey.config.property.classnames</param-name>
32 + <param-value>
33 + org.onosproject.olt.rest.OltWebResource
34 + </param-value>
35 + </init-param>
36 + <load-on-startup>1</load-on-startup>
37 + </servlet>
38 +
39 + <servlet-mapping>
40 + <servlet-name>JAX-RS Service</servlet-name>
41 + <url-pattern>/*</url-pattern>
42 + </servlet-mapping>
43 +</web-app>