Moved demo app back to main onos repo.
Change-Id: I3e445b28c1a19f9af9b582a05f3f6403af6d19c2
Showing
9 changed files
with
335 additions
and
7 deletions
apps/test/demo/app.xml
0 → 100644
| 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 | +<app name="org.onosproject.demo" origin="ON.Lab" version="1.2.0" | ||
| 18 | + features="onos-app-demo"> | ||
| 19 | + <description>Flow throughput test application</description> | ||
| 20 | +</app> |
apps/test/demo/pom.xml
0 → 100644
| 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 | +<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| 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"> | ||
| 20 | + <modelVersion>4.0.0</modelVersion> | ||
| 21 | + | ||
| 22 | + <parent> | ||
| 23 | + <groupId>org.onosproject</groupId> | ||
| 24 | + <artifactId>onos-apps-test</artifactId> | ||
| 25 | + <version>1.2.0-SNAPSHOT</version> | ||
| 26 | + <relativePath>../pom.xml</relativePath> | ||
| 27 | + </parent> | ||
| 28 | + | ||
| 29 | + <artifactId>onos-app-demo</artifactId> | ||
| 30 | + <packaging>bundle</packaging> | ||
| 31 | + | ||
| 32 | + <description>ONOS demo app bundle</description> | ||
| 33 | + | ||
| 34 | + <properties> | ||
| 35 | + <web.context>/onos/demo</web.context> | ||
| 36 | + </properties> | ||
| 37 | + | ||
| 38 | + <dependencies> | ||
| 39 | + <dependency> | ||
| 40 | + <groupId>org.osgi</groupId> | ||
| 41 | + <artifactId>org.osgi.compendium</artifactId> | ||
| 42 | + </dependency> | ||
| 43 | + <dependency> | ||
| 44 | + <groupId>org.onosproject</groupId> | ||
| 45 | + <artifactId>onlab-rest</artifactId> | ||
| 46 | + <version>${project.version}</version> | ||
| 47 | + </dependency> | ||
| 48 | + | ||
| 49 | + <dependency> | ||
| 50 | + <groupId>org.onosproject</groupId> | ||
| 51 | + <artifactId>onos-rest</artifactId> | ||
| 52 | + <version>${project.version}</version> | ||
| 53 | + </dependency> | ||
| 54 | + | ||
| 55 | + <dependency> | ||
| 56 | + <groupId>com.sun.jersey</groupId> | ||
| 57 | + <artifactId>jersey-servlet</artifactId> | ||
| 58 | + </dependency> | ||
| 59 | + <dependency> | ||
| 60 | + <groupId>com.fasterxml.jackson.core</groupId> | ||
| 61 | + <artifactId>jackson-databind</artifactId> | ||
| 62 | + </dependency> | ||
| 63 | + | ||
| 64 | + <dependency> | ||
| 65 | + <groupId>com.fasterxml.jackson.core</groupId> | ||
| 66 | + <artifactId>jackson-annotations</artifactId> | ||
| 67 | + </dependency> | ||
| 68 | + | ||
| 69 | + <dependency> | ||
| 70 | + <groupId>org.osgi</groupId> | ||
| 71 | + <artifactId>org.osgi.core</artifactId> | ||
| 72 | + </dependency> | ||
| 73 | + </dependencies> | ||
| 74 | + | ||
| 75 | + <build> | ||
| 76 | + <plugins> | ||
| 77 | + <plugin> | ||
| 78 | + <groupId>org.apache.felix</groupId> | ||
| 79 | + <artifactId>maven-bundle-plugin</artifactId> | ||
| 80 | + <extensions>true</extensions> | ||
| 81 | + <configuration> | ||
| 82 | + <instructions> | ||
| 83 | + <_wab>src/main/webapp/</_wab> | ||
| 84 | + <Bundle-SymbolicName> | ||
| 85 | + ${project.groupId}.${project.artifactId} | ||
| 86 | + </Bundle-SymbolicName> | ||
| 87 | + <Import-Package> | ||
| 88 | + org.slf4j, | ||
| 89 | + org.osgi.framework, | ||
| 90 | + javax.ws.rs,javax.ws.rs.core, | ||
| 91 | + com.sun.jersey.api.core, | ||
| 92 | + com.sun.jersey.spi.container.servlet, | ||
| 93 | + com.sun.jersey.server.impl.container.servlet, | ||
| 94 | + com.fasterxml.jackson.databind, | ||
| 95 | + com.fasterxml.jackson.databind.node, | ||
| 96 | + org.apache.commons.lang.math.*, | ||
| 97 | + com.google.common.*, | ||
| 98 | + org.onlab.packet.*, | ||
| 99 | + org.onlab.rest.*, | ||
| 100 | + org.onosproject.*, | ||
| 101 | + org.onlab.util.*, | ||
| 102 | + org.jboss.netty.util.* | ||
| 103 | + </Import-Package> | ||
| 104 | + <Web-ContextPath>${web.context}</Web-ContextPath> | ||
| 105 | + </instructions> | ||
| 106 | + </configuration> | ||
| 107 | + </plugin> | ||
| 108 | + </plugins> | ||
| 109 | + </build> | ||
| 110 | + | ||
| 111 | +</project> |
| 1 | +/* | ||
| 2 | + * Copyright 2014 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.demo; | ||
| 17 | + | ||
| 18 | +import com.fasterxml.jackson.databind.JsonNode; | ||
| 19 | + | ||
| 20 | +import java.util.Optional; | ||
| 21 | + | ||
| 22 | +/** | ||
| 23 | + * Simple demo api interface. | ||
| 24 | + */ | ||
| 25 | +public interface DemoAPI { | ||
| 26 | + | ||
| 27 | + enum InstallType { MESH, RANDOM }; | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * Tests flow subsystem based on the parameters supplied. | ||
| 31 | + * | ||
| 32 | + * @param params the test parameters | ||
| 33 | + * @return JSON representation | ||
| 34 | + */ | ||
| 35 | + JsonNode flowTest(Optional<JsonNode> params); | ||
| 36 | + | ||
| 37 | + /** | ||
| 38 | + * Installs intents based on the installation type. | ||
| 39 | + * @param type the installation type. | ||
| 40 | + * @param runParams run params | ||
| 41 | + */ | ||
| 42 | + void setup(InstallType type, Optional<JsonNode> runParams); | ||
| 43 | + | ||
| 44 | + /** | ||
| 45 | + * Uninstalls all existing intents. | ||
| 46 | + */ | ||
| 47 | + void tearDown(); | ||
| 48 | + | ||
| 49 | +} |
This diff is collapsed. Click to expand it.
| 1 | +/* | ||
| 2 | + * Copyright 2014 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.demo; | ||
| 17 | + | ||
| 18 | +import com.fasterxml.jackson.databind.JsonNode; | ||
| 19 | +import com.fasterxml.jackson.databind.ObjectMapper; | ||
| 20 | +import org.onlab.rest.BaseResource; | ||
| 21 | + | ||
| 22 | +import javax.ws.rs.Consumes; | ||
| 23 | +import javax.ws.rs.GET; | ||
| 24 | +import javax.ws.rs.POST; | ||
| 25 | +import javax.ws.rs.Path; | ||
| 26 | +import javax.ws.rs.Produces; | ||
| 27 | +import javax.ws.rs.core.MediaType; | ||
| 28 | +import javax.ws.rs.core.Response; | ||
| 29 | +import java.io.IOException; | ||
| 30 | +import java.io.InputStream; | ||
| 31 | +import java.util.Optional; | ||
| 32 | + | ||
| 33 | +/** | ||
| 34 | + * Rest API for demos. | ||
| 35 | + */ | ||
| 36 | +@Path("intents") | ||
| 37 | +public class DemoResource extends BaseResource { | ||
| 38 | + | ||
| 39 | + | ||
| 40 | + | ||
| 41 | + @POST | ||
| 42 | + @Path("flowTest") | ||
| 43 | + @Consumes(MediaType.APPLICATION_JSON) | ||
| 44 | + @Produces(MediaType.APPLICATION_JSON) | ||
| 45 | + public Response flowTest(InputStream input) throws IOException { | ||
| 46 | + ObjectMapper mapper = new ObjectMapper(); | ||
| 47 | + JsonNode cfg = mapper.readTree(input); | ||
| 48 | + DemoAPI demo = get(DemoAPI.class); | ||
| 49 | + return Response.ok(demo.flowTest(Optional.ofNullable(cfg)).toString()).build(); | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + @POST | ||
| 53 | + @Path("setup") | ||
| 54 | + @Consumes(MediaType.APPLICATION_JSON) | ||
| 55 | + @Produces(MediaType.APPLICATION_JSON) | ||
| 56 | + public Response setup(InputStream input) throws IOException { | ||
| 57 | + ObjectMapper mapper = new ObjectMapper(); | ||
| 58 | + JsonNode cfg = mapper.readTree(input); | ||
| 59 | + if (!cfg.has("type")) { | ||
| 60 | + return Response.status(Response.Status.BAD_REQUEST) | ||
| 61 | + .entity("Expected type field containing either mesh or random.").build(); | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + | ||
| 65 | + DemoAPI.InstallType type = DemoAPI.InstallType.valueOf( | ||
| 66 | + cfg.get("type").asText().toUpperCase()); | ||
| 67 | + DemoAPI demo = get(DemoAPI.class); | ||
| 68 | + demo.setup(type, Optional.ofNullable(cfg.get("runParams"))); | ||
| 69 | + | ||
| 70 | + return Response.ok(mapper.createObjectNode().toString()).build(); | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + @GET | ||
| 74 | + @Path("teardown") | ||
| 75 | + @Produces(MediaType.APPLICATION_JSON) | ||
| 76 | + public Response tearDown() throws IOException { | ||
| 77 | + ObjectMapper mapper = new ObjectMapper(); | ||
| 78 | + DemoAPI demo = get(DemoAPI.class); | ||
| 79 | + demo.tearDown(); | ||
| 80 | + return Response.ok(mapper.createObjectNode().toString()).build(); | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | +} |
| 1 | +/* | ||
| 2 | + * Copyright 2014 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 | + * Demo applications live here. | ||
| 19 | + */ | ||
| 20 | +package org.onosproject.demo; |
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | +<!-- | ||
| 3 | + ~ Copyright 2014 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>ONOS DEMO APP 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.demo.DemoResource | ||
| 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 | + | ||
| 44 | +</web-app> |
| ... | @@ -241,6 +241,13 @@ | ... | @@ -241,6 +241,13 @@ |
| 241 | <bundle>mvn:org.onosproject/onos-app-election/@ONOS-VERSION</bundle> | 241 | <bundle>mvn:org.onosproject/onos-app-election/@ONOS-VERSION</bundle> |
| 242 | </feature> | 242 | </feature> |
| 243 | 243 | ||
| 244 | + <feature name="onos-app-demo" version="@FEATURE-VERSION" | ||
| 245 | + description="ONOS demo applications"> | ||
| 246 | + <feature>onos-api</feature> | ||
| 247 | + <bundle>mvn:org.onosproject/onlab-misc/@ONOS-VERSION</bundle> | ||
| 248 | + <bundle>mvn:org.onosproject/onos-app-demo/@ONOS-VERSION</bundle> | ||
| 249 | + </feature> | ||
| 250 | + | ||
| 244 | 251 | ||
| 245 | <!-- ONOS sample app features: to be moved to a different repo --> | 252 | <!-- ONOS sample app features: to be moved to a different repo --> |
| 246 | 253 | ||
| ... | @@ -258,13 +265,6 @@ | ... | @@ -258,13 +265,6 @@ |
| 258 | <bundle>mvn:org.onosproject/onos-app-ifwd/@ONOS-VERSION</bundle> | 265 | <bundle>mvn:org.onosproject/onos-app-ifwd/@ONOS-VERSION</bundle> |
| 259 | </feature> | 266 | </feature> |
| 260 | 267 | ||
| 261 | - <feature name="onos-app-demo" version="@FEATURE-VERSION" | ||
| 262 | - description="ONOS demo applications"> | ||
| 263 | - <feature>onos-api</feature> | ||
| 264 | - <bundle>mvn:org.onosproject/onlab-misc/@ONOS-VERSION</bundle> | ||
| 265 | - <bundle>mvn:org.onosproject/onos-app-demo/@ONOS-VERSION</bundle> | ||
| 266 | - </feature> | ||
| 267 | - | ||
| 268 | <feature name="onos-app-database-perf" version="@FEATURE-VERSION" | 268 | <feature name="onos-app-database-perf" version="@FEATURE-VERSION" |
| 269 | description="ONOS partitioned database perf application"> | 269 | description="ONOS partitioned database perf application"> |
| 270 | <feature>onos-api</feature> | 270 | <feature>onos-api</feature> | ... | ... |
-
Please register or login to post a comment