Add skeleton codes of kubevirt node and networking apps
Change-Id: I30dc9f02a8ea874bb18f1ecc781210bedb2c0972
diff --git a/apps/kubevirt-networking/BUILD b/apps/kubevirt-networking/BUILD
new file mode 100644
index 0000000..af30386
--- /dev/null
+++ b/apps/kubevirt-networking/BUILD
@@ -0,0 +1,27 @@
+BUNDLES = [
+ "//apps/kubevirt-networking/api:onos-apps-kubevirt-networking-api",
+ "//apps/kubevirt-networking/app:onos-apps-kubevirt-networking-app",
+ "@commons_net//jar",
+ "@jersey_client//jar",
+ "@json//jar",
+ "@k8s_client//jar",
+ "@k8s_model//jar",
+ "@okhttp//jar",
+ "@okio//jar",
+ "@logging_interceptor//jar",
+ "@jackson_dataformat_yaml//jar",
+ "@snakeyaml//jar",
+ "@zjsonpatch//jar",
+ "@validation_api//jar",
+]
+
+onos_app(
+ category = "Integration",
+ description = "SONA KubeVirt Networking Application.",
+ included_bundles = BUNDLES,
+ required_apps = [
+ "org.onosproject.kubevirt-node",
+ ],
+ title = "KubeVirt Networking Application",
+ url = "https://wiki.onosproject.org/display/ONOS/SONA%3A+DC+Network+Virtualization",
+)
diff --git a/apps/kubevirt-networking/api/BUILD b/apps/kubevirt-networking/api/BUILD
new file mode 100644
index 0000000..e1e477c
--- /dev/null
+++ b/apps/kubevirt-networking/api/BUILD
@@ -0,0 +1,20 @@
+COMPILE_DEPS = CORE_DEPS + [
+ "@k8s_client//jar",
+ "@k8s_model//jar",
+ "@okhttp//jar",
+ "@okio//jar",
+ "@logging_interceptor//jar",
+ "@jackson_dataformat_yaml//jar",
+ "@snakeyaml//jar",
+ "@commons_net//jar",
+]
+
+TEST_DEPS = TEST_ADAPTERS + [
+ "//core/api:onos-api-tests",
+ "//core/common:onos-core-common-tests",
+]
+
+osgi_jar_with_tests(
+ test_deps = TEST_DEPS,
+ deps = COMPILE_DEPS,
+)
diff --git a/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/package-info.java b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/package-info.java
new file mode 100644
index 0000000..20001eb
--- /dev/null
+++ b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2020-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.
+ */
+
+/**
+ * APIs for KubeVirt networking related functions.
+ */
+package org.onosproject.kubevirtnetworking.api;
\ No newline at end of file
diff --git a/apps/kubevirt-networking/app/BUILD b/apps/kubevirt-networking/app/BUILD
new file mode 100644
index 0000000..1d01e80
--- /dev/null
+++ b/apps/kubevirt-networking/app/BUILD
@@ -0,0 +1,36 @@
+COMPILE_DEPS = CORE_DEPS + JACKSON + KRYO + CLI + REST + [
+ "//core/store/serializers:onos-core-serializers",
+ "//protocols/ovsdb/api:onos-protocols-ovsdb-api",
+ "//protocols/ovsdb/rfc:onos-protocols-ovsdb-rfc",
+ "//apps/kubevirt-node/api:onos-apps-kubevirt-node-api",
+ "//apps/kubevirt-networking/api:onos-apps-kubevirt-networking-api",
+ "@commons_net//jar",
+ "@jersey_client//jar",
+ "@json//jar",
+ "@k8s_client//jar",
+ "@k8s_model//jar",
+ "@okhttp//jar",
+ "@okio//jar",
+ "@logging_interceptor//jar",
+ "@jackson_dataformat_yaml//jar",
+ "@snakeyaml//jar",
+ "@zjsonpatch//jar",
+ "@validation_api//jar",
+]
+
+TEST_DEPS = TEST_ADAPTERS + TEST_REST + [
+ "//core/api:onos-api-tests",
+ "//core/common:onos-core-common-tests",
+ "//web/api:onos-rest-tests",
+]
+
+osgi_jar_with_tests(
+ api_description = "REST API for KubeVirt Networking",
+ api_package = "org.onosproject.kubevirtnetworking.web",
+ api_title = "KubeVirt Networking API",
+ api_version = "1.0",
+ karaf_command_packages = ["org.onosproject.kubevirtnetworking.cli"],
+ test_deps = TEST_DEPS,
+ web_context = "/onos/kubevirtnetworking",
+ deps = COMPILE_DEPS,
+)
diff --git a/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/cli/package-info.java b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/cli/package-info.java
new file mode 100644
index 0000000..1df47ec
--- /dev/null
+++ b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/cli/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2020-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.
+ */
+
+/**
+ * CLI implementation for KubeVirt integration.
+ */
+package org.onosproject.kubevirtnetworking.cli;
\ No newline at end of file
diff --git a/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/codec/package-info.java b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/codec/package-info.java
new file mode 100644
index 0000000..91d8c00
--- /dev/null
+++ b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/codec/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2020-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.
+ */
+
+/**
+ * Implementations of the codec broker and KubeVirt networking entity JSON codecs.
+ */
+package org.onosproject.kubevirtnetworking.codec;
\ No newline at end of file
diff --git a/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/package-info.java b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/package-info.java
new file mode 100644
index 0000000..3741e1a
--- /dev/null
+++ b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2020-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.
+ */
+
+/**
+ * Implements KubeVirt integration.
+ */
+package org.onosproject.kubevirtnetworking.impl;
\ No newline at end of file
diff --git a/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/util/package-info.java b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/util/package-info.java
new file mode 100644
index 0000000..6fc13a9
--- /dev/null
+++ b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/util/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2020-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.
+ */
+
+/**
+ * KubeVirt networking utility package.
+ */
+package org.onosproject.kubevirtnetworking.util;
\ No newline at end of file
diff --git a/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/web/KubevirtNetworkingWebApplication.java b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/web/KubevirtNetworkingWebApplication.java
new file mode 100644
index 0000000..5ae1453
--- /dev/null
+++ b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/web/KubevirtNetworkingWebApplication.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2020-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.kubevirtnetworking.web;
+
+import org.onlab.rest.AbstractWebApplication;
+
+import java.util.Set;
+
+/**
+ * KubeVirt networking REST APIs web application.
+ */
+public class KubevirtNetworkingWebApplication extends AbstractWebApplication {
+ @Override
+ public Set<Class<?>> getClasses() {
+ return getClasses(KubevirtNetworkingWebResource.class);
+ }
+}
diff --git a/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/web/KubevirtNetworkingWebResource.java b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/web/KubevirtNetworkingWebResource.java
new file mode 100644
index 0000000..1f98048
--- /dev/null
+++ b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/web/KubevirtNetworkingWebResource.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2020-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.kubevirtnetworking.web;
+
+import org.onosproject.rest.AbstractWebResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.io.InputStream;
+
+@Path("network")
+public class KubevirtNetworkingWebResource extends AbstractWebResource {
+
+ protected final Logger log = LoggerFactory.getLogger(getClass());
+
+ /**
+ * Creates a network from the JSON input stream.
+ *
+ * @param input network JSON input stream
+ * @return 201 CREATED if the JSON is correct, 400 BAD_REQUEST if the JSON
+ * is invalid or duplicated network already exists
+ * @onos.rsModel KubevirtNetwork
+ */
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response dummy(InputStream input) {
+ return Response.ok().build();
+ }
+}
diff --git a/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/web/package-info.java b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/web/package-info.java
new file mode 100644
index 0000000..bc4157c
--- /dev/null
+++ b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/web/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2020-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.
+ */
+
+/**
+ * KubeVirt networking web implementation.
+ */
+package org.onosproject.kubevirtnetworking.web;
\ No newline at end of file
diff --git a/apps/kubevirt-networking/app/src/main/resources/definitions/KubevirtNetwork.json b/apps/kubevirt-networking/app/src/main/resources/definitions/KubevirtNetwork.json
new file mode 100644
index 0000000..5653ae8
--- /dev/null
+++ b/apps/kubevirt-networking/app/src/main/resources/definitions/KubevirtNetwork.json
@@ -0,0 +1,50 @@
+{
+ "type": "object",
+ "description": "A network object.",
+ "required": [
+ "networkId",
+ "type",
+ "name",
+ "segmentId",
+ "gatewayIp",
+ "cidr",
+ "mtu"
+ ],
+ "properties": {
+ "networkId": {
+ "type": "string",
+ "example": "sona-network",
+ "description": "The ID of the attached network."
+ },
+ "type": {
+ "type": "string",
+ "example": "VXLAN",
+ "description": "Type of kubernetes network."
+ },
+ "name": {
+ "type": "string",
+ "example": "sona-network",
+ "description": "The name of network."
+ },
+ "segmentId": {
+ "type": "string",
+ "example": "1",
+ "description": "Segment ID of tenant network."
+ },
+ "gatewayIp": {
+ "type": "string",
+ "example": "10.10.10.1",
+ "description": "The IP address of the gateway."
+ },
+ "cidr": {
+ "type": "string",
+ "example": "10.10.10.0/24",
+ "description": "The CIDR of this network."
+ },
+ "mtu": {
+ "type": "integer",
+ "example": 1500,
+ "description": "The Maximum Transmission Unit of this network."
+ }
+ }
+}
\ No newline at end of file
diff --git a/apps/kubevirt-networking/app/src/main/webapp/WEB-INF/web.xml b/apps/kubevirt-networking/app/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..0b4876a
--- /dev/null
+++ b/apps/kubevirt-networking/app/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2020-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.
+ -->
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ id="ONOS" version="2.5">
+ <display-name>KubeVirt Networking REST API v1.0</display-name>
+
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>Secured</web-resource-name>
+ <url-pattern>/*</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>admin</role-name>
+ <role-name>viewer</role-name>
+ </auth-constraint>
+ </security-constraint>
+
+ <security-role>
+ <role-name>admin</role-name>
+ <role-name>viewer</role-name>
+ </security-role>
+
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ <realm-name>karaf</realm-name>
+ </login-config>
+
+ <servlet>
+ <servlet-name>JAX-RS Service</servlet-name>
+ <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
+ <init-param>
+ <param-name>javax.ws.rs.Application</param-name>
+ <param-value>org.onosproject.kubevirtnetworking.web.KubevirtNetworkingWebApplication</param-value>
+ </init-param>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>JAX-RS Service</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+</web-app>