summaryrefslogtreecommitdiff
path: root/openstack-cinder.configure
diff options
context:
space:
mode:
authorPedro Alvarez <pedro.alvarez@codethink.co.uk>2015-04-14 08:52:51 +0000
committerPedro Alvarez <pedro.alvarez@codethink.co.uk>2015-04-16 16:25:42 +0000
commit93a6551b87e8a722b7d0f5b851a3c6c1f67da1e8 (patch)
treecb04527b382165ad9256326867f596c324c722b9 /openstack-cinder.configure
parent2abd264299f6bda6a512db75f4382b856da9f9e0 (diff)
downloaddefinitions-93a6551b87e8a722b7d0f5b851a3c6c1f67da1e8.tar.gz
Openstack: Make Cinder configurable
Change-Id: I9c2bb1a204a01fa82e90d517663f6cf654666395 Signed-off-by: Pedro Alvarez <pedro.alvarez@codethink.co.uk> Signed-off-by: Francisco Redondo Marchena <francisco.marchena@codethink.co.uk> Signed-off-by: Patrick Darley <patrick.darley@codethink.co.uk>
Diffstat (limited to 'openstack-cinder.configure')
-rw-r--r--openstack-cinder.configure88
1 files changed, 88 insertions, 0 deletions
diff --git a/openstack-cinder.configure b/openstack-cinder.configure
new file mode 100644
index 00000000..0c15bd23
--- /dev/null
+++ b/openstack-cinder.configure
@@ -0,0 +1,88 @@
+#!/bin/sh
+
+# Copyright (C) 2014-2015 Codethink Limited
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+
+set -e
+
+ROOT="$1"
+
+##########################################################################
+
+ln -sf "/usr/lib/systemd/system/openstack-cinder-setup.service" \
+ "$ROOT/etc/systemd/system/multi-user.target.wants/openstack-cinder-setup.service"
+
+##########################################################################
+# Check variables
+##########################################################################
+
+if [ -z "$RABBITMQ_HOST" -a \
+ -z "$RABBITMQ_PORT" -a \
+ -z "$RABBITMQ_USER" -a \
+ -z "$RABBITMQ_PASSWORD" -a \
+ -z "$KEYSTONE_TEMPORARY_ADMIN_TOKEN" -a \
+ -z "$CINDER_DB_USER" -a \
+ -z "$CINDER_DB_PASSWORD" -a \
+ -z "$CONTROLLER_HOST_ADDRESS" -a \
+ -z "$CINDER_SERVICE_USER" -a \
+ -z "$CINDER_SERVICE_PASSWORD" -a \
+ -z "$CINDER_DEVICE" -a \
+ -z "$MANAGEMENT_INTERFACE_IP_ADDRESS" ]; then
+ # No Cinder options defined, do nothing.
+ exit 0
+fi
+
+if [ -z "$RABBITMQ_HOST" -o \
+ -z "$RABBITMQ_PORT" -o \
+ -z "$RABBITMQ_USER" -o \
+ -z "$RABBITMQ_PASSWORD" -o \
+ -z "$KEYSTONE_TEMPORARY_ADMIN_TOKEN" -o \
+ -z "$CINDER_DB_USER" -o \
+ -z "$CINDER_DB_PASSWORD" -o \
+ -z "$CONTROLLER_HOST_ADDRESS" -o \
+ -z "$CINDER_SERVICE_USER" -o \
+ -z "$CINDER_SERVICE_PASSWORD" -o \
+ -z "$CINDER_DEVICE" -o \
+ -z "$MANAGEMENT_INTERFACE_IP_ADDRESS" ]; then
+ echo Some options required for Cinder were defined, but not all.
+ exit 1
+fi
+
+##########################################################################
+# Generate configuration file
+##########################################################################
+
+OPENSTACK_DATA="$ROOT/etc/openstack"
+mkdir -p "$OPENSTACK_DATA"
+
+python <<'EOF' >"$OPENSTACK_DATA/cinder.conf"
+import os, sys, yaml
+
+cinder_configuration={
+ 'RABBITMQ_HOST':os.environ['RABBITMQ_HOST'],
+ 'RABBITMQ_PORT':os.environ['RABBITMQ_PORT'],
+ 'RABBITMQ_USER':os.environ['RABBITMQ_USER'],
+ 'RABBITMQ_PASSWORD':os.environ['RABBITMQ_PASSWORD'],
+ 'KEYSTONE_TEMPORARY_ADMIN_TOKEN':os.environ['KEYSTONE_TEMPORARY_ADMIN_TOKEN'],
+ 'CINDER_DB_USER':os.environ['CINDER_DB_USER'],
+ 'CINDER_DB_PASSWORD':os.environ['CINDER_DB_PASSWORD'],
+ 'CONTROLLER_HOST_ADDRESS':os.environ['CONTROLLER_HOST_ADDRESS'],
+ 'CINDER_SERVICE_USER':os.environ['CINDER_SERVICE_USER'],
+ 'CINDER_SERVICE_PASSWORD':os.environ['CINDER_SERVICE_PASSWORD'],
+ 'CINDER_DEVICE':os.environ['CINDER_DEVICE'],
+ 'MANAGEMENT_INTERFACE_IP_ADDRESS':os.environ['MANAGEMENT_INTERFACE_IP_ADDRESS'],
+}
+
+yaml.dump(cinder_configuration, sys.stdout, default_flow_style=False)
+EOF