1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
|
# 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)
# Integration with OSprofiler
OSPROFILER_HMAC_KEYS=${OSPROFILER_HMAC_KEYS:-""}
OSPROFILER_CONNECTION_STRING=${OSPROFILER_CONNECTION_STRING:-""}
# Functions
# ---------
# Creates a configuration file for the current deployment
# Uses the following variables:
#
# - ``ADMIN_PASSWORD``, ``REGION_NAME``
# ``KEYSTONE_SERVICE_URI``
# ``OSPROFILER_HMAC_KEYS`` - optional, for integration with osprofiler
# ``OSPROFILER_CONNECTION_STRING`` - optional, if this is set together with
# OSPROFILER_HMAC_KEYS rally html report will use osprofiler api to
# generate html report for each trace and embed it as iframe to our
# native html report
# ``RALLY_OSPROFILER_CHART`` - optional, a path to store osprofiler's reports
#
# _create_deployment_config filename
function _create_deployment_config() {
cat >$1 <<EOF
{
"openstack": {
"auth_url": "$KEYSTONE_SERVICE_URI",
"region_name": "$REGION_NAME",
"admin": {
"username": "admin",
"password": "$ADMIN_PASSWORD",
"project_name": "admin",
"user_domain_name": "Default",
"project_domain_name": "Default"
},
EOF
# Now add osprofiler config if necessary
if [[ ! -z "$OSPROFILER_HMAC_KEYS" ]]; then
cat >>$1 <<EOF
"profiler_hmac_key": $OSPROFILER_HMAC_KEYS,
EOF
fi
if [[ ! -z "$OSPROFILER_CONNECTION_STRING" ]]; then
cat >>$1 <<EOF
"profiler_conn_str": "$OSPROFILER_CONNECTION_STRING",
EOF
fi
# And finish file
cat >>$1 <<EOF
}
}
EOF
}
# 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 --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:
|