From 72d1ef47ddc5e44868c56633707b346281e9d41a Mon Sep 17 00:00:00 2001
From: Ryan Hallisey <rhallise@redhat.com>
Date: Tue, 14 Apr 2015 16:29:21 -0400
Subject: [PATCH] Add cinder into the docker compose setup

This patch adds the docker-compose files, updates the docs,
and adds cinder to the start command.

Implements: blueprint container-set-storage-operation

Change-Id: I5386851e2247c00696704dc26a8a286451d4bf59
---
 compose/cinder-api-scheduler.yml | 15 +++++++
 compose/cinder-backup.yml        |  9 +++++
 compose/cinder-volume.yml        | 18 +++++++++
 compose/nova-compute-network.yml |  2 +
 compose/nova-compute.yml         |  2 +
 docs/integration-guide.md        | 22 +++++++++-
 tools/genenv                     | 69 ++++++++++++++++++++++++++++++++
 tools/kolla                      |  3 ++
 8 files changed, 139 insertions(+), 1 deletion(-)
 create mode 100644 compose/cinder-api-scheduler.yml
 create mode 100644 compose/cinder-backup.yml
 create mode 100644 compose/cinder-volume.yml

diff --git a/compose/cinder-api-scheduler.yml b/compose/cinder-api-scheduler.yml
new file mode 100644
index 0000000000..86bbf53b6b
--- /dev/null
+++ b/compose/cinder-api-scheduler.yml
@@ -0,0 +1,15 @@
+cinderapi:
+   image: kollaglue/centos-rdo-cinder-api:latest
+   name: cinder-api
+   net: host
+   restart: always
+   env_file:
+    - openstack.env
+
+cinderscheduler:
+   image: kollaglue/centos-rdo-cinder-scheduler:latest
+   name: cinder-scheduler
+   net: host
+   restart: always
+   env_file:
+    - openstack.env
diff --git a/compose/cinder-backup.yml b/compose/cinder-backup.yml
new file mode 100644
index 0000000000..b7c82f339a
--- /dev/null
+++ b/compose/cinder-backup.yml
@@ -0,0 +1,9 @@
+cinderbackup:
+   image: kollaglue/centos-rdo-cinder-backup:latest
+   name: cinder-backup
+   net: host
+   restart: always
+   env_file:
+    - openstack.env
+   volumes:
+    - /dev:/dev
diff --git a/compose/cinder-volume.yml b/compose/cinder-volume.yml
new file mode 100644
index 0000000000..a1d601acf7
--- /dev/null
+++ b/compose/cinder-volume.yml
@@ -0,0 +1,18 @@
+cinderdata:
+  image: kollaglue/centos-rdo-cinder-data:latest
+  name: cinderdata
+  restart: on-failure
+
+cindervolume:
+   image: kollaglue/centos-rdo-cinder-volume:latest
+   name: cinder-volume
+   net: host
+   privileged: true
+   restart: always
+   env_file:
+    - openstack.env
+   volumes:
+    - /lib/modules:/lib/modules:ro
+    - /dev:/dev
+   volumes_from:
+    - cinderdata
diff --git a/compose/nova-compute-network.yml b/compose/nova-compute-network.yml
index 1f6392c5fd..7b8781e5fe 100644
--- a/compose/nova-compute-network.yml
+++ b/compose/nova-compute-network.yml
@@ -14,6 +14,7 @@ libvirt:
    volumes:
     - /run:/run
     - /sys/fs/cgroup:/sys/fs/cgroup
+    - /dev:/dev
    volumes_from:
     - computedata
 
@@ -43,5 +44,6 @@ novacompute:
    volumes:
     - /run:/run
     - /sys/fs/cgroup:/sys/fs/cgroup
+    - /dev:/dev
    volumes_from:
     - computedata
diff --git a/compose/nova-compute.yml b/compose/nova-compute.yml
index 766db52e99..297b5cf103 100644
--- a/compose/nova-compute.yml
+++ b/compose/nova-compute.yml
@@ -15,6 +15,7 @@ libvirt:
     - /run:/run
     - /sys/fs/cgroup:/sys/fs/cgroup
     - /lib/modules:/lib/modules:ro
+    - /dev:/dev
    volumes_from:
     - computedata
 
@@ -30,5 +31,6 @@ novacompute:
     - /run:/run
     - /sys/fs/cgroup:/sys/fs/cgroup
     - /lib/modules:/lib/modules:ro
+    - /dev:/dev
    volumes_from:
     - computedata
diff --git a/docs/integration-guide.md b/docs/integration-guide.md
index a1989eaf5f..d793686dc7 100644
--- a/docs/integration-guide.md
+++ b/docs/integration-guide.md
@@ -142,7 +142,27 @@ all containers.  This allows a simple method of ensuring every type of node
     DESIGNATE_SINK_NEUTRON_DOMAIN_NAME=<neutron.example.org.> - Name of domain used to create records from Neutron notifications
     DESIGNATE_SINK_NOVA_FORMATS=<("%(octet0)s-%(octet1)s-%(octet2)s-%(octet3)s.%(domain)s" "%(hostname)s.%(domain)s")> - List of formats for records that will be created by Nova handler
     DESIGNATE_SINK_NEUTRON_FORMATS=<("%(octet0)s-%(octet1)s-%(octet2)s-%(octet3)s.%(domain)s" "%(hostname)s.%(domain)s")> - List of formats for records that will be created by Neutron handler
-
+    CINDER_API_SERVICE_HOST=<IP> - The IP Address where the Cinder service is running
+    CINDER_API_SERVICE_PORT=<8776> - Port where Cinder operates
+    CINDER_API_SERVICE_LISTEN=<IP> - The IP Address where the Cinder API listens
+    CINDER_KEYSTONE_USER=<cinder> - Cinder Keystone User
+    CINDER_KEYSTONE_PASSWORD=<password> - The Cinder Keystone password
+    CINDER_ADMIN_PASSWORD=<password> - The Cinder password
+    CINDER_DB_NAME=<cinder> - Cinder's DB name
+    CINDER_DB_USER=<cinder> - User name of Cinder in the database
+    CINDER_DB_PASSWORD=<password> - Cinder DB password
+    CINDER_BACKUP_DRIVER=<driver> - The backup driver for Cinder
+    CINDER_BACKUP_MANAGER=<manager> - The backup manager for Cinder
+    CINDER_BACKUP_API_CLASS=<api> - The cinder-backup api class
+    CINDER_BACKUP_NAME_TEMPLATE=<template> - The naming template for Cinder backups
+    ISCSI_HELPER=<lioadm> - The ISCSI user tool to use
+    ISCSI_IP_ADDRESS=<IP> - The IP Address to connect to ISCSI
+    CINDER_LVM_LO_VOLUME_SIZE=<size> - The size of the volume group (4G)
+    CINDER_VOLUME_GROUP=<cinder-volumes> - The name of the volume group
+    CINDER_VOLUME_BACKEND_NAME=<LVM_iSCSI57> - The backend name for a given driver implementation
+    CINDER_VOLUME_DRIVER=<cinder.volume.drivers.lvm.LVMISCSIDriver> - The driver used for volume creation
+    CINDER_ENABLED_BACKEND=<lvm57> - A list of backend names to use
+    INIT_CINDER_DB=<true|false> - Initialize or update the cinder db
 
 [Minimum environment variable setup guide.](https://github.com/stackforge/kolla/blob/master/docs/minimal-environment-vars.md)
 
diff --git a/tools/genenv b/tools/genenv
index e182f66ed5..b1a13fd378 100755
--- a/tools/genenv
+++ b/tools/genenv
@@ -26,6 +26,7 @@ ADMIN_USER_PASSWORD=steakfordinner
 HOST_IP=$MY_IP
 MARIADB_ROOT_PASSWORD=kolla
 PASSWORD=12345
+INIT_CINDER_DB=true
 
 # Galera
 DB_CLUSTER_BIND_ADDRESS=0.0.0.0
@@ -53,6 +54,11 @@ NEUTRON_SERVER_LOG_FILE=
 NEUTRON_L3_AGENT_LOG_FILE=
 NEUTRON_LINUXBRIDGE_AGENT_LOG_FILE=
 NEUTRON_METADATA_AGENT_LOG_FILE=
+CINDER_LOG_DIR=
+CINDER_API_LOG_FILE=
+CINDER_VOLUME_LOG_FILE=
+CINDER_BACKUP_LOG_FILE=
+CINDER_SCHEDULER_LOG_FILE=
 
 # RabbitMQ
 RABBITMQ_SERVICE_HOST=$HOST_IP
@@ -157,6 +163,35 @@ DESIGNATE_SINK_NEUTRON_DOMAIN_NAME=neutron.example.org.
 DESIGNATE_SINK_NOVA_FORMATS=("%(octet0)s-%(octet1)s-%(octet2)s-%(octet3)s.%(domain)s" "%(hostname)s.%(domain)s")
 DESIGNATE_SINK_NEUTRON_FORMATS=("%(octet0)s-%(octet1)s-%(octet2)s-%(octet3)s.%(domain)s" "%(hostname)s.%(domain)s")
 
+# Cinder API
+CINDER_API_SERVICE_HOST=$HOST_IP
+CINDER_API_SERVICE_PORT=8776
+CINDER_API_SERVICE_LISTEN=$HOST_IP
+CINDER_KEYSTONE_USER=cinder
+CINDER_KEYSTONE_PASSWORD=password
+CINDER_ADMIN_PASSWORD=password
+
+# Cinder Scheduler
+CINDER_DB_NAME=cinder
+CINDER_DB_USER=cinder
+CINDER_DB_PASSWORD=password
+
+# Cinder Backup
+CINDER_BACKUP_MANAGER=cinder.backup.manager.BackupManager
+CINDER_BACKUP_API_CLASS=cinder.backup.api.API
+CINDER_BACKUP_NAME_TEMPLATE=backup-%s
+CINDER_BACKUP_DRIVER=cinder.backup.drivers.swift
+
+# Cinder Volume
+ISCSI_HELPER=lioadm
+ISCSI_IP_ADDRESS=$HOST_IP
+CINDER_LVM_LO_VOLUME_SIZE=4G
+CINDER_VOLUME_API_LISTEN=$HOST_IP
+CINDER_VOLUME_GROUP=cinder-volumes
+CINDER_VOLUME_BACKEND_NAME=LVM_iSCSI57
+CINDER_VOLUME_DRIVER=cinder.volume.drivers.lvm.LVMISCSIDriver
+CINDER_ENABLED_BACKEND=lvm57
+
 cat > ./openrc <<EOF
 export OS_AUTH_URL="http://${KEYSTONE_PUBLIC_SERVICE_HOST}:5000/v2.0"
 export OS_USERNAME=$ADMIN_TENANT_NAME
@@ -273,7 +308,41 @@ DB_CLUSTER_INIT_DB=$DB_CLUSTER_INIT_DB
 DB_CLUSTER_NAME=$DB_CLUSTER_NAME
 DB_CLUSTER_NODES=$DB_CLUSTER_NODES
 DB_CLUSTER_WSREP_METHOD=$DB_CLUSTER_WSREP_METHOD
+CINDER_API_SERVICE_HOST=$HOST_IP
+CINDER_API_SERVICE_PORT=$CINDER_API_SERVICE_PORT
+CINDER_API_SERVICE_LISTEN=$MY_IP
+CINDER_KEYSTONE_USER=$CINDER_KEYSTONE_USER
+CINDER_KEYSTONE_PASSWORD=$CINDER_KEYSTONE_PASSWORD
+CINDER_ADMIN_PASSWORD=$CINDER_ADMIN_PASSWORD
+CINDER_DB_NAME=$CINDER_DB_NAME
+CINDER_DB_USER=$CINDER_DB_USER
+CINDER_DB_PASSWORD=$CINDER_DB_PASSWORD
+CINDER_BACKUP_MANAGER=$CINDER_BACKUP_MANAGER
+CINDER_BACKUP_API_CLASS=$CINDER_BACKUP_API_CLASS
+CINDER_BACKUP_NAME_TEMPLATE=$CINDER_BACKUP_NAME_TEMPLATE
+ISCSI_HELPER=$ISCSI_HELPER
+ISCSI_IP_ADDRESS=$ISCSI_IP_ADDRESS
+CINDER_BACKUP_DRIVER=$CINDER_BACKUP_DRIVER
+CINDER_LVM_LO_VOLUME_SIZE=$CINDER_LVM_LO_VOLUME_SIZE
+CINDER_VOLUME_GROUP=$CINDER_VOLUME_GROUP
+CINDER_VOLUME_API_LISTEN=$CINDER_VOLUME_API_LISTEN
+CINDER_VOLUME_BACKEND_NAME=$CINDER_VOLUME_BACKEND_NAME
+CINDER_VOLUME_DRIVER=$CINDER_VOLUME_DRIVER
+CINDER_ENABLED_BACKEND=$CINDER_ENABLED_BACKEND
+CINDER_LOG_DIR=$CINDER_LOG_DIR
+CINDER_API_LOG_FILE=$CINDER_API_LOG_FILE
+CINDER_VOLUME_LOG_FILE=$CINDER_VOLUME_LOG_FILE
+CINDER_BACKUP_LOG_FILE=$CINDER_BACKUP_LOG_FILE
+CINDER_SCHEDULER_LOG_FILE=$CINDER_SCHEDULER_LOG_FILE
 EOF
 echo Please customize your FLAT_INTERFACE to a different network then your
 echo main network. The FLAT_INTERFACE is used for inter-VM communication.
 echo the FLAT_INTERFACE should not have an IP address assigned.
+# https://bugs.launchpad.net/kolla/+bug/1461635
+echo
+echo Cinder requires mounting /dev in the cinder-volume, nova-compute,
+echo and libvirt containers.  If /dev/pts/ptmx does not have proper permissions
+echo on the host, then libvirt will fail to boot an instance.
+echo This is a bug in Docker where it is not correctly mounting /dev/pts
+echo **Temporary fix**
+echo chmod 666 /dev/pts/ptmx
diff --git a/tools/kolla b/tools/kolla
index f21f198079..d100a82c2f 100755
--- a/tools/kolla
+++ b/tools/kolla
@@ -44,6 +44,9 @@ function process_all {
     process heat-api-engine
     process magnum-api-conductor
     process horizon
+    process cinder-api-scheduler
+    process cinder-backup
+    process cinder-volume
 }
 
 function check_selinux {