summaryrefslogtreecommitdiff
path: root/openstack/usr/share/openstack/openstack-glance-setup
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2015-03-23 21:06:52 +0000
committerRichard Maw <richard.maw@codethink.co.uk>2015-03-23 22:57:47 +0000
commitee53974ddc864535bbc99302d16da11287affe47 (patch)
tree4cc8ed4c1b56401a7b5c4ced41ccca34ef8d4aad /openstack/usr/share/openstack/openstack-glance-setup
parent4a4e7610d52e9288b08fc04c0d704e354b76c61b (diff)
downloaddefinitions-ee53974ddc864535bbc99302d16da11287affe47.tar.gz
WIP: Add OpenStack initial configuration
TODO: Split this out into: 1. initial config (openstack/etc) default values 2+. as many individual changes to initial config as possible to extract, including support scripts and configuration extensions
Diffstat (limited to 'openstack/usr/share/openstack/openstack-glance-setup')
-rw-r--r--openstack/usr/share/openstack/openstack-glance-setup89
1 files changed, 89 insertions, 0 deletions
diff --git a/openstack/usr/share/openstack/openstack-glance-setup b/openstack/usr/share/openstack/openstack-glance-setup
new file mode 100644
index 00000000..1363a7b7
--- /dev/null
+++ b/openstack/usr/share/openstack/openstack-glance-setup
@@ -0,0 +1,89 @@
+#!/bin/sh
+#
+# Copyright (C) 2014 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, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+set -e
+
+# Create required system users and groups
+getent group glance >/dev/null || groupadd -r --gid 164 glance
+getent passwd glance >/dev/null || \
+ useradd --uid 164 -r -g glance -d /var/lib/glance -s /sbin/nologin \
+ -c "OpenStack Glance Daemons" glance
+
+# Create required keystone tenants, users and roles
+export OS_SERVICE_TOKEN=##KEYSTONE_TEMPORARY_ADMIN_TOKEN##
+export OS_SERVICE_ENDPOINT='http://onenode:35357/v2.0'
+
+keystone user-create --name ##GLANCE_SERVICE_USER## --pass ##GLANCE_SERVICE_PASSWORD##
+keystone user-role-add --tenant service --user ##GLANCE_SERVICE_USER## --role admin
+
+keystone service-create --name glance --type image --description "OpenStack Image Service"
+keystone endpoint-create --service-id $(keystone service-list | awk '/ image / {print $2}') \
+ --publicurl ##GLANCE_PUBLIC_URL## \
+ --internalurl ##GLANCE_INTERNAL_URL## \
+ --adminurl ##GLANCE_ADMIN_URL##
+
+# Create run directory for glance
+if [ ! -d /var/run/glance ]; then
+ mkdir -p /var/run/glance
+ chown -R glance:glance /var/run/glance
+fi
+
+# Create the lock directory for glance
+if [ ! -d /var/lock/glance ]; then
+ mkdir -p /var/lock/glance
+ chown -R glance:glance /var/lock/glance
+fi
+
+# Create the log directory for glance
+if [ ! -d /var/log/glance ]; then
+ mkdir -p /var/log/glance
+ chown -R glance:glance /var/log/glance
+fi
+
+# Setup the glance database
+if ! sudo -u postgres psql -lqt | grep -q glance; then
+ # Create posgreSQL user
+ sudo -u postgres createuser \
+ --pwprompt --encrypted \
+ --no-adduser --no-createdb \
+ --no-password \
+ ##GLANCE_DB_USER##
+
+ sudo -u postgres createdb \
+ --owner=##GLANCE_DB_USER## \
+ glance
+
+ sudo -u glance glance-manage db_sync
+fi
+
+chown -R glance:glance /var/lib/glance
+
+# Remove the one-shot setup service
+rm /etc/systemd/system/multi-user.target.wants/openstack-glance-setup.service
+
+# Start glance services
+systemctl start openstack-glance-api
+systemctl start openstack-glance-registry
+
+# Create the links to run glance services when system start next times.
+ln -s "/etc/systemd/system/openstack-glance-api.service" \
+ "/etc/systemd/system/multi-user.target.wants/openstack-glance-api.service"
+
+ln -s "/etc/systemd/system/openstack-glance-registry.service" \
+ "/etc/systemd/system/multi-user.target.wants/openstack-glance-registry.service"
+
+exit 0