diff options
Diffstat (limited to 'meta-openstack/recipes-devtools/python/python-cinder/cinder-init')
| -rw-r--r-- | meta-openstack/recipes-devtools/python/python-cinder/cinder-init | 57 |
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() | ||
| 10 | DB_USER=%DB_USER% | ||
| 11 | CINDER_USER=%CINDER_USER% | ||
| 12 | CINDER_GROUP=%CINDER_GROUP% | ||
| 13 | CONTROLLER_IP=%CONTROLLER_IP% | ||
| 14 | ADMIN_USER=%ADMIN_USER% | ||
| 15 | ADMIN_PASSWORD=%ADMIN_PASSWORD% | ||
| 16 | ADMIN_ROLE=%ADMIN_ROLE% | ||
| 17 | SYSCONFDIR=%SYSCONFDIR% | ||
| 18 | |||
| 19 | sudo -u postgres psql -c "CREATE DATABASE \"cinder\"" 2> /dev/null | ||
| 20 | sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE \"cinder\" TO ${DB_USER}" 2> /dev/null | ||
| 21 | |||
| 22 | source ${SYSCONFDIR}/keystone/admin-openrc | ||
| 23 | |||
| 24 | openstack user create --domain default --password ${ADMIN_PASSWORD} ${CINDER_USER} | ||
| 25 | |||
| 26 | # Ensure the 'service' project exists | ||
| 27 | openstack project show service > /dev/null 2>&1 | ||
| 28 | if [ $? -ne 0 ]; then | ||
| 29 | openstack project create service --domain default | ||
| 30 | fi | ||
| 31 | openstack role add --project service --user ${CINDER_USER} ${ADMIN_ROLE} | ||
| 32 | |||
| 33 | # Create cinderv2 service and service endpoints | ||
| 34 | openstack service create --name cinderv2 --description "OpenStack Block Storage" volumev2 | ||
| 35 | openstack endpoint create --region RegionOne volumev2 public http://${CONTROLLER_IP}:8776/v2/%\(project_id\)s | ||
| 36 | openstack endpoint create --region RegionOne volumev2 internal http://${CONTROLLER_IP}:8776/v2/%\(project_id\)s | ||
| 37 | openstack endpoint create --region RegionOne volumev2 admin http://${CONTROLLER_IP}:8776/v2/%\(project_id\)s | ||
| 38 | |||
| 39 | # Create cinderv3 service and service endpoints | ||
| 40 | openstack service create --name cinderv3 --description "OpenStack Block Storage" volumev3 | ||
| 41 | openstack endpoint create --region RegionOne volumev3 public http://${CONTROLLER_IP}:8776/v3/%\(project_id\)s | ||
| 42 | openstack endpoint create --region RegionOne volumev3 internal http://${CONTROLLER_IP}:8776/v3/%\(project_id\)s | ||
| 43 | openstack endpoint create --region RegionOne volumev3 admin http://${CONTROLLER_IP}:8776/v3/%\(project_id\)s | ||
| 44 | |||
| 45 | sudo -u ${CINDER_USER} cinder-manage db sync | ||
| 46 | |||
| 47 | # Enable cinder services now that they are configured | ||
| 48 | systemctl enable cinder-api | ||
| 49 | systemctl enable cinder-volume | ||
| 50 | systemctl enable cinder-backup | ||
| 51 | systemctl enable cinder-scheduler | ||
| 52 | |||
| 53 | # Start our services | ||
| 54 | systemctl start cinder-api | ||
| 55 | systemctl start cinder-volume | ||
| 56 | systemctl start cinder-backup | ||
| 57 | systemctl start cinder-scheduler | ||
