From 278bcdb154f6e9b62dcd823c9233d8b1d93ba45d Mon Sep 17 00:00:00 2001 From: Marcus G K Williams Date: Tue, 3 Jan 2017 13:42:46 -0800 Subject: [PATCH] Add OpenDaylight Container to kolla Implements docker container template for OpenDaylight. Change-Id: Icdcff77f0f6088f5a4db1bf77e37334dbd42074f Partially-Implements: blueprint opendaylight-support --- contrib/template-override/.keep | 0 .../opendaylight-template-overrides.j2 | 22 ++++++++++ doc/index.rst | 9 ++++ doc/template-override/.keep | 0 doc/template-override/opendaylight-source.rst | 38 ++++++++++++++++ docker/opendaylight/Dockerfile.j2 | 44 +++++++++++++++++++ docker/opendaylight/extend_start.sh | 10 +++++ docker/opendaylight/opendaylight.repo | 5 +++ kolla/common/config.py | 15 +++++++ .../add-opendaylight-fee2807442ce3c6d.yaml | 3 ++ tests/test_build.py | 4 ++ 11 files changed, 150 insertions(+) delete mode 100644 contrib/template-override/.keep create mode 100644 contrib/template-override/opendaylight-template-overrides.j2 delete mode 100644 doc/template-override/.keep create mode 100644 doc/template-override/opendaylight-source.rst create mode 100644 docker/opendaylight/Dockerfile.j2 create mode 100644 docker/opendaylight/extend_start.sh create mode 100644 docker/opendaylight/opendaylight.repo create mode 100644 releasenotes/notes/add-opendaylight-fee2807442ce3c6d.yaml diff --git a/contrib/template-override/.keep b/contrib/template-override/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/contrib/template-override/opendaylight-template-overrides.j2 b/contrib/template-override/opendaylight-template-overrides.j2 new file mode 100644 index 0000000000..e9f6cf38ea --- /dev/null +++ b/contrib/template-override/opendaylight-template-overrides.j2 @@ -0,0 +1,22 @@ +{% extends parent_template %} + +{% block neutron_server_footer %} +ADD plugins-archive / +RUN pip --no-cache-dir install /plugins/* +{% endblock %} + +{% block opendaylight_source_install %} + {% if base_distro in ['centos', 'oraclelinux', 'rhel'] %} + {% set opendaylight_packages = ['java-1.8.0-openjdk'] %} + {% elif base_distro in ['ubuntu', 'debian'] %} + {% set opendaylight_packages = ['openjdk-8-jre'] %} + {% endif %} + +{{ macros.install_packages(opendaylight_packages | customizable("packages")) }} + + {% if opendaylight_distro is not defined %} + {% set opendaylight_distro = 'distribution-karaf-0.5.3-Boron-SR3' %} + {% endif %} +ADD opendaylight-archive /opendaylight +RUN ln -s /opendaylight/{{ opendaylight_distro }} /opt/opendaylight +{% endblock %} diff --git a/doc/index.rst b/doc/index.rst index c63a9d2edb..54e6202129 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -55,3 +55,12 @@ Developer Docs CONTRIBUTING running-tests bug-triage + +Template Override Docs +====================== + +.. toctree:: + :maxdepth: 1 + :glob: + + template-override/* diff --git a/doc/template-override/.keep b/doc/template-override/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/doc/template-override/opendaylight-source.rst b/doc/template-override/opendaylight-source.rst new file mode 100644 index 0000000000..caf980774f --- /dev/null +++ b/doc/template-override/opendaylight-source.rst @@ -0,0 +1,38 @@ +================== +OpenDaylight Build +================== + +To build OpenDaylight, use of a template override +`opendaylight-template-overrides.j2` is needed. +The template override enables OpenDaylight use +with OpenStack by installing required networking-odl +plugin in neutron-server container. + +If you wish to install a different version of OpenDaylight +then distro packages, use a source build (in most cases this is +a prebuilt binary package). + +Building OpenDaylight Containers +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + +- For source builds append the following to kolla-build.conf, + selecting the version of OpenDaylight to use for your source build. + +- Change `opendaylight_distro` to match the folder where OpenDaylight + build resides. For example, if using prebuilt archive from OpenDaylight + downloads `distribution-karaf-0.5.3-Boron-SR3.tar.gz` becomes + `distribution-karaf-0.5.3-Boron-SR3`. + +kolla-build.conf +________________ +.. code-block:: console + + opendaylight_distro = distribution-karaf-0.5.3-Boron-SR3 + [opendaylight] + type = url + location = https://nexus.opendaylight.org/content/repositories/opendaylight.release/org/opendaylight/integration/distribution-karaf/0.5.3-Boron-SR3/distribution-karaf-0.5.3-Boron-SR3.tar.gz + +Build the container (source or binary) by executing the following command:: +:: + kolla-build --template-override contrib/template-override/opendaylight-template-overrides.j2 opendaylight diff --git a/docker/opendaylight/Dockerfile.j2 b/docker/opendaylight/Dockerfile.j2 new file mode 100644 index 0000000000..81c4a0d74a --- /dev/null +++ b/docker/opendaylight/Dockerfile.j2 @@ -0,0 +1,44 @@ +FROM {{ namespace }}/{{ image_prefix }}base:{{ tag }} +MAINTAINER {{ maintainer }} + +{% block opendaylight_header %}{% endblock %} + +{% import "macros.j2" as macros with context %} + +{{ macros.configure_user(name='opendaylight') }} + +{% if install_type == 'binary' %} + {% set opendaylight_packages = ['opendaylight'] %} + {% if base_distro in ['centos', 'oraclelinux', 'rhel'] %} + + {% if opendaylight_repo is not defined %} + {% set opendaylight_repo = 'opendaylight.repo' %} + {% endif %} +COPY {{ opendaylight_repo }} /etc/yum.repos.d/ + + {% elif base_distro in ['ubuntu', 'debian'] %} + {% if odl_release_deb_url is not defined %} + {% if base_distro in 'ubuntu' %} + {% set odl_release_deb_url = 'http://download.opensuse.org/repositories/home:/akshitajha/xUbuntu_16.04/' %} + {% elif base_distro in 'debian' %} + {% set odl_release_deb_url = 'http://download.opensuse.org/repositories/home:/akshitajha/Debian_8.0/' %} + {% endif %} + {% endif %} +RUN sh -c "echo 'deb {{ odl_release_deb_url }} /' > /etc/apt/sources.list.d/opendaylight.list" \ +&& apt-get update + {% endif %} + +{{ macros.install_packages(opendaylight_packages | customizable("packages")) }} + +{% elif install_type == 'source' %} +{% block opendaylight_source_install %} +RUN echo '{{ install_type }} not yet available for {{ base_distro }}' \ + && /bin/false +{% endblock %} +{% endif %} + +COPY extend_start.sh /usr/local/bin/kolla_extend_start +RUN chmod 755 /usr/local/bin/kolla_extend_start + +{% block opendaylight_footer %}{% endblock %} +{% block footer %}{% endblock %} diff --git a/docker/opendaylight/extend_start.sh b/docker/opendaylight/extend_start.sh new file mode 100644 index 0000000000..8fdba07268 --- /dev/null +++ b/docker/opendaylight/extend_start.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +OPENDAYLIGHT_LOG_DIR=/var/log/kolla/opendaylight + +if [[ ! -d "${OPENDAYLIGHT_LOG_DIR}" ]]; then + mkdir -p "${OPENDAYLIGHT_LOG_DIR}" +fi +if [[ $(stat -c %a "${OPENDAYLIGHT_LOG_DIR}") != "755" ]]; then + chmod 755 "${OPENDAYLIGHT_LOG_DIR}" +fi diff --git a/docker/opendaylight/opendaylight.repo b/docker/opendaylight/opendaylight.repo new file mode 100644 index 0000000000..0962252e12 --- /dev/null +++ b/docker/opendaylight/opendaylight.repo @@ -0,0 +1,5 @@ +[opendaylight] +name=CentOS CBS OpenDaylight Release Repository +baseurl=http://cbs.centos.org/repos/nfv7-opendaylight-5-release/$basearch/os/ +enabled=1 +gpgcheck=0 diff --git a/kolla/common/config.py b/kolla/common/config.py index 25b3db3512..6001c0c643 100755 --- a/kolla/common/config.py +++ b/kolla/common/config.py @@ -49,6 +49,7 @@ _PROFILE_OPTS = [ 'mariadb', 'memcached', 'mongodb', + 'opendaylight', 'openvswitch', 'rabbitmq', 'redis', @@ -460,6 +461,10 @@ SOURCES = { 'type': 'url', 'location': ('$tarballs_base/neutron-lbaas/' 'neutron-lbaas-master.tar.gz')}, + 'neutron-server-plugin-networking-odl': { + 'type': 'url', + 'location': ('$tarballs_base/networking-odl/' + 'networking-odl-master.tar.gz')}, 'neutron-server-plugin-neutron-dynamic-routing': { 'type': 'url', 'location': ('$tarballs_base/neutron-dynamic-routing/' @@ -496,6 +501,12 @@ SOURCES = { 'type': 'url', 'location': ('$tarballs_base/octavia/' 'octavia-master.tar.gz')}, + 'opendaylight': { + 'type': 'url', + 'location': ('https://nexus.opendaylight.org/content/' + 'repositories/opendaylight.release/org/opendaylight/' + 'integration/distribution-karaf/0.5.3-Boron-SR3/' + 'distribution-karaf-0.5.3-Boron-SR3.tar.gz')}, 'panko-base': { 'type': 'url', 'location': ('$tarballs_base/panko/' @@ -798,6 +809,10 @@ USERS = { 'uid': 42461, 'gid': 42461, }, + 'opendaylight-user': { + 'uid': 42462, + 'gid': 42462, + } } diff --git a/releasenotes/notes/add-opendaylight-fee2807442ce3c6d.yaml b/releasenotes/notes/add-opendaylight-fee2807442ce3c6d.yaml new file mode 100644 index 0000000000..f1e722f997 --- /dev/null +++ b/releasenotes/notes/add-opendaylight-fee2807442ce3c6d.yaml @@ -0,0 +1,3 @@ +--- +features: + - Add OpenDaylight docker template and supporting files. diff --git a/tests/test_build.py b/tests/test_build.py index 01a9dedce7..ebbee7880c 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -102,6 +102,7 @@ class BuildTestCentosSource(BuildTest, base.BaseTestCase): "bifrost-base", "kafka", "mistral-base", + "opendaylight" ] def setUp(self): @@ -142,6 +143,7 @@ class BuildTestUbuntuBinary(BuildTest, base.BaseTestCase): class BuildTestUbuntuSource(BuildTest, base.BaseTestCase): excluded_images = [ "bifrost-base", + "opendaylight" ] def setUp(self): @@ -182,6 +184,7 @@ class BuildTestDebianBinary(BuildTest, base.BaseTestCase): class BuildTestDebianSource(BuildTest, base.BaseTestCase): excluded_images = [ "bifrost-base", + "opendaylight" ] def setUp(self): @@ -220,6 +223,7 @@ class BuildTestOracleLinuxSource(BuildTest, base.BaseTestCase): excluded_images = [ "bifrost-base", "kafka", + "opendaylight" ] def setUp(self):