VOL-1612: Initial commit
Builds and works
Change-Id: Ie9c9be5de0169b3d8492fd8a62bcd1887ea57f7b
diff --git a/Dockerfile.voltha-onos b/Dockerfile.voltha-onos
new file mode 100644
index 0000000..d0017bd
--- /dev/null
+++ b/Dockerfile.voltha-onos
@@ -0,0 +1,89 @@
+# Copyright 2018 the original author or authors.
+#
+# 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.
+
+
+# Download and copy the specified onos apps
+FROM maven:3-jdk-8-alpine as download
+
+# The ENV settings must be replicated below as they are not shared between stages
+ENV DOWNLOAD_ROOT=/download
+RUN mkdir -p ${DOWNLOAD_ROOT}
+WORKDIR ${DOWNLOAD_ROOT}
+COPY mvn_settings.* ${DOWNLOAD_ROOT}/
+RUN ./mvn_settings.sh
+ADD dependencies.xml .
+
+ARG LOCAL_ONOSAPPS
+COPY local_imports/ /local_imports/
+RUN if [ -n "$LOCAL_ONOSAPPS" ] ; then \
+ cp /local_imports/oar/* ${DOWNLOAD_ROOT}/ ; \
+else \
+ mvn dependency:copy -Dmdep.useBaseVersion=true -DoutputDirectory=${DOWNLOAD_ROOT} -Dsilent=true -f dependencies.xml -s mvn_settings.xml ; \
+fi
+
+
+# Unpack and install specific apps from download stage
+FROM onosproject/onos:1.13.5 as install
+
+# The ENV settings must be replicated below as they are not shared between stages
+ENV ONOS=/root/onos
+ENV KARAF_VERSION=3.0.8
+ENV KARAF_ROOT=${ONOS}/apache-karaf-${KARAF_VERSION}
+ENV APPS_ROOT=${ONOS}/apps
+ENV KARAF_M2=${KARAF_ROOT}/system
+ENV DOWNLOAD_ROOT=/download
+ENV APP_INSTALL_ROOT=/expand
+
+# Copy the downloaded artifact to the install stage container
+COPY --from=download ${DOWNLOAD_ROOT} ${DOWNLOAD_ROOT}
+
+# Install the applications
+COPY app-install.sh ./app-install.sh
+RUN chmod 755 ./app-install.sh
+RUN ./app-install.sh
+
+
+# Create the final image coping over the installed applications from the install stage
+FROM onosproject/onos:1.13.5
+
+# The ENV settings must be replicated below as they are not shared between stages
+ENV ONOS=/root/onos
+ENV KARAF_VERSION=3.0.8
+ENV KARAF_ROOT=${ONOS}/apache-karaf-${KARAF_VERSION}
+ENV KARAF_M2=${KARAF_ROOT}/system
+ENV APPS_ROOT=${ONOS}/apps
+
+COPY --from=install ${KARAF_M2}/ ${KARAF_M2}/
+RUN echo "${KARAF_M2} ${APPS_ROOT}"
+COPY --from=install ${APPS_ROOT}/ ${APPS_ROOT}/
+COPY network-cfg.json $KARAF_ROOT/../config/network-cfg.json
+
+RUN touch $ONOS/apps/org.onosproject.hostprovider/active
+RUN touch $ONOS/apps/org.onosproject.openflow-base/active
+
+# Label image
+ARG org_label_schema_name=unknown
+ARG org_label_schema_version=unknown
+ARG org_label_schema_vcs_url=unknown
+ARG org_label_schema_vcs_ref=unknown
+ARG org_label_schema_build_date=unknown
+ARG org_opencord_vcs_commit_date=unknown
+
+LABEL org.label-schema.schema-version=1.0 \
+ org.label-schema.name=$org_label_schema_name \
+ org.label-schema.version=$org_label_schema_version \
+ org.label-schema.vcs-url=$org_label_schema_vcs_url \
+ org.label-schema.vcs-ref=$org_label_schema_vcs_ref \
+ org.label-schema.build-date=$org_label_schema_build_date \
+ org.opencord.vcs-commit-date=$org_opencord_vcs_commit_date
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..d9b70fb
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,77 @@
+#
+# Copyright 2016 the original author or authors.
+#
+# 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.
+#
+
+# set default shell
+SHELL = bash -e -o pipefail
+
+# Variables
+VERSION ?= $(shell cat ./VERSION)
+
+## Docker related
+DOCKER_REGISTRY ?=
+DOCKER_REPOSITORY ?=
+DOCKER_BUILD_ARGS ?=
+DOCKER_TAG ?= ${VERSION}
+ONOS_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}voltha-onos:${DOCKER_TAG}
+
+## Docker labels. Only set ref and commit date if committed
+DOCKER_LABEL_VCS_URL ?= $(shell git remote get-url $(shell git remote))
+DOCKER_LABEL_VCS_REF ?= $(shell git diff-index --quiet HEAD -- && git rev-parse HEAD || echo "unknown")
+DOCKER_LABEL_COMMIT_DATE ?= $(shell git diff-index --quiet HEAD -- && git show -s --format=%cd --date=iso-strict HEAD || echo "unknown" )
+DOCKER_LABEL_BUILD_DATE ?= $(shell date -u "+%Y-%m-%dT%H:%M:%SZ")
+
+.PHONY: docker-build
+
+# This should to be the first and default target in this Makefile
+help:
+ @echo "Usage: make [<target>]"
+ @echo "where available targets are:"
+ @echo
+ @echo "build : Build the onos docker image with olt apps built-in"
+ @echo "help : Print this help"
+ @echo "docker-push : Push the docker images to an external repository"
+ @echo "clean : Delete any locally copied oar files in local_imports"
+ @echo
+
+
+## Docker targets
+
+build: docker-build
+
+local-onosapps:
+ mkdir -p local_imports/oar
+ifdef LOCAL_ONOSAPPS
+ ./get-local-oars.sh
+endif
+
+docker-build: local-onosapps
+ docker build $(DOCKER_BUILD_ARGS) \
+ -t ${ONOS_IMAGENAME} \
+ --build-arg LOCAL_ONOSAPPS=$(LOCAL_ONOSAPPS) \
+ --build-arg org_label_schema_version="${VERSION}" \
+ --build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \
+ --build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \
+ --build-arg org_label_schema_build_date="${DOCKER_LABEL_BUILD_DATE}" \
+ --build-arg org_opencord_vcs_commit_date="${DOCKER_LABEL_COMMIT_DATE}" \
+ -f Dockerfile.voltha-onos .
+
+docker-push:
+ docker push ${ONOS_IMAGENAME}
+
+clean:
+ rm -rf local_imports
+
+# end file
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..98d421d
--- /dev/null
+++ b/README.md
@@ -0,0 +1,46 @@
+# VOLTHA ONOS Development Build Environment
+
+Docker build environment capable of producing a version of onos and needed apps that can run with voltha. Typically the onos restful api would be used to include apps after onos is started. This provides a build environment that includes current released and enabled oar files or optionally can import locally built oar files.
+
+
+## Build
+
+By default the current set of onos apps is imported from a maven repository as read from `dependencies.xml`.
+```sh
+make build
+```
+
+
+## Including locally built oar files
+
+If you wish to include your own onos apps then export the `LOCAL_ONOSAPPS` environment variable to have locally built oar files copied from `local_imports/oar` into the docker build environment rather than pulling from maven. Any oar files in this directory will be included and set to start on onos startup.
+
+Note! its assumed that the standard apps (olt-app, sadis, aaa, and dhcpl2relay) build environment is one up directory from this build environment. Modify `get-local-oars.sh` if this is not the case:
+
+```sh
+export LOCAL_ONOSAPPS=true
+make build
+```
+
+## Including custom config
+
+The voltha-onos build also includes a mechanism to build in a default onos `network-config.json` file. You can simply edit `network-cfg.json` before building the docker image. Or if using docker-compose or k8s volume mount over the built in file within the container `/root/onos/config/network-cfg.json` with your own.
+
+For example, in a docker-compose file:
+
+```sh
+ onos:
+ image: "${DOCKER_REGISTRY}${DOCKER_REPOSITORY}voltha-onos:${DOCKER_TAG}"
+ ports:
+ - "8101:8101" # ssh
+ - "6653:6653" # OF
+ - "8181:8181" # UI
+ environment:
+ ONOS_APPS: 'drivers,openflow-base'
+ volumes:
+ - "/var/run/docker.sock:/tmp/docker.sock"
+ - "./network-cfg.json:/root/onos/config/network-cfg.json"
+ networks:
+ - default
+ restart: unless-stopped
+```
diff --git a/VERSION b/VERSION
new file mode 100644
index 0000000..d72f262
--- /dev/null
+++ b/VERSION
@@ -0,0 +1 @@
+2.0.0-dev
diff --git a/app-install.sh b/app-install.sh
new file mode 100755
index 0000000..5ca794e
--- /dev/null
+++ b/app-install.sh
@@ -0,0 +1,34 @@
+#!/bin/bash
+# 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.
+
+HERE=$(pwd)
+OARS=$(find $DOWNLOAD_ROOT -name "*.oar")
+for oar in $OARS; do
+ cd $HERE
+ echo "Installing application '$oar'"
+ rm -rf $APP_INSTALL_ROOT
+ mkdir -p $APP_INSTALL_ROOT
+ cd $APP_INSTALL_ROOT
+ cp $oar $APP_INSTALL_ROOT
+ unzip -oq -d . $APP_INSTALL_ROOT/$(basename $oar)
+ name=$(grep "name=" $APP_INSTALL_ROOT/app.xml | sed 's/<app name="//g;s/".*//g')
+ mkdir -p $APPS_ROOT/$name
+ cp $APP_INSTALL_ROOT/app.xml $APPS_ROOT/$name/app.xml
+ touch $APPS_ROOT/$name/active
+ [ -f $APP_INSTALL_ROOT/app.png ] && cp $APP_INSTALL_ROOT/app.png $APPS_ROOT/$name/app.png
+ cp $APP_INSTALL_ROOT/$(basename $oar) $APPS_ROOT/$name/$name.oar
+ cp -rf $APP_INSTALL_ROOT/m2/* $KARAF_M2
+ rm -rf $APP_INSTALL_ROOT
+done
diff --git a/dependencies.xml b/dependencies.xml
new file mode 100644
index 0000000..2d5a52c
--- /dev/null
+++ b/dependencies.xml
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+<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>
+
+ <groupId>fake</groupId>
+ <artifactId>fake</artifactId>
+ <version>fake</version>
+
+ <properties>
+ <olt.version>2.1.0</olt.version>
+ <sadis.version>2.2.0</sadis.version>
+ <aaa.version>1.8.0</aaa.version>
+ <dhcpl2relay.version>1.5.0</dhcpl2relay.version>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>3.0.1</version>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.opencord</groupId>
+ <artifactId>olt-app</artifactId>
+ <version>${olt.version}</version>
+ <type>oar</type>
+ <overWrite>true</overWrite>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.opencord</groupId>
+ <artifactId>sadis-app</artifactId>
+ <version>${sadis.version}</version>
+ <type>oar</type>
+ <overWrite>true</overWrite>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.opencord</groupId>
+ <artifactId>aaa</artifactId>
+ <version>${aaa.version}</version>
+ <type>oar</type>
+ <overWrite>true</overWrite>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.opencord</groupId>
+ <artifactId>dhcpl2relay</artifactId>
+ <version>${dhcpl2relay.version}</version>
+ <type>oar</type>
+ <overWrite>true</overWrite>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <repositories>
+ <repository>
+ <id>central</id>
+ <name>Central Repository</name>
+ <url>http://repo.maven.apache.org/maven2</url>
+ <layout>default</layout>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ <releases>
+ <enabled>true</enabled>
+ <updatePolicy>always</updatePolicy>
+ <checksumPolicy>fail</checksumPolicy>
+ </releases>
+ </repository>
+
+ <repository>
+ <id>snapshots</id>
+ <url>https://oss.sonatype.org/content/repositories/snapshots</url>
+ <snapshots>
+ <enabled>true</enabled>
+ <updatePolicy>always</updatePolicy>
+ <checksumPolicy>fail</checksumPolicy>
+ </snapshots>
+ </repository>
+ </repositories>
+
+</project>
diff --git a/get-local-oars.sh b/get-local-oars.sh
new file mode 100755
index 0000000..f74cb2c
--- /dev/null
+++ b/get-local-oars.sh
@@ -0,0 +1,24 @@
+#
+# Copyright 2016 the original author or authors.
+#
+# 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.
+#
+
+set -x
+
+mkdir -p local_imports/oar
+cp ../olt/app/target/*.oar local_imports/oar/
+cp ../sadis/app/target/*.oar local_imports/oar/
+cp ../aaa/target/*.oar local_imports/oar/
+cp ../dhcpl2relay/target/*.oar local_imports/oar/
+
diff --git a/mvn_settings.sh b/mvn_settings.sh
new file mode 100755
index 0000000..7f66f25
--- /dev/null
+++ b/mvn_settings.sh
@@ -0,0 +1,48 @@
+#!/bin/bash
+# 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.
+if [ -f mvn_settings.custom.xml ] ; then
+ cp mvn_settings.custom.xml mvn_settings.xml
+ exit 0
+fi
+
+if [ "$http_proxy$https_proxy" != "" ] ; then
+ echo " <proxies>" >> mvn_settings.proxy.xml
+ for PROTOCOL in http https ; do
+ proxy="${PROTOCOL}_proxy"
+ proxy="${!proxy}"
+ if [ "$proxy" = "" ] ; then continue ; fi
+
+ # username/password not yet included
+ PROXY_HOST=$(echo "$proxy" | sed "s@.*://@@;s/.*@//;s@:.*@@")
+ PROXY_PORT=$(echo "$proxy" | sed "s@.*://@@;s@.*:@@;s@/.*@@")
+ NON_PROXY=$(echo "$no_proxy" | sed "s@,@|@g")
+
+ echo " <proxy>
+ <id>$PROTOCOL</id>
+ <active>true</active>
+ <protocol>$PROTOCOL</protocol>
+ <host>$PROXY_HOST</host>
+ <port>$PROXY_PORT</port>
+ <nonProxyHosts>$NON_PROXY</nonProxyHosts>
+ </proxy>" >> mvn_settings.proxy.xml
+ done
+ echo " </proxies>" >> mvn_settings.proxy.xml
+
+ sed -i '/<!--PROXY-->/r mvn_settings.proxy.xml' mvn_settings.xml
+fi
+
+if [ -f mvn_settings.extra.xml ] ; then
+ sed -i 's/<!--EXTRA-->/r mvn_settings.extra.xml' mvn_settings.xml
+fi
diff --git a/mvn_settings.xml b/mvn_settings.xml
new file mode 100644
index 0000000..26f9926
--- /dev/null
+++ b/mvn_settings.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you 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.
+-->
+
+<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
+ <!--PROXY-->
+ <!--EXTRA-->
+</settings>
diff --git a/network-cfg.json b/network-cfg.json
new file mode 100644
index 0000000..1ccd56b
--- /dev/null
+++ b/network-cfg.json
@@ -0,0 +1,69 @@
+{
+ "devices" : {
+ "of:000000000a4001cf" : {
+ "accessDevice" : {
+ "uplink" : "65536",
+ "vlan" : "1"
+ },
+ "basic" : {
+ "driver" : "voltha"
+ }
+ }
+ },
+ "apps" : {
+ "org.opencord.dhcpl2relay" : {
+ "dhcpl2relay" : {
+ "useOltUplinkForServerPktInOut" : true
+ }
+ },
+ "org.opencord.aaa" : {
+ "AAA" : {
+ "radiusIp" : "172.16.0.1",
+ "radiusServerPort" : "1645",
+ "radiusSecret" : "secret",
+ "nasIp" : "172.16.0.10",
+ "radiusConnectionType" : "socket",
+ "packetCustomizer" : "att"
+ }
+ },
+ "org.opencord.sadis" : {
+ "sadis" : {
+ "integration" : {
+ "cache" : {
+ "enabled" : true,
+ "maxsize" : 50,
+ "ttl" : "PT1m"
+ }
+ },
+ "entries" : [ {
+ "id" : "EC1829000886",
+ "uplinkPort" : 65536,
+ "hardwareIdentifier" : "3c:2c:99:f7:c6:82",
+ "ipAddress" : "10.64.1.207",
+ "nasId" : "ATLEDGEVOLT1"
+ }, {
+ "id" : "BRCM33333333-1",
+ "cTag" : 22,
+ "sTag" : 13,
+ "nasPortId" : "PON 1/1/3/1:3.1.1",
+ "circuitId" : "PON 1/1/3/1:3.1.1-CID",
+ "remoteId" : "ATLEDGEVOLT1-RID"
+ }, {
+ "id" : "BRCM33333333-2",
+ "cTag" : 23,
+ "sTag" : 13,
+ "nasPortId" : "PON 1/1/3/1:4.1.1",
+ "circuitId" : "PON 1/1/3/1:4.1.1-CID",
+ "remoteId" : "ATLEDGEVOLT1-RID"
+ }, {
+ "id" : "BRCM33333333-3",
+ "cTag" : 24,
+ "sTag" : 13,
+ "nasPortId" : "PON 1/1/3/1:5.1.1",
+ "circuitId" : "PON 1/1/3/1:5.1.1-CID",
+ "remoteId" : "ATLEDGEVOLT1-RID"
+ }]
+ }
+ }
+ }
+}