From a6454f15f21064e6eb10a22d4b3fba957eace39f Mon Sep 17 00:00:00 2001
From: Paul Bourke <paul.bourke@oracle.com>
Date: Wed, 5 Aug 2015 15:19:38 +0000
Subject: [PATCH] Implement Murano source images

* Both api and engine start up without error, but can't test properly
until Horizon is fixed (bug #1482196)

* These are source installs are there no RPMs available for Murano
that I can find.

* Also requires a plugin for horizon that will be made as a
separate commit

Co-Authored-By: Mick Thompson <michael.a.thompson@oracle.com>
Implements: blueprint enable-murano-container

Change-Id: Ia46985b21bb5f6d7690501e7199800c8c7fcb51f
---
 compose/murano-api-engine.yml                 | 16 +++++++++++++
 .../source/murano/murano-api/Dockerfile       |  8 +++++++
 docker/centos/source/murano/murano-api/build  |  1 +
 .../murano/murano-api/config-external.sh      |  1 +
 .../centos/source/murano/murano-api/start.sh  |  1 +
 .../source/murano/murano-base/.buildinfo      | 10 ++++++++
 .../source/murano/murano-base/Dockerfile      | 15 ++++++++++++
 docker/centos/source/murano/murano-base/build |  1 +
 .../source/murano/murano-engine/Dockerfile    |  8 +++++++
 .../centos/source/murano/murano-engine/build  |  1 +
 .../murano/murano-engine/config-external.sh   |  1 +
 .../source/murano/murano-engine/start.sh      |  1 +
 .../murano/murano-api/config-external.sh      | 10 ++++++++
 docker/common/murano/murano-api/start.sh      | 20 ++++++++++++++++
 .../murano/murano-engine/config-external.sh   | 10 ++++++++
 docker/common/murano/murano-engine/start.sh   | 13 ++++++++++
 tools/genenv                                  | 24 +++++++++++++++++--
 17 files changed, 139 insertions(+), 2 deletions(-)
 create mode 100644 compose/murano-api-engine.yml
 create mode 100644 docker/centos/source/murano/murano-api/Dockerfile
 create mode 120000 docker/centos/source/murano/murano-api/build
 create mode 120000 docker/centos/source/murano/murano-api/config-external.sh
 create mode 120000 docker/centos/source/murano/murano-api/start.sh
 create mode 100644 docker/centos/source/murano/murano-base/.buildinfo
 create mode 100644 docker/centos/source/murano/murano-base/Dockerfile
 create mode 120000 docker/centos/source/murano/murano-base/build
 create mode 100644 docker/centos/source/murano/murano-engine/Dockerfile
 create mode 120000 docker/centos/source/murano/murano-engine/build
 create mode 120000 docker/centos/source/murano/murano-engine/config-external.sh
 create mode 120000 docker/centos/source/murano/murano-engine/start.sh
 create mode 100644 docker/common/murano/murano-api/config-external.sh
 create mode 100755 docker/common/murano/murano-api/start.sh
 create mode 100644 docker/common/murano/murano-engine/config-external.sh
 create mode 100755 docker/common/murano/murano-engine/start.sh

diff --git a/compose/murano-api-engine.yml b/compose/murano-api-engine.yml
new file mode 100644
index 0000000000..faf5e9ccd4
--- /dev/null
+++ b/compose/murano-api-engine.yml
@@ -0,0 +1,16 @@
+# NOTE(pbourke): no binary images for murano are available
+muranoapi:
+  image: kollaglue/centos-source-murano-api:latest
+  name: murano-api
+  restart: always
+  net: "host"
+  env_file:
+   - openstack.env
+
+muranoengine:
+  image: kollaglue/centos-source-murano-engine:latest
+  name: murano-engine
+  restart: always
+  net: "host"
+  env_file:
+   - openstack.env
diff --git a/docker/centos/source/murano/murano-api/Dockerfile b/docker/centos/source/murano/murano-api/Dockerfile
new file mode 100644
index 0000000000..a838fa8acd
--- /dev/null
+++ b/docker/centos/source/murano/murano-api/Dockerfile
@@ -0,0 +1,8 @@
+FROM %%KOLLA_NAMESPACE%%/%%KOLLA_PREFIX%%murano-base:%%KOLLA_TAG%%
+MAINTAINER Kolla Project (https://launchpad.net/kolla)
+
+COPY config-external.sh /opt/kolla/
+
+COPY start.sh /
+
+CMD ["/start.sh"]
diff --git a/docker/centos/source/murano/murano-api/build b/docker/centos/source/murano/murano-api/build
new file mode 120000
index 0000000000..ec19138031
--- /dev/null
+++ b/docker/centos/source/murano/murano-api/build
@@ -0,0 +1 @@
+../../../../../tools/build-docker-image
\ No newline at end of file
diff --git a/docker/centos/source/murano/murano-api/config-external.sh b/docker/centos/source/murano/murano-api/config-external.sh
new file mode 120000
index 0000000000..6b73e957f5
--- /dev/null
+++ b/docker/centos/source/murano/murano-api/config-external.sh
@@ -0,0 +1 @@
+../../../../common/murano/murano-api/config-external.sh
\ No newline at end of file
diff --git a/docker/centos/source/murano/murano-api/start.sh b/docker/centos/source/murano/murano-api/start.sh
new file mode 120000
index 0000000000..bcf6f43e7f
--- /dev/null
+++ b/docker/centos/source/murano/murano-api/start.sh
@@ -0,0 +1 @@
+../../../../common/murano/murano-api/start.sh
\ No newline at end of file
diff --git a/docker/centos/source/murano/murano-base/.buildinfo b/docker/centos/source/murano/murano-base/.buildinfo
new file mode 100644
index 0000000000..4806db1559
--- /dev/null
+++ b/docker/centos/source/murano/murano-base/.buildinfo
@@ -0,0 +1,10 @@
+# Build info specific to this image. All values can be overridden in .buildconf
+
+COMPONENT=murano
+SOURCE_INSTALL_AVAILABLE=1
+
+# Used for git install method
+: ${CLONE_FROM:=https://github.com/openstack/murano}
+
+# Used for curl install method
+: ${TARBALL_URI:=http://tarballs.openstack.org/murano/murano-master.tar.gz}
diff --git a/docker/centos/source/murano/murano-base/Dockerfile b/docker/centos/source/murano/murano-base/Dockerfile
new file mode 100644
index 0000000000..21de3ece3b
--- /dev/null
+++ b/docker/centos/source/murano/murano-base/Dockerfile
@@ -0,0 +1,15 @@
+FROM %%KOLLA_NAMESPACE%%/%%KOLLA_PREFIX%%base:%%KOLLA_TAG%%
+MAINTAINER Kolla Project (https://launchpad.net/kolla)
+
+ADD ./murano.tar /
+RUN ln -s /murano-* /murano
+
+RUN cd /murano \
+    && pip install -r requirements.txt \
+    && pip install /murano \
+    && mkdir /etc/murano \
+    && cd /murano \
+    && tox -e genconfig \
+    && cp -r etc/murano/* /etc/murano/ \
+    && cp etc/murano/murano.conf.sample /etc/murano/murano.conf \
+    && rm -rf /root/.cache
diff --git a/docker/centos/source/murano/murano-base/build b/docker/centos/source/murano/murano-base/build
new file mode 120000
index 0000000000..ec19138031
--- /dev/null
+++ b/docker/centos/source/murano/murano-base/build
@@ -0,0 +1 @@
+../../../../../tools/build-docker-image
\ No newline at end of file
diff --git a/docker/centos/source/murano/murano-engine/Dockerfile b/docker/centos/source/murano/murano-engine/Dockerfile
new file mode 100644
index 0000000000..a838fa8acd
--- /dev/null
+++ b/docker/centos/source/murano/murano-engine/Dockerfile
@@ -0,0 +1,8 @@
+FROM %%KOLLA_NAMESPACE%%/%%KOLLA_PREFIX%%murano-base:%%KOLLA_TAG%%
+MAINTAINER Kolla Project (https://launchpad.net/kolla)
+
+COPY config-external.sh /opt/kolla/
+
+COPY start.sh /
+
+CMD ["/start.sh"]
diff --git a/docker/centos/source/murano/murano-engine/build b/docker/centos/source/murano/murano-engine/build
new file mode 120000
index 0000000000..ec19138031
--- /dev/null
+++ b/docker/centos/source/murano/murano-engine/build
@@ -0,0 +1 @@
+../../../../../tools/build-docker-image
\ No newline at end of file
diff --git a/docker/centos/source/murano/murano-engine/config-external.sh b/docker/centos/source/murano/murano-engine/config-external.sh
new file mode 120000
index 0000000000..1c8e0612cc
--- /dev/null
+++ b/docker/centos/source/murano/murano-engine/config-external.sh
@@ -0,0 +1 @@
+../../../../common/murano/murano-engine/config-external.sh
\ No newline at end of file
diff --git a/docker/centos/source/murano/murano-engine/start.sh b/docker/centos/source/murano/murano-engine/start.sh
new file mode 120000
index 0000000000..a4b0147fba
--- /dev/null
+++ b/docker/centos/source/murano/murano-engine/start.sh
@@ -0,0 +1 @@
+../../../../common/murano/murano-engine/start.sh
\ No newline at end of file
diff --git a/docker/common/murano/murano-api/config-external.sh b/docker/common/murano/murano-api/config-external.sh
new file mode 100644
index 0000000000..5d9a2da497
--- /dev/null
+++ b/docker/common/murano/murano-api/config-external.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+SOURCE="/opt/kolla/murano/murano.conf"
+TARGET="/etc/murano/murano.conf"
+OWNER="murano"
+
+if [[ -f "$SOURCE" ]]; then
+    cp $SOURCE $TARGET
+    chown ${OWNER}: $TARGET
+    chmod 0644 $TARGET
+fi
diff --git a/docker/common/murano/murano-api/start.sh b/docker/common/murano/murano-api/start.sh
new file mode 100755
index 0000000000..7d712177d0
--- /dev/null
+++ b/docker/common/murano/murano-api/start.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+set -o errexit
+
+CMD="/usr/bin/murano-api"
+ARGS="--config-file /etc/murano/murano.conf"
+
+# Loading common functions.
+source /opt/kolla/kolla-common.sh
+
+# Execute config strategy
+set_configs
+
+# Bootstrap and exit if KOLLA_BOOTSTRAP variable is set. This catches all cases
+# of the KOLLA_BOOTSTRAP variable being set, including empty.
+if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then
+    su -s /bin/sh -c "murano-db-manage --config-file /etc/murano/murano.conf upgrade" murano
+    exit 0
+fi
+
+exec $CMD $ARGS
diff --git a/docker/common/murano/murano-engine/config-external.sh b/docker/common/murano/murano-engine/config-external.sh
new file mode 100644
index 0000000000..5d9a2da497
--- /dev/null
+++ b/docker/common/murano/murano-engine/config-external.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+SOURCE="/opt/kolla/murano/murano.conf"
+TARGET="/etc/murano/murano.conf"
+OWNER="murano"
+
+if [[ -f "$SOURCE" ]]; then
+    cp $SOURCE $TARGET
+    chown ${OWNER}: $TARGET
+    chmod 0644 $TARGET
+fi
diff --git a/docker/common/murano/murano-engine/start.sh b/docker/common/murano/murano-engine/start.sh
new file mode 100755
index 0000000000..22834fc4c1
--- /dev/null
+++ b/docker/common/murano/murano-engine/start.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+set -o errexit
+
+CMD="/usr/bin/murano-engine"
+ARGS="--config-file /etc/murano/murano.conf"
+
+# Loading common functions.
+source /opt/kolla/kolla-common.sh
+
+# Execute config strategy
+set_configs
+
+exec $CMD $ARGS
diff --git a/tools/genenv b/tools/genenv
index c9d8b7a747..050df7f3cf 100755
--- a/tools/genenv
+++ b/tools/genenv
@@ -57,6 +57,7 @@ INIT_CINDER_DB=true
 INIT_CONNECT="SET NAMES utf8"
 INIT_DESIGNATE_DB=true
 INIT_GLANCE_DB=true
+INIT_MURANO_DB=true
 INIT_HEAT_DB=true
 INIT_KEYSTONE_DB=true
 INIT_NOVA_DB=true
@@ -110,7 +111,7 @@ RABBITMQ_CLUSTER_NODES=
 RABBITMQ_SERVICE_HOST=$HOST_IP
 RABBITMQ_SERVICE_PORT=5672
 RABBIT_PASSWORD=guest
-RABBIT_USER=guest
+RABBITMQ_USER=guest
 
 #Barbican
 ADMIN_TENANT_NAME=admin
@@ -255,6 +256,16 @@ MAGNUM_KEYSTONE_PASSWORD=magnum
 MAGNUM_API_SERVICE_HOST=$HOST_IP
 MAGNUM_API_SERVICE_PORT=9511
 
+# Murano
+MURANO_DB_NAME=murano
+MURANO_DB_PASSWORD=murano
+MURANO_DB_USER=murano
+MURANO_HOST_IP=$HOST_IP
+MURANO_KEYSTONE_PASSWORD=password
+MURANO_KEYSTONE_USER=murano
+MURANO_SERVICE_PORT=8082
+MURANO_SERVICE_PROTOCOL=http
+
 # Neutron
 NEUTRON_DB_NAME=neutron
 NEUTRON_DB_USER=neutron
@@ -498,6 +509,7 @@ INIT_CINDER_DB=$INIT_CINDER_DB
 INIT_CONNECT=$INIT_CONNECT
 INIT_DESIGNATE_DB=$INIT_DESIGNATE_DB
 INIT_GLANCE_DB=$INIT_GLANCE_DB
+INIT_MURANO_DB=$INIT_MURANO_DB
 INIT_HEAT_DB=$INIT_HEAT_DB
 INIT_KEYSTONE_DB=$INIT_KEYSTONE_DB
 INIT_NOVA_DB=$INIT_NOVA_DB
@@ -534,6 +546,14 @@ MARIADB_SERVICE_PORT=$MARIADB_SERVICE_PORT
 MECHANISM_DRIVERS=$MECHANISM_DRIVERS
 METADATA_HOST=$METADATA_HOST
 MONGODB_SERVICE_PORT=$MONGODB_SERVICE_PORT
+MURANO_DB_NAME=$MURANO_DB_NAME
+MURANO_DB_PASSWORD=$MURANO_DB_PASSWORD
+MURANO_DB_USER=$MURANO_DB_USER
+MURANO_HOST_IP=$MURANO_HOST_IP
+MURANO_KEYSTONE_PASSWORD=$MURANO_KEYSTONE_PASSWORD
+MURANO_KEYSTONE_USER=$MURANO_KEYSTONE_USER
+MURANO_SERVICE_PORT=$MURANO_SERVICE_PORT
+MURANO_SERVICE_PROTOCOL=$MURANO_SERVICE_PROTOCOL
 NETWORK_MANAGER=$NETWORK_MANAGER
 NEUTRON_API_PASTE_CONFIG=$NEUTRON_API_PASTE_CONFIG
 NEUTRON_DB_NAME=$NEUTRON_DB_NAME
@@ -586,7 +606,7 @@ RABBITMQ_CLUSTER_NODES=$RABBITMQ_CLUSTER_NODES
 RABBITMQ_PASS=$RABBIT_PASSWORD
 RABBITMQ_SERVICE_HOST=$RABBITMQ_SERVICE_HOST
 RABBITMQ_SERVICE_PORT=$RABBITMQ_SERVICE_PORT
-RABBITMQ_USER=$RABBIT_USER
+RABBITMQ_USER=$RABBITMQ_USER
 RABBIT_PASSWORD=$RABBIT_PASSWORD
 RABBIT_USERID=$RABBIT_USER
 ROOT_HELPER=$ROOT_HELPER