From cbd42ca6e90cca2ff4b84f5e4e46224e6455e8b2 Mon Sep 17 00:00:00 2001 From: Sam Yaple Date: Fri, 28 Aug 2015 12:16:53 +0000 Subject: 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 --- docker/neutron/neutron-base/Dockerfile.j2 | 47 +++++++++++++++++++ docker/neutron/neutron-base/config-sudoers.sh | 12 +++++ docker/neutron/neutron-base/ip_wrapper.py | 66 +++++++++++++++++++++++++++ 3 files changed, 125 insertions(+) create mode 100644 docker/neutron/neutron-base/Dockerfile.j2 create mode 100644 docker/neutron/neutron-base/config-sudoers.sh create mode 100755 docker/neutron/neutron-base/ip_wrapper.py (limited to 'docker/neutron/neutron-base') 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) -- cgit v1.2.3