From a070839b1f61e1cdd7bbcb0b943cd1683f19f093 Mon Sep 17 00:00:00 2001
From: Sam Yaple <sam@yaple.net>
Date: Sat, 22 Aug 2015 11:46:47 +0000
Subject: [PATCH] Ubuntu - Nova

Makes the tweaks to get Nova working on Ubuntu properly

Change-Id: I812f8878650b6412781e991ba34cc6187d7ff994
Partially-Implements: blueprint install-from-ubuntu
---
 build.ini                                     |  5 +++++
 docker_templates/base/sources.list            |  8 ++++---
 docker_templates/nova/nova-base/Dockerfile.j2 | 22 ++++++++++---------
 .../nova/nova-compute/Dockerfile.j2           |  9 ++++++--
 .../nova/nova-libvirt/Dockerfile.j2           | 12 ++++++++--
 .../nova/nova-novncproxy/Dockerfile.j2        |  5 +++++
 6 files changed, 44 insertions(+), 17 deletions(-)

diff --git a/build.ini b/build.ini
index 0330fc00e5..4a64567cbf 100644
--- a/build.ini
+++ b/build.ini
@@ -58,6 +58,11 @@ type = url
 location = http://tarballs.openstack.org/nova/nova-master.tar.gz
 dest_filename = nova.tar
 
+[nova-novncproxy]
+type = url
+location = http://github.com/kanaka/noVNC/tarball/v0.5.1
+dest_filename = novnc.tar
+
 [swift-base]
 type = url
 location = http://tarballs.openstack.org/swift/swift-master.tar.gz
diff --git a/docker_templates/base/sources.list b/docker_templates/base/sources.list
index 331a3b1f09..ccb6f8d257 100644
--- a/docker_templates/base/sources.list
+++ b/docker_templates/base/sources.list
@@ -6,9 +6,11 @@ deb http://archive.ubuntu.com/ubuntu/ trusty-security main restricted universe m
 # Backports have a lower priority and must be explictly installed to be used
 deb http://archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
 
-# We need to add the Liberty repo for the updated packages they provide. The
-# main ones are qemu, libvirt, and openvswitch
-deb http://ubuntu-cloud.archive.canonical.com/ubuntu trusty-updates/liberty main
+# TODO(SamYaple): Switch this to the Liberty repo as soon as the update packages
+#                 and actually start signing them.
+# We need to add the Kilo repo for the updated packages they provide. The main
+# ones are qemu, libvirt, and openvswitch.
+deb http://ubuntu-cloud.archive.canonical.com/ubuntu trusty-updates/kilo main
 
 # MariaDB 10.0 repo
 deb http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.0/ubuntu trusty main
diff --git a/docker_templates/nova/nova-base/Dockerfile.j2 b/docker_templates/nova/nova-base/Dockerfile.j2
index 46ce0e2e0d..8e117e69e8 100644
--- a/docker_templates/nova/nova-base/Dockerfile.j2
+++ b/docker_templates/nova/nova-base/Dockerfile.j2
@@ -27,26 +27,28 @@ RUN yum -y install \
 
     {% elif base_distro in ['ubuntu', 'debian'] %}
 
-RUN echo '{{ install_type }} not yet available for {{ base_distro }}' \
-    && /bin/false
+RUN apt-get install -y --no-install-recommends \
+        iptables \
+        ebtables \
+        dnsmasq \
+        bridge-utils \
+        python-libvirt \
+        openssh-client \
+        openvswitch-switch \
+     && apt-get clean
 
     {% endif %}
 
-RUN pip install \
-    python-cinderclient \
-    python-keystoneclient
-
 ADD ./nova.tar /
 RUN ln -s /nova-* /nova
 
 RUN cd /nova \
     && useradd --user-group nova \
     && pip install -r requirements.txt \
-    && pip install /nova \
-    && tox -egenconfig \
-    && mkdir /etc/nova /var/log/nova \
+    && pip install --install-option="--install-scripts=/usr/bin" /nova \
+    && mkdir /etc/nova /var/log/nova /home/nova \
     && cp -r /nova/etc/nova/* /etc/nova/ \
-    && chown -R nova: /etc/nova /var/log/nova \
+    && chown -R nova: /etc/nova /var/log/nova /home/nova \
     && rm -rf /root/.cache
 
 {% endif %}
diff --git a/docker_templates/nova/nova-compute/Dockerfile.j2 b/docker_templates/nova/nova-compute/Dockerfile.j2
index 84dd5d3d8d..214cde4fe5 100644
--- a/docker_templates/nova/nova-compute/Dockerfile.j2
+++ b/docker_templates/nova/nova-compute/Dockerfile.j2
@@ -11,17 +11,22 @@ RUN yum -y install openstack-nova-compute \
 
     {% endif %}
 {% elif install_type == 'source' %}
+    {% if base_distro in ['fedora', 'centos', 'oraclelinux'] %}
 
 RUN yum -y install \
         sysfsutils \
         libvirt-python \
     && yum clean all
 
+    {% elif base_distro in ['ubuntu', 'debian'] %}
+
+RUN apt-get install -y --no-install-recommends qemu-utils \
+    && apt-get clean
+
+    {% endif %}
 {% endif %}
 
 COPY start.sh /
 COPY config-external.sh /opt/kolla/
 
-VOLUME [ "/sys/fs/cgroup" ]
-
 CMD ["/start.sh"]
diff --git a/docker_templates/nova/nova-libvirt/Dockerfile.j2 b/docker_templates/nova/nova-libvirt/Dockerfile.j2
index 691ec81335..29e0843c32 100644
--- a/docker_templates/nova/nova-libvirt/Dockerfile.j2
+++ b/docker_templates/nova/nova-libvirt/Dockerfile.j2
@@ -12,11 +12,19 @@ RUN yum -y install \
         libvirt-daemon-driver-lxc \
     && yum clean all
 
+{% elif base_distro in ['ubuntu', 'debian'] %}
+
+RUN apt-get install -y --no-install-recommends \
+        libvirt-bin \
+        dmidecode \
+        pm-utils \
+        qemu \
+        ebtables \
+    && apt-get clean
+
 {% endif %}
 
 COPY start.sh /
 COPY config-external.sh /opt/kolla/
 
-VOLUME [ "/sys/fs/cgroup" ]
-
 CMD ["/start.sh"]
diff --git a/docker_templates/nova/nova-novncproxy/Dockerfile.j2 b/docker_templates/nova/nova-novncproxy/Dockerfile.j2
index 58a4664bdd..4ddc7e6c36 100644
--- a/docker_templates/nova/nova-novncproxy/Dockerfile.j2
+++ b/docker_templates/nova/nova-novncproxy/Dockerfile.j2
@@ -18,6 +18,11 @@ RUN yum -y install \
         novnc \
     && yum clean all
 
+    {% elif base_distro in ['ubuntu', 'debian'] %}
+
+ADD novnc.tar /
+RUN ln -s /kanaka-noVNC-* /usr/share/novnc
+
     {% endif %}
 {% endif %}