58 lines
1.8 KiB
Bash
Executable File
58 lines
1.8 KiB
Bash
Executable File
#!/bin/bash
|
|
set -eux
|
|
|
|
db_pass=$(os-apply-config --key db-password)
|
|
|
|
PATH=/usr/local/bin:$PATH
|
|
|
|
# create the database for the specifed service.db config key
|
|
# optionally use a second default dsn parameter if key no found
|
|
function create_db_from_config() {
|
|
dsn=$(os-apply-config --key $1 --type dsn --key-default '')
|
|
if [ -z "$dsn" -a -n "${2:-}" ]; then
|
|
echo "No configuration found for $1, using default of $2"
|
|
dsn=$2
|
|
fi
|
|
if [ -n "$dsn" ]; then
|
|
part=${dsn##*://}
|
|
part=${part%%\?*}
|
|
database=${part##*/}
|
|
dsn_creds=${part%%@*}
|
|
dsn_user=${dsn_creds%%:*}
|
|
dsn_pass=${dsn_creds##*:}
|
|
os-db-create $database $dsn_user $dsn_pass
|
|
else
|
|
echo "No configuration found for $1, skipping db create"
|
|
fi
|
|
}
|
|
|
|
create_db_from_config "keystone.db" "mysql://keystone:${db_pass}@localhost/keystone"
|
|
|
|
if which cinder-manage 1>/dev/null 2>&1; then
|
|
create_db_from_config "cinder.db" "mysql://cinder:${db_pass}@localhost/cinder"
|
|
fi
|
|
|
|
if which ironic-dbsync 1>/dev/null 2>&1; then
|
|
create_db_from_config "ironic.db" "mysql://ironic:${db_pass}@localhost/ironic"
|
|
fi
|
|
|
|
if which tuskar-dbsync 1>/dev/null 2>&1; then
|
|
create_db_from_config "tuskar.db" "mysql://tuskar:${db_pass}@localhost/tuskar"
|
|
fi
|
|
|
|
if which ceilometer-dbsync 1>/dev/null 2>&1; then
|
|
create_db_from_config "ceilometer.db" "mysql://ceilometer:${db_pass}@localhost/ceilometer"
|
|
fi
|
|
|
|
create_db_from_config "nova.db" "mysql://nova:${db_pass}@localhost/nova"
|
|
|
|
if which nova-baremetal-manage 1>/dev/null 2>&1; then
|
|
create_db_from_config "nova.baremetal.db" "mysql://nova_bm:${db_pass}@localhost/nova_bm"
|
|
fi
|
|
|
|
create_db_from_config "glance.db" "mysql://glance:${db_pass}@localhost/glance"
|
|
|
|
create_db_from_config "heat.db" "mysql://heat:${db_pass}@localhost/heat"
|
|
|
|
create_db_from_config "neutron.ovs_db" "mysql://neutron:${db_pass}@localhost/ovs_neutron"
|