Add skeleton codes of kubevirt node and networking apps
Change-Id: I30dc9f02a8ea874bb18f1ecc781210bedb2c0972
diff --git a/apps/kubevirt-node/BUILD b/apps/kubevirt-node/BUILD
new file mode 100644
index 0000000..c0fb377
--- /dev/null
+++ b/apps/kubevirt-node/BUILD
@@ -0,0 +1,24 @@
+BUNDLES = JACKSON + [
+ "//apps/kubevirt-node/api:onos-apps-kubevirt-node-api",
+ "//apps/kubevirt-node/app:onos-apps-kubevirt-node-app",
+ "@commons_net//jar",
+ "@k8s_client//jar",
+ "@k8s_model//jar",
+ "@okhttp//jar",
+ "@okio//jar",
+ "@logging_interceptor//jar",
+ "@jackson_dataformat_yaml//jar",
+ "@snakeyaml//jar",
+]
+
+onos_app(
+ category = "Integration",
+ description = "SONA KubeVirt Node Application.",
+ included_bundles = BUNDLES,
+ required_apps = [
+ "org.onosproject.ovsdb-base",
+ "org.onosproject.drivers.ovsdb",
+ ],
+ title = "KubeVirt Node Application",
+ url = "https://wiki.onosproject.org/display/ONOS/SONA%3A+DC+Network+Virtualization",
+)
diff --git a/apps/kubevirt-node/api/BUILD b/apps/kubevirt-node/api/BUILD
new file mode 100644
index 0000000..55de911
--- /dev/null
+++ b/apps/kubevirt-node/api/BUILD
@@ -0,0 +1,14 @@
+COMPILE_DEPS = CORE_DEPS + [
+ "//protocols/ovsdb/api:onos-protocols-ovsdb-api",
+ "//protocols/ovsdb/rfc:onos-protocols-ovsdb-rfc",
+]
+
+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-node/api/src/main/java/org/onosproject/kubevirtnode/api/package-info.java b/apps/kubevirt-node/api/src/main/java/org/onosproject/kubevirtnode/api/package-info.java
new file mode 100644
index 0000000..76c5edd
--- /dev/null
+++ b/apps/kubevirt-node/api/src/main/java/org/onosproject/kubevirtnode/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.
+ */
+
+/**
+ * Application for bootstrapping Master/Minion Nodes in KubeVirt.
+ */
+package org.onosproject.kubevirtnode.api;
\ No newline at end of file
diff --git a/apps/kubevirt-node/app/BUILD b/apps/kubevirt-node/app/BUILD
new file mode 100644
index 0000000..196953d
--- /dev/null
+++ b/apps/kubevirt-node/app/BUILD
@@ -0,0 +1,31 @@
+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",
+ "@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 + 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 Node",
+ api_package = "org.onosproject.kubevirtnode.web",
+ api_title = "KubeVirt Node API",
+ api_version = "1.0",
+ karaf_command_packages = ["org.onosproject.kubevirtnode.cli"],
+ test_deps = TEST_DEPS,
+ web_context = "/onos/kubevirtnode",
+ deps = COMPILE_DEPS,
+)
diff --git a/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/cli/package-info.java b/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/cli/package-info.java
new file mode 100644
index 0000000..adcdb98
--- /dev/null
+++ b/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/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.
+ */
+
+/**
+ * Console commands to manage KubeVirt nodes.
+ */
+package org.onosproject.kubevirtnode.cli;
\ No newline at end of file
diff --git a/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/codec/package-info.java b/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/codec/package-info.java
new file mode 100644
index 0000000..7b0f16c
--- /dev/null
+++ b/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/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.
+ */
+
+/**
+ * Implementation of the codec broker and KubeVirt node entity JOSN codecs.
+ */
+package org.onosproject.kubevirtnode.codec;
\ No newline at end of file
diff --git a/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/impl/package-info.java b/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/impl/package-info.java
new file mode 100644
index 0000000..169795d
--- /dev/null
+++ b/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/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.
+ */
+
+/**
+ * Application for bootstrapping Master/Minion Nodes in KubeVirt.
+ */
+package org.onosproject.kubevirtnode.impl;
\ No newline at end of file
diff --git a/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/util/package-info.java b/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/util/package-info.java
new file mode 100644
index 0000000..8b424e7
--- /dev/null
+++ b/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/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 node utility package.
+ */
+package org.onosproject.kubevirtnode.util;
\ No newline at end of file
diff --git a/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/web/KubevirtNodeWebApplication.java b/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/web/KubevirtNodeWebApplication.java
new file mode 100644
index 0000000..aa30a6a
--- /dev/null
+++ b/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/web/KubevirtNodeWebApplication.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.kubevirtnode.web;
+
+import org.onlab.rest.AbstractWebApplication;
+
+import java.util.Set;
+
+/**
+ * KubeVirt node REST APIs web application.
+ */
+public class KubevirtNodeWebApplication extends AbstractWebApplication {
+ @Override
+ public Set<Class<?>> getClasses() {
+ return getClasses(KubevirtNodeWebResource.class);
+ }
+}
diff --git a/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/web/KubevirtNodeWebResource.java b/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/web/KubevirtNodeWebResource.java
new file mode 100644
index 0000000..65e5901
--- /dev/null
+++ b/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/web/KubevirtNodeWebResource.java
@@ -0,0 +1,50 @@
+/*
+ * 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.kubevirtnode.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("configure")
+public class KubevirtNodeWebResource extends AbstractWebResource {
+
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ /**
+ * Creates a set of KubeVirt nodes' config from the JSON input stream.
+ *
+ * @param input KubeVirt nodes JSON input stream
+ * @return 201 CREATED if the JSON is correct, 400 BAD_REQUEST if the JSON
+ * is malformed
+ * @onos.rsModel KubevirtNode
+ */
+ @POST
+ @Path("node")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response dummy(InputStream input) {
+ return Response.ok().build();
+ }
+}
diff --git a/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/web/package-info.java b/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/web/package-info.java
new file mode 100644
index 0000000..0847103
--- /dev/null
+++ b/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/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.
+ */
+
+/**
+ * Application for bootstrapping Master/Minion Nodes in KubeVirt.
+ */
+package org.onosproject.kubevirtnode.web;
\ No newline at end of file
diff --git a/apps/kubevirt-node/app/src/main/resources/definitions/KubevirtNode.json b/apps/kubevirt-node/app/src/main/resources/definitions/KubevirtNode.json
new file mode 100644
index 0000000..2e2cc37
--- /dev/null
+++ b/apps/kubevirt-node/app/src/main/resources/definitions/KubevirtNode.json
@@ -0,0 +1,48 @@
+{
+ "type": "object",
+ "required": [
+ "nodes"
+ ],
+ "properties": {
+ "nodes": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "required": [
+ "clusterName",
+ "hostname",
+ "type",
+ "managementIp",
+ "dataIp",
+ "integrationBridge"
+ ],
+ "properties": {
+ "clusterName": {
+ "type": "string",
+ "example": "kubernetes"
+ },
+ "hostname": {
+ "type": "string",
+ "example": "host1"
+ },
+ "type": {
+ "type": "string",
+ "example": "GATEWAY"
+ },
+ "managementIp": {
+ "type": "string",
+ "example": "10.10.10.1"
+ },
+ "dataIp": {
+ "type": "string",
+ "example": "20.20.20.2"
+ },
+ "integrationBridge": {
+ "type": "string",
+ "example": "of:0000000000000001"
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/apps/kubevirt-node/app/src/main/webapp/WEB-INF/web.xml b/apps/kubevirt-node/app/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..bcd9854
--- /dev/null
+++ b/apps/kubevirt-node/app/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,59 @@
+<?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 Node 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.kubevirtnode.web.KubevirtNodeWebApplication</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>