Files
rally-openstack/devstack/lib/rally
Andrey Kurilin 57d2a22dfd Simplify deployment config format
There is upgoing work related to deployment refactoring. The bunch of
different enitities will be removed and inner code will be rewritten
almost from scratch.

This patch introduces a new simpler dedployment config format. Despite
the fact that it requires several workarounds, we need to merge it
before actual refactoring is done, since we want to provide a good
deprecation period and as quicker we introduce a new format as quicker
we will able to remove deprecated stuff:)

An example of old deployment config:

    {
         "type": "ExistingCloud",
         "creds": {
             "openstack": {
                 "auth_url": "https://example.com",
                 "admin": {
                               "username": "admin",
                               "password": "pass",
                               "project_name": "admin"
                 }
             }
         }
    }

An example of a new format:

    {
         "openstack": {
             "auth_url": "https://example.com",
             "admin": {
                           "username": "admin",
                           "password": "pass",
                           "project_name": "admin"
             }
         }
    }

Change-Id: If88317a0aefdd3d1adc6c380672d83e2bad11f15
2017-08-22 16:26:17 +03:00

128 lines
3.1 KiB
Plaintext

# lib/rally
# Functions to control the configuration and operation of the **Rally**
# Dependencies:
#
# - ``functions`` file
# - ``DEST``, ``DATA_DIR``, ``STACK_USER`` must be defined
# ``stack.sh`` calls the entry points in this order:
#
# - install_rally
# - configure_rally
# - init_rally
# Save trace setting
XTRACE=$(set +o | grep xtrace)
set +o xtrace
# Defaults
# --------
# Set up default directories
DIR=$(dirname ${BASH_SOURCE[0]})
RALLY_DIR=$(readlink -m $DIR/../..)
RALLY_CONF_DIR=${RALLY_CONF_DIR:-/etc/rally}
RALLY_CONF_FILE=rally.conf
# Debug mode
RALLY_DEBUG=${RALLY_DEBUG:-False}
# Create deployment
RALLY_ADD_DEPLOYMENT=${RALLY_ADD_DEPLOYMENT:-"True"}
RALLY_ADD_DEPLOYMENT=$(trueorfalse True $RALLY_ADD_DEPLOYMENT)
# Functions
# ---------
# Creates a configuration file for the current deployment
# Uses the following variables:
#
# - ``ADMIN_PASSWORD``, ``KEYSTONE_SERVICE_PROTOCOL``,
# ``KEYSTONE_SERVICE_HOST``, ``KEYSTONE_SERVICE_PORT``,
# ``IDENTITY_API_VERSION`` - must be defined
#
# _create_deployment_config filename
function _create_deployment_config() {
if [[ "$IDENTITY_API_VERSION" == 2.0 ]]
then
cat >$1 <<EOF
{
"openstack": {
"auth_url": "$OS_AUTH_URL",
"region_name": "$REGION_NAME",
"admin": {
"username": "admin",
"password": "$ADMIN_PASSWORD",
"tenant_name": "admin",
}
}
}
EOF
fi
if [[ "$IDENTITY_API_VERSION" == 3 ]]
then
cat >$1 <<EOF
{
"openstack": {
"auth_url": "$OS_AUTH_URL",
"region_name": "$REGION_NAME",
"admin": {
"username": "admin",
"password": "$ADMIN_PASSWORD",
"project_name": "admin",
"user_domain_name": "Default",
"project_domain_name": "Default"
}
}
}
EOF
fi
}
# install_rally() - Collect source and prepare
function install_rally() {
setup_develop $RALLY_DIR
}
# configure_rally() - Set config files, create data dirs, etc
function configure_rally() {
if [[ ! -d $RALLY_CONF_DIR ]]; then
sudo mkdir -p $RALLY_CONF_DIR
fi
sudo chown $STACK_USER $RALLY_CONF_DIR
# Copy over rally configuration file and configure common parameters.
cp $RALLY_DIR/etc/rally/rally.conf.sample $RALLY_CONF_DIR/$RALLY_CONF_FILE
iniset $RALLY_CONF_DIR/$RALLY_CONF_FILE DEFAULT debug $RALLY_DEBUG
iniset $RALLY_CONF_DIR/$RALLY_CONF_FILE database connection `database_connection_url rally`
iniset $RALLY_CONF_DIR/$RALLY_CONF_FILE DEFAULT use_syslog $SYSLOG
}
# init_rally() - Initialize databases, etc.
function init_rally() {
recreate_database rally utf8
# Recreate rally database
rally-manage --config-file $RALLY_CONF_DIR/$RALLY_CONF_FILE db recreate
# Add current DevStack deployment to Rally
if [ "$RALLY_ADD_DEPLOYMENT" = "True" ]; then
local tmpfile=$(mktemp)
_create_deployment_config $tmpfile
rally --config-file $RALLY_CONF_DIR/$RALLY_CONF_FILE deployment create --name devstack --filename $tmpfile
fi
}
# Restore xtrace
$XTRACE
# Tell emacs to use shell-script-mode
## Local variables:
## mode: shell-script
## End: