summaryrefslogtreecommitdiffstats
path: root/meta-openstack/recipes-devtools/python/python-cinder/cinder-init
diff options
context:
space:
mode:
Diffstat (limited to 'meta-openstack/recipes-devtools/python/python-cinder/cinder-init')
-rw-r--r--meta-openstack/recipes-devtools/python/python-cinder/cinder-init57
1 files changed, 57 insertions, 0 deletions
diff --git a/meta-openstack/recipes-devtools/python/python-cinder/cinder-init b/meta-openstack/recipes-devtools/python/python-cinder/cinder-init
new file mode 100644
index 0000000..e1a5758
--- /dev/null
+++ b/meta-openstack/recipes-devtools/python/python-cinder/cinder-init
@@ -0,0 +1,57 @@
1#!/bin/bash
2#
3# Basic cinder setup based on:
4# https://docs.openstack.org/cinder/pike/install/cinder-controller-install-ubuntu.html
5#
6# Prerequisites: keystone must be available and bootstrapped
7#
8
9# Substitutions setup at do_intall()
10DB_USER=%DB_USER%
11CINDER_USER=%CINDER_USER%
12CINDER_GROUP=%CINDER_GROUP%
13CONTROLLER_IP=%CONTROLLER_IP%
14ADMIN_USER=%ADMIN_USER%
15ADMIN_PASSWORD=%ADMIN_PASSWORD%
16ADMIN_ROLE=%ADMIN_ROLE%
17SYSCONFDIR=%SYSCONFDIR%
18
19sudo -u postgres psql -c "CREATE DATABASE \"cinder\"" 2> /dev/null
20sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE \"cinder\" TO ${DB_USER}" 2> /dev/null
21
22source ${SYSCONFDIR}/keystone/admin-openrc
23
24openstack user create --domain default --password ${ADMIN_PASSWORD} ${CINDER_USER}
25
26# Ensure the 'service' project exists
27openstack project show service > /dev/null 2>&1
28if [ $? -ne 0 ]; then
29 openstack project create service --domain default
30fi
31openstack role add --project service --user ${CINDER_USER} ${ADMIN_ROLE}
32
33# Create cinderv2 service and service endpoints
34openstack service create --name cinderv2 --description "OpenStack Block Storage" volumev2
35openstack endpoint create --region RegionOne volumev2 public http://${CONTROLLER_IP}:8776/v2/%\(project_id\)s
36openstack endpoint create --region RegionOne volumev2 internal http://${CONTROLLER_IP}:8776/v2/%\(project_id\)s
37openstack endpoint create --region RegionOne volumev2 admin http://${CONTROLLER_IP}:8776/v2/%\(project_id\)s
38
39# Create cinderv3 service and service endpoints
40openstack service create --name cinderv3 --description "OpenStack Block Storage" volumev3
41openstack endpoint create --region RegionOne volumev3 public http://${CONTROLLER_IP}:8776/v3/%\(project_id\)s
42openstack endpoint create --region RegionOne volumev3 internal http://${CONTROLLER_IP}:8776/v3/%\(project_id\)s
43openstack endpoint create --region RegionOne volumev3 admin http://${CONTROLLER_IP}:8776/v3/%\(project_id\)s
44
45sudo -u ${CINDER_USER} cinder-manage db sync
46
47# Enable cinder services now that they are configured
48systemctl enable cinder-api
49systemctl enable cinder-volume
50systemctl enable cinder-backup
51systemctl enable cinder-scheduler
52
53# Start our services
54systemctl start cinder-api
55systemctl start cinder-volume
56systemctl start cinder-backup
57systemctl start cinder-scheduler