From 7ca1e19e06c8f094b13ece32fe6058e878e88c5f Mon Sep 17 00:00:00 2001
From: Sam Yaple <sam@yaple.net>
Date: Sat, 22 Aug 2015 13:40:20 +0000
Subject: [PATCH] Ubuntu - Neutron

Make the changes needed to support Ubuntu

Additionally, adjust the way supervisor is installed. Rather than
installing via pip, install via a package.

Change-Id: I1e7f538a180e4e35166d5afa8ba3f165b7e9f6d5
Partially-Implements: blueprint install-from-ubuntu
Closes-Bug: #1487715
---
 .../neutron/neutron-agents/supervisord.conf    |  6 ------
 .../neutron/neutron-agents/Dockerfile.j2       | 16 +++++++++-------
 .../neutron/neutron-base/Dockerfile.j2         | 18 ++++++++++++++----
 .../neutron-linuxbridge-agent/Dockerfile.j2    |  7 +++++--
 .../neutron-openvswitch-agent/Dockerfile.j2    |  8 +++++---
 .../neutron/neutron-server/Dockerfile.j2       |  3 ++-
 6 files changed, 35 insertions(+), 23 deletions(-)

diff --git a/docker/common/neutron/neutron-agents/supervisord.conf b/docker/common/neutron/neutron-agents/supervisord.conf
index 2db1af2dc2..5cab8f5dcd 100644
--- a/docker/common/neutron/neutron-agents/supervisord.conf
+++ b/docker/common/neutron/neutron-agents/supervisord.conf
@@ -38,9 +38,3 @@ priority=40
 startsec=10
 stderr_events_enabled=true
 stdout_events_enabled=true
-
-[eventlistener:stdout]
-command = supervisor_stdout
-buffer_size = 100
-events = PROCESS_LOG
-result_handler = supervisor_stdout:event_handler
diff --git a/docker_templates/neutron/neutron-agents/Dockerfile.j2 b/docker_templates/neutron/neutron-agents/Dockerfile.j2
index 8c9b54d756..cb4cec403f 100644
--- a/docker_templates/neutron/neutron-agents/Dockerfile.j2
+++ b/docker_templates/neutron/neutron-agents/Dockerfile.j2
@@ -3,16 +3,18 @@ MAINTAINER Kolla Project (https://launchpad.net.kolla)
 
 {% if base_distro in ['centos', 'fedora', 'oraclelinux'] %}
 
-# Install supervisor
-RUN easy_install supervisor
+RUN yum install -y supervisor \
+    && yum clean all
 
-# Install supervisor-stdout
-RUN pip install supervisor-stdout
-
-# Configure supervisord
-RUN mkdir -p /var/log/supervisor/
 COPY supervisord.conf /etc/
 
+{% elif base_distro in ['ubuntu', 'debian'] %}
+
+RUN apt-get install -y --no-install-recommends supervisor \
+    && apt-get clean
+
+COPY supervisord.conf /etc/supervisor/
+
 {% endif %}
 
 # TODO: SamYaple FWaaS is part of the l3-agent, not a seperate agent that is
diff --git a/docker_templates/neutron/neutron-base/Dockerfile.j2 b/docker_templates/neutron/neutron-base/Dockerfile.j2
index 63d798b217..367d5daaea 100644
--- a/docker_templates/neutron/neutron-base/Dockerfile.j2
+++ b/docker_templates/neutron/neutron-base/Dockerfile.j2
@@ -18,8 +18,18 @@ 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
@@ -27,13 +37,13 @@ RUN ln -s /neutron-* /neutron
 RUN cd /neutron \
     && useradd --user-group neutron \
     && pip install -r requirements.txt \
-    && pip install /neutron \
-    && mkdir /etc/neutron /usr/share/neutron /var/log/neutron \
+    && pip install --install-option="--install-scripts=/usr/bin" /neutron \
+    && mkdir -p /etc/neutron /usr/share/neutron /var/log/neutron /home/neutron \
     && cp -r etc/* /etc/neutron/ \
     && cp -r etc/neutron/* /etc/neutron/ \
     && cp etc/api-paste.ini /usr/share/neutron \
     && mv /etc/neutron/neutron/ /etc/neutron/plugins/ \
-    && chown -R neutron: /etc/neutron /var/log/neutron \
+    && chown -R neutron: /etc/neutron /var/log/neutron /home/neutron \
     && rm -rf /root/.cache
 
 {% endif %}
diff --git a/docker_templates/neutron/neutron-linuxbridge-agent/Dockerfile.j2 b/docker_templates/neutron/neutron-linuxbridge-agent/Dockerfile.j2
index 5a9099848c..cdac55369f 100644
--- a/docker_templates/neutron/neutron-linuxbridge-agent/Dockerfile.j2
+++ b/docker_templates/neutron/neutron-linuxbridge-agent/Dockerfile.j2
@@ -5,16 +5,19 @@ MAINTAINER Kolla Project (https://launchpad.net.kolla)
     {% if base_distro in ['centos', 'fedora', 'oraclelinux'] %}
 
 # Install required packages
-RUN yum install -y ebtables openstack-neutron-linuxbridge \
+RUN yum install -y \
+        ebtables \
+        openstack-neutron-linuxbridge \
     && yum clean all
 
     {% endif %}
-
 {% elif install_type == 'source' %}
+    {% if base_distro in ['centos', 'fedora', 'oraclelinux'] %}
 
 # Install required packages
 RUN yum install -y ebtables && yum clean all
 
+    {% endif %}
 {% endif %}
 
 COPY start.sh /
diff --git a/docker_templates/neutron/neutron-openvswitch-agent/Dockerfile.j2 b/docker_templates/neutron/neutron-openvswitch-agent/Dockerfile.j2
index af8816690d..977f53d230 100644
--- a/docker_templates/neutron/neutron-openvswitch-agent/Dockerfile.j2
+++ b/docker_templates/neutron/neutron-openvswitch-agent/Dockerfile.j2
@@ -5,13 +5,14 @@ MAINTAINER Kolla Project (https://launchpad.net.kolla)
     {% if base_distro in ['centos', 'fedora', 'oraclelinux'] %}
 
 # Install required packages
-RUN yum install -y openstack-neutron-openvswitch \
-                   openvswitch \
+RUN yum install -y \
+        openstack-neutron-openvswitch \
+        openvswitch \
     && yum clean all
 
     {% endif %}
-
 {% elif install_type == 'source' %}
+    {% if base_distro in ['centos', 'fedora', 'oraclelinux'] %}
 
 # Install required packages
 RUN yum install -y \
@@ -20,6 +21,7 @@ RUN yum install -y \
         openvswitch \
     && yum clean all
 
+    {% endif %}
 {% endif %}
 
 COPY start.sh /
diff --git a/docker_templates/neutron/neutron-server/Dockerfile.j2 b/docker_templates/neutron/neutron-server/Dockerfile.j2
index a8febf9557..0c4a2cfa15 100644
--- a/docker_templates/neutron/neutron-server/Dockerfile.j2
+++ b/docker_templates/neutron/neutron-server/Dockerfile.j2
@@ -13,13 +13,14 @@ RUN yum install -y which \
 RUN pip install oslo.messaging==2.2.0
 
     {% endif %}
-
 {% elif install_type == 'source' %}
+    {% if base_distro in ['centos', 'fedora', 'oraclelinux'] %}
 
 #Install required packages
 RUN yum install -y which \
     && yum clean all
 
+    {% endif %}
 {% endif %}
 
 COPY start.sh /