labs: unified login/password handling
The labs scripts need two sets of login/password for each service: one for the (MySQL) database used by the service, and one for authentication with keystone. For the labs scripts login names and passwords are simple functions of the service names: for the first set (database), we have ${service}User/${service}Pass, for the second set (keystone auth) ${service}/${service}_pass. This changeset adds two functions for producing the second set of credentials and renames the existing functions (as well as related variables) for producing the first set. This prevents us from having to store login names and passwords in the service scripts. It also keeps those things in one location where they can be changed easily should we ever want to do so. Implements: blueprint openstack-training-labs Change-Id: I730eab475bee843767984b6c64bab88a94c0156e
This commit is contained in:
parent
41e0a4a2a3
commit
8aab6f82de
@ -155,22 +155,38 @@ function mysql_exe {
|
||||
|
||||
function setup_database {
|
||||
local service=$1
|
||||
local user_name=$(service_to_user_name $service)
|
||||
local user_password=$(service_to_user_password $service)
|
||||
local db_user=$(service_to_db_user $service)
|
||||
local db_password=$(service_to_db_password $service)
|
||||
mysql_exe "CREATE DATABASE $service"
|
||||
mysql_exe "GRANT ALL ON ${service}.* TO '$user_name'@'%' IDENTIFIED BY '$user_password';"
|
||||
mysql_exe "GRANT ALL ON ${service}.* TO '$db_user'@'%' IDENTIFIED BY '$db_password';"
|
||||
}
|
||||
|
||||
function service_to_user_name {
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Users for service-specific MySQL databases
|
||||
|
||||
function service_to_db_user {
|
||||
local service_name=$1
|
||||
echo "${service_name}User"
|
||||
}
|
||||
|
||||
function service_to_user_password {
|
||||
function service_to_db_password {
|
||||
local service_name=$1
|
||||
echo "${service_name}Pass"
|
||||
}
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Service-specific users in keystone
|
||||
|
||||
function service_to_user_name {
|
||||
local service_name=$1
|
||||
echo "${service_name}"
|
||||
}
|
||||
|
||||
function service_to_user_password {
|
||||
local service_name=$1
|
||||
echo "${service_name}_pass"
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Network configuration
|
||||
#-------------------------------------------------------------------------------
|
||||
|
@ -22,11 +22,11 @@ echo "Setting up database for keystone."
|
||||
setup_database keystone
|
||||
|
||||
function get_database_url {
|
||||
local user_name=$(service_to_user_name keystone)
|
||||
local user_password=$(service_to_user_password keystone)
|
||||
local db_user=$(service_to_db_user keystone)
|
||||
local db_password=$(service_to_db_password keystone)
|
||||
local database_host=controller-mgmt
|
||||
|
||||
echo "mysql://$user_name:$user_password@$database_host/keystone"
|
||||
echo "mysql://$db_user:$db_password@$database_host/keystone"
|
||||
}
|
||||
|
||||
database_url=$(get_database_url)
|
||||
|
Loading…
x
Reference in New Issue
Block a user