summaryrefslogtreecommitdiffstats
path: root/meta-openstack/recipes-devtools/python/python-glance/glance-init
diff options
context:
space:
mode:
Diffstat (limited to 'meta-openstack/recipes-devtools/python/python-glance/glance-init')
-rw-r--r--meta-openstack/recipes-devtools/python/python-glance/glance-init42
1 files changed, 42 insertions, 0 deletions
diff --git a/meta-openstack/recipes-devtools/python/python-glance/glance-init b/meta-openstack/recipes-devtools/python/python-glance/glance-init
new file mode 100644
index 0000000..8551399
--- /dev/null
+++ b/meta-openstack/recipes-devtools/python/python-glance/glance-init
@@ -0,0 +1,42 @@
1#!/bin/bash
2#
3# Basic glance setup based on:
4# https://docs.openstack.org/glance/pike/install/install-debian.html
5#
6# Prerequisites: keystone must be available and bootstrapped
7#
8
9# Substitutions setup at do_intall()
10DB_USER=%DB_USER%
11GLANCE_USER=%GLANCE_USER%
12GLANCE_GROUP=%GLANCE_GROUP%
13CONTROLLER_IP=%CONTROLLER_IP%
14ADMIN_USER=%ADMIN_USER%
15ADMIN_PASSWORD=%ADMIN_PASSWORD%
16ADMIN_ROLE=%ADMIN_ROLE%
17SYSCONFDIR=%SYSCONFDIR%
18
19# Create the glance DB and grant the necessary permissions
20sudo -u postgres psql -c "CREATE DATABASE glance" 2> /dev/null
21sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE glance TO ${DB_USER}" 2> /dev/null
22
23source ${SYSCONFDIR}/keystone/admin-openrc
24
25openstack user create --domain default --password ${ADMIN_PASSWORD} ${GLANCE_USER}
26
27# Ensure the 'service' project exists
28openstack project show service > /dev/null 2>&1
29if [ $? -ne 0 ]; then
30 openstack project create service --domain default
31fi
32openstack role add --project service --user ${GLANCE_USER} ${ADMIN_ROLE}
33
34openstack service create --name glance --description "OpenStack Image" image
35openstack endpoint create --region RegionOne image public http://${CONTROLLER_IP}:9292
36openstack endpoint create --region RegionOne image internal http://${CONTROLLER_IP}:9292
37openstack endpoint create --region RegionOne image admin http://${CONTROLLER_IP}:9292
38
39sudo -u ${GLANCE_USER} glance-manage db_sync
40
41systemctl restart glance-registry
42systemctl restart glance-api