Merge "Deprecate DATABASE_TYPE and use_database"
This commit is contained in:
commit
d0b1c37816
@ -60,11 +60,12 @@ You can override environment variables used in `stack.sh` by creating file name
|
|||||||
# Database Backend
|
# Database Backend
|
||||||
|
|
||||||
Multiple database backends are available. The available databases are defined in the lib/databases directory.
|
Multiple database backends are available. The available databases are defined in the lib/databases directory.
|
||||||
To choose a database backend, add a line to your `localrc` like:
|
`mysql` is the default database, choose a different one by putting the following in `localrc`:
|
||||||
|
|
||||||
use_database postgresql
|
disable_service mysql
|
||||||
|
enable_service postgresql
|
||||||
|
|
||||||
By default, the mysql database backend is used.
|
`mysql` is the default database.
|
||||||
|
|
||||||
# RPC Backend
|
# RPC Backend
|
||||||
|
|
||||||
|
@ -1003,9 +1003,11 @@ function upload_image() {
|
|||||||
# $1 The name of the database backend to use (mysql, postgresql, ...)
|
# $1 The name of the database backend to use (mysql, postgresql, ...)
|
||||||
function use_database {
|
function use_database {
|
||||||
if [[ -z "$DATABASE_BACKENDS" ]]; then
|
if [[ -z "$DATABASE_BACKENDS" ]]; then
|
||||||
# The backends haven't initialized yet, just save the selection for now
|
# No backends registered means this is likely called from ``localrc``
|
||||||
|
# This is now deprecated usage
|
||||||
DATABASE_TYPE=$1
|
DATABASE_TYPE=$1
|
||||||
else
|
else
|
||||||
|
# This should no longer get called...here for posterity
|
||||||
use_exclusive_service DATABASE_BACKENDS DATABASE_TYPE $1
|
use_exclusive_service DATABASE_BACKENDS DATABASE_TYPE $1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
35
lib/database
35
lib/database
@ -2,9 +2,12 @@
|
|||||||
# Interface for interacting with different database backends
|
# Interface for interacting with different database backends
|
||||||
|
|
||||||
# Dependencies:
|
# Dependencies:
|
||||||
# DATABASE_BACKENDS variable must contain a list of available database backends
|
# ``ENABLED_SERVICES`` must be defined
|
||||||
# DATABASE_TYPE variable must be set
|
|
||||||
|
|
||||||
|
# ``DATABASE_BACKENDS`` will contain a list of available database backends
|
||||||
|
# after sourcing this file.
|
||||||
|
|
||||||
|
# This is a wrapper for the specific database backends available.
|
||||||
# Each database must implement four functions:
|
# Each database must implement four functions:
|
||||||
# recreate_database_$DATABASE_TYPE
|
# recreate_database_$DATABASE_TYPE
|
||||||
# install_database_$DATABASE_TYPE
|
# install_database_$DATABASE_TYPE
|
||||||
@ -23,8 +26,36 @@ function register_database {
|
|||||||
[ -z "$DATABASE_BACKENDS" ] && DATABASE_BACKENDS=$1 || DATABASE_BACKENDS+=" $1"
|
[ -z "$DATABASE_BACKENDS" ] && DATABASE_BACKENDS=$1 || DATABASE_BACKENDS+=" $1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Sourcing the database libs sets DATABASE_BACKENDS with the available list
|
||||||
for f in $TOP_DIR/lib/databases/*; do source $f; done
|
for f in $TOP_DIR/lib/databases/*; do source $f; done
|
||||||
|
|
||||||
|
# If ``DATABASE_TYPE`` is defined here it's because the user has it in ``localrc``
|
||||||
|
# or has called ``use_database``. Both are deprecated so let's fix it up for now.
|
||||||
|
if [[ -n $DATABASE_TYPE ]]; then
|
||||||
|
# This is now deprecated usage, set up a warning and try to be
|
||||||
|
# somewhat backward compatible for now.
|
||||||
|
DEPRECATED_TEXT="$DEPRECATED_TEXT\nThe database backend needs to be properly set in ENABLED_SERVICES; DATABASE_TYPE or use_database is deprecated localrc\n"
|
||||||
|
if [[ ! $ENABLED_SERVICES =~ $DATABASE_TYPE ]]; then
|
||||||
|
# It's not in enabled services but user has attempted to select a
|
||||||
|
# database, so just add it now
|
||||||
|
ENABLED_SERVICES+=,$DATABASE_TYPE
|
||||||
|
unset DATABASE_TYPE
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ``DATABASE_BACKENDS`` now contains a list of the supported databases
|
||||||
|
# Look in ``ENABLED_SERVICES`` to see if one has been selected
|
||||||
|
for db in $DATABASE_BACKENDS; do
|
||||||
|
# Set the type for the rest of the backend to use
|
||||||
|
if is_service_enabled $db; then
|
||||||
|
# Set this now for the rest of the database funtions
|
||||||
|
DATABASE_TYPE=$db
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
# If ``DATABASE_TYPE`` is unset here no database was selected
|
||||||
|
# This is not an error as multi-node installs will do this on the compute nodes
|
||||||
|
|
||||||
|
|
||||||
# Set the database type based on the configuration
|
# Set the database type based on the configuration
|
||||||
function initialize_database_backends {
|
function initialize_database_backends {
|
||||||
for backend in $DATABASE_BACKENDS; do
|
for backend in $DATABASE_BACKENDS; do
|
||||||
|
25
stack.sh
25
stack.sh
@ -83,11 +83,6 @@ fi
|
|||||||
source $TOP_DIR/lib/database
|
source $TOP_DIR/lib/database
|
||||||
source $TOP_DIR/lib/rpc_backend
|
source $TOP_DIR/lib/rpc_backend
|
||||||
|
|
||||||
# Validate database selection
|
|
||||||
# Since DATABASE_BACKENDS is now set, this also gets ENABLED_SERVICES
|
|
||||||
# properly configured for the database selection.
|
|
||||||
use_database $DATABASE_TYPE || echo "Invalid database '$DATABASE_TYPE'"
|
|
||||||
|
|
||||||
# Remove services which were negated in ENABLED_SERVICES
|
# Remove services which were negated in ENABLED_SERVICES
|
||||||
# using the "-" prefix (e.g., "-rabbit") instead of
|
# using the "-" prefix (e.g., "-rabbit") instead of
|
||||||
# calling disable_service().
|
# calling disable_service().
|
||||||
@ -419,13 +414,13 @@ FLAT_INTERFACE=${FLAT_INTERFACE-$GUEST_INTERFACE_DEFAULT}
|
|||||||
# Database Configuration
|
# Database Configuration
|
||||||
# ----------------------
|
# ----------------------
|
||||||
|
|
||||||
# To select between database backends, add a line to localrc like:
|
# To select between database backends, add the following to ``localrc``:
|
||||||
#
|
#
|
||||||
# use_database postgresql
|
# disable_service mysql
|
||||||
|
# enable_service postgresql
|
||||||
#
|
#
|
||||||
# The available database backends are defined in the ``DATABASE_BACKENDS``
|
# The available database backends are listed in ``DATABASE_BACKENDS`` after
|
||||||
# variable defined in stackrc. By default, MySQL is enabled as the database
|
# ``lib/database`` is sourced. ``mysql`` is the default.
|
||||||
# backend.
|
|
||||||
|
|
||||||
initialize_database_backends && echo "Using $DATABASE_TYPE database backend" || echo "No database enabled"
|
initialize_database_backends && echo "Using $DATABASE_TYPE database backend" || echo "No database enabled"
|
||||||
|
|
||||||
@ -509,11 +504,11 @@ function echo_summary() {
|
|||||||
if [ ! -z "$LAST_SPINNER_PID" ]; then
|
if [ ! -z "$LAST_SPINNER_PID" ]; then
|
||||||
printf "\b\b\bdone\n" >&3
|
printf "\b\b\bdone\n" >&3
|
||||||
fi
|
fi
|
||||||
echo -n $@ >&6
|
echo -n -e $@ >&6
|
||||||
spinner &
|
spinner &
|
||||||
LAST_SPINNER_PID=$!
|
LAST_SPINNER_PID=$!
|
||||||
else
|
else
|
||||||
echo $@ >&6
|
echo -e $@ >&6
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1364,9 +1359,9 @@ fi
|
|||||||
# Echo ``HOST_IP`` - useful for ``build_uec.sh``, which uses dhcp to give the instance an address
|
# Echo ``HOST_IP`` - useful for ``build_uec.sh``, which uses dhcp to give the instance an address
|
||||||
echo "This is your host ip: $HOST_IP"
|
echo "This is your host ip: $HOST_IP"
|
||||||
|
|
||||||
# Warn that ``EXTRA_FLAGS`` needs to be converted to ``EXTRA_OPTS``
|
# Warn that a deprecated feature was used
|
||||||
if [[ -n "$EXTRA_FLAGS" ]]; then
|
if [[ -n "$DEPRECATED_TEXT" ]]; then
|
||||||
echo_summary "WARNING: EXTRA_FLAGS is defined and may need to be converted to EXTRA_OPTS"
|
echo_summary "WARNING: $DEPRECATED_TEXT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Indicate how long this took to run (bash maintained variable ``SECONDS``)
|
# Indicate how long this took to run (bash maintained variable ``SECONDS``)
|
||||||
|
5
stackrc
5
stackrc
@ -9,9 +9,6 @@ DEST=/opt/stack
|
|||||||
# Destination for working data
|
# Destination for working data
|
||||||
DATA_DIR=${DEST}/data
|
DATA_DIR=${DEST}/data
|
||||||
|
|
||||||
# Select the default database
|
|
||||||
DATABASE_TYPE=mysql
|
|
||||||
|
|
||||||
# Determine stack user
|
# Determine stack user
|
||||||
if [[ $EUID -eq 0 ]]; then
|
if [[ $EUID -eq 0 ]]; then
|
||||||
STACK_USER=stack
|
STACK_USER=stack
|
||||||
@ -24,7 +21,7 @@ fi
|
|||||||
# ``disable_service`` functions in ``localrc``.
|
# ``disable_service`` functions in ``localrc``.
|
||||||
# For example, to enable Swift add this to ``localrc``:
|
# For example, to enable Swift add this to ``localrc``:
|
||||||
# enable_service swift
|
# enable_service swift
|
||||||
ENABLED_SERVICES=g-api,g-reg,key,n-api,n-crt,n-obj,n-cpu,n-net,n-cond,cinder,c-sch,c-api,c-vol,n-sch,n-novnc,n-xvnc,n-cauth,horizon,rabbit,tempest,$DATABASE_TYPE
|
ENABLED_SERVICES=g-api,g-reg,key,n-api,n-crt,n-obj,n-cpu,n-net,n-cond,cinder,c-sch,c-api,c-vol,n-sch,n-novnc,n-xvnc,n-cauth,horizon,rabbit,tempest,mysql
|
||||||
|
|
||||||
# Set the default Nova APIs to enable
|
# Set the default Nova APIs to enable
|
||||||
NOVA_ENABLED_APIS=ec2,osapi_compute,metadata
|
NOVA_ENABLED_APIS=ec2,osapi_compute,metadata
|
||||||
|
Loading…
Reference in New Issue
Block a user