diff options
| author | Sam Yaple <sam@yaple.net> | 2015-08-28 12:16:53 +0000 |
|---|---|---|
| committer | Sam Yaple <sam@yaple.net> | 2015-08-28 13:33:50 +0000 |
| commit | cbd42ca6e90cca2ff4b84f5e4e46224e6455e8b2 (patch) | |
| tree | 2e4256b6b7b8339da11b1d17250378596e61605b /docker/neutron/neutron-base | |
| parent | 3b5380ade021c9884551f427441cbfc0122eb0f0 (diff) | |
| download | kolla-cbd42ca6e90cca2ff4b84f5e4e46224e6455e8b2.tar.gz kolla-cbd42ca6e90cca2ff4b84f5e4e46224e6455e8b2.zip | |
Move docker_templates to docker dir
Updated build.py to reflect this change.
Deprecate --template option and make it a noop.
Change-Id: I7cd98d1ee684a4c64984a49597159868152683b2
Partially-Implements: blueprint remove-docker-dir
Diffstat (limited to 'docker/neutron/neutron-base')
| -rw-r--r-- | docker/neutron/neutron-base/Dockerfile.j2 | 47 | ||||
| -rw-r--r-- | docker/neutron/neutron-base/config-sudoers.sh | 12 | ||||
| -rwxr-xr-x | docker/neutron/neutron-base/ip_wrapper.py | 66 |
3 files changed, 125 insertions, 0 deletions
diff --git a/docker/neutron/neutron-base/Dockerfile.j2 b/docker/neutron/neutron-base/Dockerfile.j2 new file mode 100644 index 000000000..f1cd75a37 --- /dev/null +++ b/docker/neutron/neutron-base/Dockerfile.j2 @@ -0,0 +1,47 @@ +FROM {{ namespace }}/{{ base_distro }}-{{ install_type }}-base:{{ tag }} +MAINTAINER Kolla Project (https://launchpad.net.kolla) + +{% if install_type == 'binary' %} + {% if base_distro in ['centos', 'fedora', 'oraclelinux'] %} + +RUN yum -y install openstack-neutron \ + openstack-neutron-ml2 \ + openvswitch \ + && yum clean all + +# TODO (sdake): remove once RDO adds to the openstack-neutron package +RUN pip install oslo.versionedobjects + + {% elif base_distro in ['ubuntu', 'debian'] %} + +RUN echo '{{ install_type}} not yet available for {{ base_distro }}' \ + && /bin/false + + {% endif %} +{% elif install_type == 'source' %} + {% if base_distro in ['ubuntu', 'debian'] %} + +RUN apt-get install -y --no-install-recommends \ + iptables \ + dnsmasq \ + uuid-runtime \ + ipset \ + openvswitch-switch \ + && apt-get clean + + {% endif %} + +ADD neutron.tar / +RUN ln -s /neutron-* neutron \ + && useradd --user-group neutron \ + && pip --no-cache-dir install /neutron \ + && mkdir -p /etc/neutron /usr/share/neutron /var/log/neutron /home/neutron \ + && cp -r /neutron/etc/* /etc/neutron/ \ + && cp -r /neutron/etc/neutron/* /etc/neutron/ \ + && cp /neutron/etc/api-paste.ini /usr/share/neutron \ + && mv /etc/neutron/neutron/ /etc/neutron/plugins/ \ + && chown -R neutron: /etc/neutron /usr/share/neutron /var/log/neutron /home/neutron + +{% endif %} + +COPY config-sudoers.sh /opt/kolla/ diff --git a/docker/neutron/neutron-base/config-sudoers.sh b/docker/neutron/neutron-base/config-sudoers.sh new file mode 100644 index 000000000..82cf0d624 --- /dev/null +++ b/docker/neutron/neutron-base/config-sudoers.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# Neutron uses rootwrap which requires a tty for sudo. +# Since the container is running in daemon mode, a tty +# is not present and requiretty must be commented out. +if [ ! -f /sudo-modified ]; then + chmod 0640 /etc/sudoers + sed -i '/Defaults requiretty/s/^/#/' /etc/sudoers + chmod 0440 /etc/sudoers +fi + +touch /sudo-modified diff --git a/docker/neutron/neutron-base/ip_wrapper.py b/docker/neutron/neutron-base/ip_wrapper.py new file mode 100755 index 000000000..591fca6f4 --- /dev/null +++ b/docker/neutron/neutron-base/ip_wrapper.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python + +# Copyright 2015 Sam Yaple +# +# 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. + +# This file exists because we want to create and delete any network +# namespaces from the host mount namespace. This allows the host to +# access all of the neutron network namespaces as well as all +# containers that bind mount /run/netns from the host. + +# This is required for "thin" neutron containers to function properly + +import nsenter +import subprocess +import sys + + +def host_mnt_exec(cmd): + try: + with nsenter.ExitStack() as stack: + stack.enter_context( + nsenter.Namespace( + '1', + 'mnt', + proc='/opt/kolla/host_proc/')) + process_ = subprocess.Popen(cmd) + + except Exception as e: + print( + "An error has occured with a component that Kolla manages." + " Please file a bug") + print("Error: ", e) + + return process_ + + +if len(sys.argv) > 2: + # We catch all commands that ip will accept that refer + # to creating or deleteing a Network namespace + if str(sys.argv[1]).startswith("net") and ( + str(sys.argv[2]).startswith("a") or + str(sys.argv[2]).startswith("d")): + # This cmd is executed in the host mount namespace + cmd = ["/usr/bin/env", "ip"] + sys.argv[1:] + sys.exit(host_mnt_exec(cmd).returncode) + else: + cmd = ["/opt/kolla/ip"] + sys.argv[1:] +else: + cmd = ["/opt/kolla/ip"] + + if len(sys.argv) == 2: + cmd = cmd + sys.argv[1:] + +process_ = subprocess.Popen(cmd) +sys.exit(process_.returncode) |
