REST API support added for t3-troubleshoot-simple
Change-Id: I1f31b48fb866e0a61e66b61ad2e6a30b5eddb04c
diff --git a/apps/t3/BUCK b/apps/t3/BUCK
index bb18951..c06bf7c 100644
--- a/apps/t3/BUCK
+++ b/apps/t3/BUCK
@@ -1,37 +1,19 @@
-COMPILE_DEPS = [
- '//lib:CORE_DEPS',
- '//lib:KRYO',
- '//core/store/serializers:onos-core-serializers',
- '//core/store/primitives:onos-core-primitives',
- '//core/api:onos-api',
- '//lib:org.apache.karaf.shell.console',
- '//cli:onos-cli',
- '//drivers/default:onos-drivers-default',
- '//apps/segmentrouting/app:onos-apps-segmentrouting-app',
- '//apps/route-service/api:onos-apps-route-service-api',
- '//apps/mcast/api:onos-apps-mcast-api',
+BUNDLES = [
+ '//apps/t3/web:onos-apps-t3-web',
+ '//apps/t3/app:onos-apps-t3-app',
]
-TEST_DEPS = [
- '//lib:TEST_ADAPTERS',
- '//utils/misc:onlab-misc',
- '//apps/route-service/api:onos-apps-route-service-api-tests',
-]
-
-osgi_jar_with_tests (
- deps = COMPILE_DEPS,
- test_deps = TEST_DEPS,
-)
-
onos_app (
- title = 'Trellis Troubleshooting Toolkit',
- category = 'Utilities',
- url = 'https://wiki.opencord.org/pages/viewpage.action?pageId=4456974',
- description = 'Provides static analysis of flows and groups ' +
- 'to determine the possible paths a packet may take.',
- required_apps = [
- 'org.onosproject.segmentrouting',
- 'org.onosproject.route-service',
- 'org.onosproject.mcast',
- ],
+ title = 'Trellis Troubleshooting Toolkit',
+ category = 'Utilities',
+ url = 'https://wiki.opencord.org/pages/viewpage.action?pageId=4456974',
+ description = 'Provides static analysis of flows and groups ' +
+ 'to determine the possible paths a packet may take.',
+ required_apps = [
+ 'org.onosproject.segmentrouting',
+ 'org.onosproject.route-service',
+ 'org.onosproject.mcast',
+ ],
+ included_bundles = BUNDLES,
+ app_name = 'org.onosproject.t3'
)
diff --git a/apps/t3/app/BUCK b/apps/t3/app/BUCK
new file mode 100644
index 0000000..55092ea
--- /dev/null
+++ b/apps/t3/app/BUCK
@@ -0,0 +1,26 @@
+COMPILE_DEPS = [
+ '//lib:CORE_DEPS',
+ '//lib:KRYO',
+ '//core/store/serializers:onos-core-serializers',
+ '//core/store/primitives:onos-core-primitives',
+ '//lib:JACKSON',
+ '//lib:jackson-databind',
+ '//core/api:onos-api',
+ '//lib:org.apache.karaf.shell.console',
+ '//cli:onos-cli',
+ '//drivers/default:onos-drivers-default',
+ '//apps/segmentrouting/app:onos-apps-segmentrouting-app',
+ '//apps/route-service/api:onos-apps-route-service-api',
+ '//apps/mcast/api:onos-apps-mcast-api',
+]
+
+TEST_DEPS = [
+ '//lib:TEST_ADAPTERS',
+ '//utils/misc:onlab-misc',
+ '//apps/route-service/api:onos-apps-route-service-api-tests',
+]
+
+osgi_jar_with_tests (
+ deps = COMPILE_DEPS,
+ test_deps = TEST_DEPS,
+)
diff --git a/apps/t3/app/pom.xml b/apps/t3/app/pom.xml
new file mode 100644
index 0000000..592a6c1
--- /dev/null
+++ b/apps/t3/app/pom.xml
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2017 Open Networking Foundation
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-apps</artifactId>
+ <version>1.14.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>onos-apps-t3-app</artifactId>
+ <packaging>bundle</packaging>
+
+ <description>Trellis Troubleshooting Toolkit</description>
+
+ <properties>
+ <onos.app.title>Trellis Troubleshooting Toolkit</onos.app.title>
+ <onos.app.category>Utilities</onos.app.category>
+ <onos.app.url>http://onosproject.org</onos.app.url>
+ <onos.app.readme>Static analysis of flows and groups to determine paths of packets.</onos.app.readme>
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-apps-mcast-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-apps-route-service-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-apps-route-service-api</artifactId>
+ <version>${project.version}</version>
+ <classifier>tests</classifier>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-apps-segmentrouting-app</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-core-serializers</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-api</artifactId>
+ <scope>test</scope>
+ <classifier>tests</classifier>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-core-primitives</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-cli</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.shell</groupId>
+ <artifactId>org.apache.karaf.shell.console</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.scr.annotations</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-drivers-default</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onlab-misc</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
+
diff --git a/apps/t3/src/main/java/org/onosproject/t3/api/GroupsInDevice.java b/apps/t3/app/src/main/java/org/onosproject/t3/api/GroupsInDevice.java
similarity index 100%
rename from apps/t3/src/main/java/org/onosproject/t3/api/GroupsInDevice.java
rename to apps/t3/app/src/main/java/org/onosproject/t3/api/GroupsInDevice.java
diff --git a/apps/t3/src/main/java/org/onosproject/t3/api/StaticPacketTrace.java b/apps/t3/app/src/main/java/org/onosproject/t3/api/StaticPacketTrace.java
similarity index 100%
rename from apps/t3/src/main/java/org/onosproject/t3/api/StaticPacketTrace.java
rename to apps/t3/app/src/main/java/org/onosproject/t3/api/StaticPacketTrace.java
diff --git a/apps/t3/src/main/java/org/onosproject/t3/api/TroubleshootService.java b/apps/t3/app/src/main/java/org/onosproject/t3/api/TroubleshootService.java
similarity index 100%
rename from apps/t3/src/main/java/org/onosproject/t3/api/TroubleshootService.java
rename to apps/t3/app/src/main/java/org/onosproject/t3/api/TroubleshootService.java
diff --git a/apps/t3/src/main/java/org/onosproject/t3/api/package-info.java b/apps/t3/app/src/main/java/org/onosproject/t3/api/package-info.java
similarity index 100%
rename from apps/t3/src/main/java/org/onosproject/t3/api/package-info.java
rename to apps/t3/app/src/main/java/org/onosproject/t3/api/package-info.java
diff --git a/apps/t3/src/main/java/org/onosproject/t3/cli/T3CliUtils.java b/apps/t3/app/src/main/java/org/onosproject/t3/cli/T3CliUtils.java
similarity index 100%
rename from apps/t3/src/main/java/org/onosproject/t3/cli/T3CliUtils.java
rename to apps/t3/app/src/main/java/org/onosproject/t3/cli/T3CliUtils.java
diff --git a/apps/t3/src/main/java/org/onosproject/t3/cli/TroubleshootMcastCommand.java b/apps/t3/app/src/main/java/org/onosproject/t3/cli/TroubleshootMcastCommand.java
similarity index 100%
rename from apps/t3/src/main/java/org/onosproject/t3/cli/TroubleshootMcastCommand.java
rename to apps/t3/app/src/main/java/org/onosproject/t3/cli/TroubleshootMcastCommand.java
diff --git a/apps/t3/src/main/java/org/onosproject/t3/cli/TroubleshootPingAllCommand.java b/apps/t3/app/src/main/java/org/onosproject/t3/cli/TroubleshootPingAllCommand.java
similarity index 100%
rename from apps/t3/src/main/java/org/onosproject/t3/cli/TroubleshootPingAllCommand.java
rename to apps/t3/app/src/main/java/org/onosproject/t3/cli/TroubleshootPingAllCommand.java
diff --git a/apps/t3/src/main/java/org/onosproject/t3/cli/TroubleshootSimpleTraceCommand.java b/apps/t3/app/src/main/java/org/onosproject/t3/cli/TroubleshootSimpleTraceCommand.java
similarity index 100%
rename from apps/t3/src/main/java/org/onosproject/t3/cli/TroubleshootSimpleTraceCommand.java
rename to apps/t3/app/src/main/java/org/onosproject/t3/cli/TroubleshootSimpleTraceCommand.java
diff --git a/apps/t3/src/main/java/org/onosproject/t3/cli/TroubleshootTraceCommand.java b/apps/t3/app/src/main/java/org/onosproject/t3/cli/TroubleshootTraceCommand.java
similarity index 100%
rename from apps/t3/src/main/java/org/onosproject/t3/cli/TroubleshootTraceCommand.java
rename to apps/t3/app/src/main/java/org/onosproject/t3/cli/TroubleshootTraceCommand.java
diff --git a/apps/t3/src/main/java/org/onosproject/t3/cli/package-info.java b/apps/t3/app/src/main/java/org/onosproject/t3/cli/package-info.java
similarity index 100%
rename from apps/t3/src/main/java/org/onosproject/t3/cli/package-info.java
rename to apps/t3/app/src/main/java/org/onosproject/t3/cli/package-info.java
diff --git a/apps/t3/src/main/java/org/onosproject/t3/impl/Generator.java b/apps/t3/app/src/main/java/org/onosproject/t3/impl/Generator.java
similarity index 100%
rename from apps/t3/src/main/java/org/onosproject/t3/impl/Generator.java
rename to apps/t3/app/src/main/java/org/onosproject/t3/impl/Generator.java
diff --git a/apps/t3/src/main/java/org/onosproject/t3/impl/McastGenerator.java b/apps/t3/app/src/main/java/org/onosproject/t3/impl/McastGenerator.java
similarity index 100%
rename from apps/t3/src/main/java/org/onosproject/t3/impl/McastGenerator.java
rename to apps/t3/app/src/main/java/org/onosproject/t3/impl/McastGenerator.java
diff --git a/apps/t3/src/main/java/org/onosproject/t3/impl/PingAllGenerator.java b/apps/t3/app/src/main/java/org/onosproject/t3/impl/PingAllGenerator.java
similarity index 100%
rename from apps/t3/src/main/java/org/onosproject/t3/impl/PingAllGenerator.java
rename to apps/t3/app/src/main/java/org/onosproject/t3/impl/PingAllGenerator.java
diff --git a/apps/t3/src/main/java/org/onosproject/t3/impl/Subnet.java b/apps/t3/app/src/main/java/org/onosproject/t3/impl/Subnet.java
similarity index 100%
rename from apps/t3/src/main/java/org/onosproject/t3/impl/Subnet.java
rename to apps/t3/app/src/main/java/org/onosproject/t3/impl/Subnet.java
diff --git a/apps/t3/src/main/java/org/onosproject/t3/impl/TroubleshootManager.java b/apps/t3/app/src/main/java/org/onosproject/t3/impl/TroubleshootManager.java
similarity index 100%
rename from apps/t3/src/main/java/org/onosproject/t3/impl/TroubleshootManager.java
rename to apps/t3/app/src/main/java/org/onosproject/t3/impl/TroubleshootManager.java
diff --git a/apps/t3/src/main/java/org/onosproject/t3/impl/TroubleshootUtils.java b/apps/t3/app/src/main/java/org/onosproject/t3/impl/TroubleshootUtils.java
similarity index 100%
rename from apps/t3/src/main/java/org/onosproject/t3/impl/TroubleshootUtils.java
rename to apps/t3/app/src/main/java/org/onosproject/t3/impl/TroubleshootUtils.java
diff --git a/apps/t3/src/main/java/org/onosproject/t3/impl/package-info.java b/apps/t3/app/src/main/java/org/onosproject/t3/impl/package-info.java
similarity index 100%
rename from apps/t3/src/main/java/org/onosproject/t3/impl/package-info.java
rename to apps/t3/app/src/main/java/org/onosproject/t3/impl/package-info.java
diff --git a/apps/t3/src/main/java/org/onosproject/t3/package-info.java b/apps/t3/app/src/main/java/org/onosproject/t3/package-info.java
similarity index 100%
rename from apps/t3/src/main/java/org/onosproject/t3/package-info.java
rename to apps/t3/app/src/main/java/org/onosproject/t3/package-info.java
diff --git a/apps/t3/src/main/resources/OSGI-INF/blueprint/shell-config.xml b/apps/t3/app/src/main/resources/OSGI-INF/blueprint/shell-config.xml
similarity index 100%
rename from apps/t3/src/main/resources/OSGI-INF/blueprint/shell-config.xml
rename to apps/t3/app/src/main/resources/OSGI-INF/blueprint/shell-config.xml
diff --git a/apps/t3/src/test/java/org/onosproject/t3/impl/T3TestObjects.java b/apps/t3/app/src/test/java/org/onosproject/t3/impl/T3TestObjects.java
similarity index 100%
rename from apps/t3/src/test/java/org/onosproject/t3/impl/T3TestObjects.java
rename to apps/t3/app/src/test/java/org/onosproject/t3/impl/T3TestObjects.java
diff --git a/apps/t3/src/test/java/org/onosproject/t3/impl/TroubleshootManagerTest.java b/apps/t3/app/src/test/java/org/onosproject/t3/impl/TroubleshootManagerTest.java
similarity index 100%
rename from apps/t3/src/test/java/org/onosproject/t3/impl/TroubleshootManagerTest.java
rename to apps/t3/app/src/test/java/org/onosproject/t3/impl/TroubleshootManagerTest.java
diff --git a/apps/t3/src/test/java/org/onosproject/t3/impl/TroubleshootUtilsTest.java b/apps/t3/app/src/test/java/org/onosproject/t3/impl/TroubleshootUtilsTest.java
similarity index 100%
rename from apps/t3/src/test/java/org/onosproject/t3/impl/TroubleshootUtilsTest.java
rename to apps/t3/app/src/test/java/org/onosproject/t3/impl/TroubleshootUtilsTest.java
diff --git a/apps/t3/pom.xml b/apps/t3/pom.xml
new file mode 100644
index 0000000..c980f98
--- /dev/null
+++ b/apps/t3/pom.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2017 Open Networking Foundation
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>onos-apps</artifactId>
+ <groupId>org.onosproject</groupId>
+ <version>1.14.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-apps-t3</artifactId>
+ <version>1.14.0-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <onos.version>1.14.0-SNAPSHOT</onos.version>
+ <onos.app.name>org.onosproject.t3</onos.app.name>
+ <onos.app.title>Trellis Troubleshooting Toolkit</onos.app.title>
+ <onos.app.category>Utilities</onos.app.category>
+ <onos.app.url>http://onosproject.org</onos.app.url>
+ <onos.app.readme>T3 APP and API support to determine the paths of packets</onos.app.readme>
+ </properties>
+
+
+ <modules>
+ <module>web</module>
+ <module>app</module>
+ </modules>
+
+
+</project>
diff --git a/apps/t3/web/BUCK b/apps/t3/web/BUCK
new file mode 100644
index 0000000..fb837c4
--- /dev/null
+++ b/apps/t3/web/BUCK
@@ -0,0 +1,19 @@
+COMPILE_DEPS = [
+ '//lib:CORE_DEPS',
+ '//lib:KRYO',
+ '//core/api:onos-api',
+ '//lib:org.apache.karaf.shell.console',
+ '//utils/rest:onlab-rest',
+ '//lib:JACKSON',
+ '//lib:javax.ws.rs-api',
+ '//lib:jersey-server',
+ '//apps/t3/app:onos-apps-t3-app',
+]
+osgi_jar (
+ deps = COMPILE_DEPS,
+ web_context = '/onos/v1/t3',
+ api_title = 'T3 REST API',
+ api_version = '1.0',
+ api_description = 'REST API for T3',
+ api_package = 'org.onosproject.t3.rest',
+)
diff --git a/apps/t3/web/pom.xml b/apps/t3/web/pom.xml
new file mode 100644
index 0000000..e0c5414
--- /dev/null
+++ b/apps/t3/web/pom.xml
@@ -0,0 +1,221 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2017 Open Networking Foundation
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>onos-apps</artifactId>
+ <groupId>org.onosproject</groupId>
+ <version>1.14.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-apps-t3-web</artifactId>
+ <version>1.14.0-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+
+ <description>T3 REST API</description>
+ <url>http://onosproject.org</url>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <onos.version>1.14.0-SNAPSHOT</onos.version>
+ <web.context>/onos/v1/t3</web.context>
+ <api.version>1.0.0</api.version>
+ <api.title>ONOS T3 REST API</api.title>
+ <api.description>
+ APIs for interacting with the T3 application.
+ </api.description>
+ <api.package>org.onosproject.t3.rest</api.package>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-api</artifactId>
+ <version>${onos.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-apps-t3-app</artifactId>
+ <version>${onos.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onlab-osgi</artifactId>
+ <version>${onos.version}</version>
+ </dependency>
+
+
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onlab-misc</artifactId>
+ <version>${onos.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-api</artifactId>
+ <version>${onos.version}</version>
+ <scope>test</scope>
+ <classifier>tests</classifier>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.scr.annotations</artifactId>
+ <version>1.9.12</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.ws.rs</groupId>
+ <artifactId>javax.ws.rs-api</artifactId>
+ <version>2.1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-api</artifactId>
+ <version>${onos.version}</version>
+ <classifier>tests</classifier>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-rest</artifactId>
+ <version>${onos.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.glassfish.jersey.containers</groupId>
+ <artifactId>jersey-container-servlet</artifactId>
+ <version>2.25.1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onlab-rest</artifactId>
+ <version>${onos.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-cli</artifactId>
+ <version>${onos.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.shell</groupId>
+ <artifactId>org.apache.karaf.shell.console</artifactId>
+ <version>3.0.8</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>3.0.1</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <_wab>src/main/webapp/</_wab>
+ <Include-Resource>WEB-INF/classes/apidoc/swagger.json=target/swagger.json,
+ {maven-resources}
+ </Include-Resource>
+ <Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
+ <Import-Package>*,org.glassfish.jersey.servlet</Import-Package>
+ <Web-ContextPath>${web.context}</Web-ContextPath>
+ </instructions>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.5.1</version>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ <version>1.21.0</version>
+ <executions>
+ <execution>
+ <id>generate-scr-srcdescriptor</id>
+ <goals>
+ <goal>scr</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <supportedProjectTypes>
+ <supportedProjectType>bundle</supportedProjectType>
+ <supportedProjectType>war</supportedProjectType>
+ </supportedProjectTypes>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-maven-plugin</artifactId>
+ <version>1.10</version>
+ <executions>
+ <execution>
+ <id>cfg</id>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>cfg</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>swagger</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>swagger</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>app</id>
+ <phase>package</phase>
+ <goals>
+ <goal>app</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/apps/t3/web/src/main/java/org/onosproject/t3/rest/T3WebApplication.java b/apps/t3/web/src/main/java/org/onosproject/t3/rest/T3WebApplication.java
new file mode 100644
index 0000000..5f6a548
--- /dev/null
+++ b/apps/t3/web/src/main/java/org/onosproject/t3/rest/T3WebApplication.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.t3.rest;
+
+
+import org.onlab.rest.AbstractWebApplication;
+
+import java.util.Set;
+
+public class T3WebApplication extends AbstractWebApplication {
+ @Override
+ public Set<Class<?>> getClasses() {
+ return getClasses(T3WebResource.class);
+ }
+
+}
diff --git a/apps/t3/web/src/main/java/org/onosproject/t3/rest/T3WebResource.java b/apps/t3/web/src/main/java/org/onosproject/t3/rest/T3WebResource.java
new file mode 100644
index 0000000..0fe7674
--- /dev/null
+++ b/apps/t3/web/src/main/java/org/onosproject/t3/rest/T3WebResource.java
@@ -0,0 +1,271 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.t3.rest;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+import org.onlab.packet.EthType;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.HostId;
+import org.onosproject.net.flow.FlowEntry;
+import org.onosproject.net.flow.criteria.Criterion;
+import org.onosproject.net.group.Group;
+import org.onosproject.rest.AbstractWebResource;
+import org.onosproject.t3.api.GroupsInDevice;
+import org.onosproject.t3.api.StaticPacketTrace;
+import org.onosproject.t3.api.TroubleshootService;
+import org.slf4j.Logger;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import java.util.List;
+import java.util.Set;
+
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Trellis Troubleshooting Tool REST API.
+ */
+@Path("t3")
+public class T3WebResource extends AbstractWebResource {
+ private final ObjectMapper mapper = new ObjectMapper();
+ private static final Logger LOG = getLogger(T3WebResource.class);
+
+ /**
+ * Returns the trace non verbose result for the given source and destination ips.
+ *
+ * @param srcHost source ip identifier
+ * @param dstHost destination ip identifier
+ * @param ethType ethernet type identifier
+ * @return 200 OK with component properties of given component and variable
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("simple/{srcHost}/{dstHost}/{ethType}")
+ public Response getT3Simple(@PathParam("srcHost") String srcHost, @PathParam("dstHost") String dstHost,
+ @PathParam("ethType") String ethType) {
+
+ ObjectNode node;
+ try {
+ node = getT3JsonOutput(srcHost, dstHost, ethType, false);
+ } catch (IllegalArgumentException e) {
+ throw new IllegalArgumentException(e);
+ }
+ return Response.status(200).entity(node).build();
+
+ }
+
+ /**
+ * Returns the trace verbose result for the given source and destination ips.
+ *
+ * @param srcHost source ip identifier
+ * @param dstHost destination ip identifier
+ * @param ethType ethernet type identifier
+ * @return 200 OK with component properties of given component and variable
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("simple/{srcHost}/{dstHost}/{ethType}/verbose")
+ public Response getT3SimpleVerbose(@PathParam("srcHost") String srcHost, @PathParam("dstHost") String dstHost,
+ @PathParam("ethType") String ethType) {
+
+ ObjectNode node;
+ try {
+ node = getT3JsonOutput(srcHost, dstHost, ethType, true);
+ } catch (IllegalArgumentException e) {
+ throw new IllegalArgumentException(e);
+ }
+ return Response.status(200).entity(node).build();
+ }
+
+ /**
+ * Returns trace verbose or non verbose json output for the given trace.
+ *
+ * @param srcHost source ip identifier
+ * @param dstHost destination ip identifier
+ * @param ethType the ethernet Type
+ * @param verbose based on verbosity level
+ * @return a json representing the trace.
+ */
+ private ObjectNode getT3JsonOutput(String srcHost, String dstHost, String ethType, Boolean verbose) {
+ TroubleshootService troubleshootService = get(TroubleshootService.class);
+ final ObjectNode nodeOutput = mapper.createObjectNode();
+ //Tracing between host ips
+ ArrayNode ipList = mapper.createArrayNode();
+ ipList.add(srcHost);
+ ipList.add(dstHost);
+ nodeOutput.set("hostIps ", ipList);
+ EthType.EtherType type = EthType.EtherType.valueOf(ethType.toUpperCase());
+
+ //Build the traces
+ Set<StaticPacketTrace> traces = troubleshootService.trace(HostId.hostId(srcHost), HostId.hostId(dstHost), type);
+ traces.forEach(trace -> {
+
+ if (trace.getInitialPacket() != null) {
+ ArrayNode node = mapper.createArrayNode();
+ for (Criterion packet : trace.getInitialPacket().criteria()) {
+ node.add(packet.toString());
+ }
+ nodeOutput.set("input packet", node);
+ nodeOutput.set("trace", getTraceJson(trace, verbose));
+ } else {
+ LOG.debug("cannot obtain trace between: ", srcHost, dstHost);
+ nodeOutput.set("failed trace", ipList);
+ nodeOutput.put("reason", trace.resultMessage());
+ }
+ });
+ return nodeOutput;
+ }
+
+ /**
+ * Returns verbose or non verbose json output for the given trace. *
+ *
+ * @param trace the trace
+ * @param verbosity based on verbosity level
+ * @return a json representing the trace.
+ */
+ public ObjectNode getTraceJson(StaticPacketTrace trace, boolean verbosity) {
+ ObjectNode nodeOutput = mapper.createObjectNode();
+ if (verbosity) {
+ nodeOutput.set("trace", getTrace(trace, verbosity));
+ } else {
+ ArrayNode nodePath = mapper.createArrayNode();
+ for (List<ConnectPoint> listPaths : trace.getCompletePaths()) {
+ ArrayNode node = mapper.createArrayNode();
+ for (ConnectPoint path : listPaths) {
+ node.add(path.toString());
+ }
+ nodePath.add(node);
+ }
+ nodeOutput.set("paths", nodePath);
+ }
+
+ nodeOutput.put("result", trace.resultMessage());
+ return nodeOutput;
+ }
+
+ /**
+ * Returns verbose json output for the given trace. *
+ *
+ * @param trace the trace
+ * @return a json representing the trace.
+ */
+ private ObjectNode getTrace(StaticPacketTrace trace, boolean verbose) {
+
+ ObjectNode nodeOutput = mapper.createObjectNode();
+
+ List<List<ConnectPoint>> paths = trace.getCompletePaths();
+ ArrayNode nodePath = mapper.createArrayNode();
+ for (List<ConnectPoint> path : paths) {
+ ArrayNode pathNode = mapper.createArrayNode();
+ for (ConnectPoint pathItr : path) {
+ pathNode.add(pathItr.toString());
+ }
+ nodePath.add(pathNode);
+
+ ConnectPoint previous = null;
+
+ if (path.size() == 1) {
+ ConnectPoint connectPoint = path.get(0);
+ nodeOutput.put("device", connectPoint.deviceId().toString());
+ nodeOutput.put("input", connectPoint.toString());
+ nodeOutput.put("flowCount", trace.getFlowsForDevice(connectPoint.deviceId()).size());
+ nodeOutput.set("flows", getFlowArray(trace, connectPoint, verbose));
+
+ List<GroupsInDevice> groupsInDevice = trace.getGroupOuputs(connectPoint.deviceId());
+
+ if (groupsInDevice != null) {
+ groupsInDevice.forEach(output -> {
+ nodeOutput.set("groups", getGroupObj(connectPoint, output, verbose));
+ });
+ }
+
+ } else {
+ for (ConnectPoint connectPoint : path) {
+ if (previous == null || !previous.deviceId().equals(connectPoint.deviceId())) {
+ nodeOutput.put("device", connectPoint.deviceId().toString());
+ nodeOutput.put("input", connectPoint.toString());
+ nodeOutput.put("flows", trace.getFlowsForDevice(connectPoint.deviceId()).size());
+ nodeOutput.put("verbose", verbose);
+ nodeOutput.set("flows", getFlowArray(trace, connectPoint, verbose));
+ } else {
+ List<GroupsInDevice> groupsInDevice = trace.getGroupOuputs(connectPoint.deviceId());
+ if (groupsInDevice != null) {
+ groupsInDevice.forEach(output -> {
+ nodeOutput.set("groups", getGroupObj(connectPoint, output, verbose));
+ });
+
+ }
+
+ }
+ previous = connectPoint;
+ }
+ }
+ }
+ nodeOutput.set("path", nodePath);
+ return nodeOutput;
+ }
+
+ //Return groups Object for a given trace and a specified level of verbosity
+ private ObjectNode getGroupObj(ConnectPoint connectPoint, GroupsInDevice output, boolean verbose) {
+ ArrayNode groupArray = mapper.createArrayNode();
+ ObjectNode groupsObj = mapper.createObjectNode();
+ if (output.getOutput().equals(connectPoint)) {
+ output.getGroups().forEach(group -> {
+ ObjectNode groups = mapper.createObjectNode();
+ if (verbose) {
+ groups = codec(Group.class).encode(group, this);
+ } else {
+ groups.put("groupId", group.id().toString());
+ }
+ groupArray.add(groups);
+ });
+ ArrayNode node = mapper.createArrayNode();
+ for (Criterion packet : output.getFinalPacket().criteria()) {
+ node.add(packet.toString());
+ }
+ groupsObj.set("outgoing packet", node);
+ }
+ groupsObj.set("groups", groupArray);
+ return groupsObj;
+ }
+
+ //Return flows Object for a given trace and a specified level of verbosity
+ private ArrayNode getFlowArray(StaticPacketTrace trace, ConnectPoint connectPoint, boolean verbose) {
+ ArrayNode flowArray = mapper.createArrayNode();
+ trace.getFlowsForDevice(connectPoint.deviceId()).forEach(f -> {
+ ObjectNode flows = mapper.createObjectNode();
+ if (verbose) {
+ flows = codec(FlowEntry.class).encode(f, this);
+ } else {
+ flows.put("flowId: ", f.id().toString());
+ flows.put("table: ", f.table().toString());
+ flows.put("selector: ", f.selector().criteria().toString());
+ }
+ flowArray.add(flows);
+ });
+ return flowArray;
+ }
+
+}
diff --git a/apps/t3/web/src/main/java/org/onosproject/t3/rest/package-info.java b/apps/t3/web/src/main/java/org/onosproject/t3/rest/package-info.java
new file mode 100644
index 0000000..e390f3e
--- /dev/null
+++ b/apps/t3/web/src/main/java/org/onosproject/t3/rest/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Troubleshooting toolkit for trellis fabrics implementation.
+ */
+package org.onosproject.t3.rest;