Extra scripts with DevStack support
DevStack project don't merge support of stackforge projects into master. There is an alternative support to use the devstack infrastructure. The mechanism based on ability of implementing hooks such as extras.d. Implemented functionality of the Rally library: * Install Rally from repository * Configure Rally and create database tables * Create a special tenant * Optionally add devstack installation as a deployment blueprint rally-devstack-extras Change-Id: I43b74db203ca385d321ba9d6f79c2bd21f947e13
This commit is contained in:
parent
cb789a5fb6
commit
b486db9d5f
20
contrib/devstack/README.rst
Normal file
20
contrib/devstack/README.rst
Normal file
@ -0,0 +1,20 @@
|
||||
===============================
|
||||
Installing Rally using devstack
|
||||
===============================
|
||||
|
||||
The contrib/devstack/ directory contains the files necessary to integrate Rally with devstack.
|
||||
|
||||
To install:
|
||||
|
||||
$ DEVSTACK_DIR=.../path/to/devstack
|
||||
$ cp lib/rally ${DEVSTACK_DIR}/lib
|
||||
$ cp extras.d/70-rally.sh ${DEVSTACK_DIR}/extras.d
|
||||
|
||||
To configure devstack to run rally:
|
||||
|
||||
$ cd ${DEVSTACK_DIR}
|
||||
$ echo "enable_service rally" >> localrc
|
||||
|
||||
Run devstack as normal:
|
||||
|
||||
$ ./stack.sh
|
18
contrib/devstack/extras.d/70-rally.sh
Normal file
18
contrib/devstack/extras.d/70-rally.sh
Normal file
@ -0,0 +1,18 @@
|
||||
# rally.sh - DevStack extras script to install Rally
|
||||
|
||||
if is_service_enabled rally; then
|
||||
if [[ "$1" == "source" ]]; then
|
||||
# Initial source
|
||||
source $TOP_DIR/lib/rally
|
||||
elif [[ "$1" == "stack" && "$2" == "install" ]]; then
|
||||
echo_summary "Installing Rally"
|
||||
install_rally
|
||||
elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
|
||||
echo_summary "Configuring Rally"
|
||||
configure_rally
|
||||
create_rally_accounts
|
||||
elif [[ "$1" == "stack" && "$2" == "extra" ]]; then
|
||||
echo_summary "Initializing Rally"
|
||||
init_rally
|
||||
fi
|
||||
fi
|
132
contrib/devstack/lib/rally
Normal file
132
contrib/devstack/lib/rally
Normal file
@ -0,0 +1,132 @@
|
||||
# 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
|
||||
# - create_rally_accounts
|
||||
# - init_rally
|
||||
|
||||
# Save trace setting
|
||||
XTRACE=$(set +o | grep xtrace)
|
||||
set +o xtrace
|
||||
|
||||
|
||||
# Defaults
|
||||
# --------
|
||||
|
||||
# Set up default repos
|
||||
RALLY_REPO=${RALLY_REPO:-${GIT_BASE}/stackforge/rally.git}
|
||||
RALLY_BRANCH=${RALLY_BRANCH:-master}
|
||||
|
||||
# Set up default directories
|
||||
RALLY_DIR=$DEST/rally
|
||||
RALLY_CONF_DIR=${RALLY_CONF_DIR:-/etc/rally}
|
||||
RALLY_CONF_FILE=rally.conf
|
||||
|
||||
# Debuge mode
|
||||
RALLY_DEBUG=${RALLY_DEBUG:-True}
|
||||
|
||||
# Support entry points installation of console scripts
|
||||
if [[ -d $RALLY_DIR/bin ]]; then
|
||||
RALLY_BIN_DIR=$NOVA_DIR/bin
|
||||
else
|
||||
RALLY_BIN_DIR=$(get_python_exec_prefix)
|
||||
fi
|
||||
|
||||
# Benchmark accounts
|
||||
BENCHMARK_TENANT=${BENCHMARK_TENANT:-benchmark}
|
||||
|
||||
# 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() {
|
||||
cat >$1 <<EOF
|
||||
{
|
||||
"name": "DummyEngine",
|
||||
"endpoint": {
|
||||
"auth_url": "$KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/v$IDENTITY_API_VERSION",
|
||||
"username": "admin",
|
||||
"password": "$ADMIN_PASSWORD",
|
||||
"tenant_name": "benchmark"
|
||||
}
|
||||
}
|
||||
EOF
|
||||
}
|
||||
|
||||
# install_rally() - Collect source and prepare
|
||||
function install_rally() {
|
||||
git_clone $RALLY_REPO $RALLY_DIR $RALLY_BRANCH
|
||||
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
|
||||
}
|
||||
|
||||
# create_rally_accounts() - Sets up common required rally accounts
|
||||
create_rally_accounts() {
|
||||
ADMIN_USER=$(keystone user-list | awk "/ admin / { print \$2 }")
|
||||
ADMIN_ROLE=$(keystone role-list | awk "/ admin / { print \$2 }")
|
||||
|
||||
BENHCMARK_TENANT=$(keystone tenant-create \
|
||||
--name benchmark \
|
||||
| grep " id " | get_field 2)
|
||||
keystone user-role-add \
|
||||
--user-id $ADMIN_USER \
|
||||
--role-id $ADMIN_ROLE \
|
||||
--tenant-id $BENHCMARK_TENANT
|
||||
}
|
||||
|
||||
# init_rally() - Initialize databases, etc.
|
||||
function init_rally() {
|
||||
recreate_database rally utf8
|
||||
# Recreate rally database
|
||||
$RALLY_BIN_DIR/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_BIN_DIR/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:
|
Loading…
x
Reference in New Issue
Block a user