e500346e40
Without setting these, they default to localhost which works in the the gate, but may not work in all devstack setups. Change-Id: I50eadbf0b4975cf04ec945bcf463c2738e6e7a3c
231 lines
9.0 KiB
Plaintext
231 lines
9.0 KiB
Plaintext
# lib/trove
|
|
# Functions to control the configuration and operation of the **Trove** service
|
|
|
|
# Dependencies:
|
|
# ``functions`` file
|
|
# ``DEST``, ``STACK_USER`` must be defined
|
|
# ``SERVICE_{HOST|PROTOCOL|TOKEN}`` must be defined
|
|
|
|
# ``stack.sh`` calls the entry points in this order:
|
|
#
|
|
# install_trove
|
|
# configure_trove
|
|
# init_trove
|
|
# start_trove
|
|
# stop_trove
|
|
# cleanup_trove
|
|
|
|
# Save trace setting
|
|
XTRACE=$(set +o | grep xtrace)
|
|
set +o xtrace
|
|
|
|
# Defaults
|
|
# --------
|
|
|
|
NETWORK_GATEWAY=${NETWORK_GATEWAY:-10.0.0.1}
|
|
|
|
# Set up default configuration
|
|
TROVE_DIR=$DEST/trove
|
|
TROVECLIENT_DIR=$DEST/python-troveclient
|
|
TROVE_CONF_DIR=/etc/trove
|
|
TROVE_LOCAL_CONF_DIR=$TROVE_DIR/etc/trove
|
|
TROVE_AUTH_CACHE_DIR=${TROVE_AUTH_CACHE_DIR:-/var/cache/trove}
|
|
|
|
# Support entry points installation of console scripts
|
|
if [[ -d $TROVE_DIR/bin ]]; then
|
|
TROVE_BIN_DIR=$TROVE_DIR/bin
|
|
else
|
|
TROVE_BIN_DIR=$(get_python_exec_prefix)
|
|
fi
|
|
|
|
# Tell Tempest this project is present
|
|
TEMPEST_SERVICES+=,trove
|
|
|
|
|
|
# Functions
|
|
# ---------
|
|
|
|
# Test if any Trove services are enabled
|
|
# is_trove_enabled
|
|
function is_trove_enabled {
|
|
[[ ,${ENABLED_SERVICES} =~ ,"tr-" ]] && return 0
|
|
return 1
|
|
}
|
|
|
|
# setup_trove_logging() - Adds logging configuration to conf files
|
|
function setup_trove_logging {
|
|
local CONF=$1
|
|
iniset $CONF DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL
|
|
iniset $CONF DEFAULT use_syslog $SYSLOG
|
|
if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then
|
|
# Add color to logging output
|
|
setup_colorized_logging $CONF DEFAULT tenant user
|
|
fi
|
|
}
|
|
|
|
# create_trove_accounts() - Set up common required trove accounts
|
|
|
|
# Tenant User Roles
|
|
# ------------------------------------------------------------------
|
|
# service trove admin # if enabled
|
|
|
|
function create_trove_accounts {
|
|
# Trove
|
|
SERVICE_TENANT=$(openstack project list | awk "/ $SERVICE_TENANT_NAME / { print \$2 }")
|
|
SERVICE_ROLE=$(openstack role list | awk "/ admin / { print \$2 }")
|
|
|
|
if [[ "$ENABLED_SERVICES" =~ "trove" ]]; then
|
|
TROVE_USER=$(openstack user create \
|
|
trove \
|
|
--password "$SERVICE_PASSWORD" \
|
|
--project $SERVICE_TENANT \
|
|
--email trove@example.com \
|
|
| grep " id " | get_field 2)
|
|
openstack role add \
|
|
$SERVICE_ROLE \
|
|
--project $SERVICE_TENANT \
|
|
--user $TROVE_USER
|
|
if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
|
|
TROVE_SERVICE=$(openstack service create \
|
|
trove \
|
|
--type=database \
|
|
--description="Trove Service" \
|
|
| grep " id " | get_field 2)
|
|
openstack endpoint create \
|
|
$TROVE_SERVICE \
|
|
--region RegionOne \
|
|
--publicurl "http://$SERVICE_HOST:8779/v1.0/\$(tenant_id)s" \
|
|
--adminurl "http://$SERVICE_HOST:8779/v1.0/\$(tenant_id)s" \
|
|
--internalurl "http://$SERVICE_HOST:8779/v1.0/\$(tenant_id)s"
|
|
fi
|
|
fi
|
|
}
|
|
|
|
# stack.sh entry points
|
|
# ---------------------
|
|
|
|
# cleanup_trove() - Remove residual data files, anything left over from previous
|
|
# runs that a clean run would need to clean up
|
|
function cleanup_trove {
|
|
#Clean up dirs
|
|
rm -fr $TROVE_AUTH_CACHE_DIR/*
|
|
rm -fr $TROVE_CONF_DIR/*
|
|
}
|
|
|
|
# configure_troveclient() - Set config files, create data dirs, etc
|
|
function configure_troveclient {
|
|
setup_develop $TROVECLIENT_DIR
|
|
}
|
|
|
|
# configure_trove() - Set config files, create data dirs, etc
|
|
function configure_trove {
|
|
setup_develop $TROVE_DIR
|
|
|
|
# Create the trove conf dir and cache dirs if they don't exist
|
|
sudo mkdir -p ${TROVE_CONF_DIR}
|
|
sudo mkdir -p ${TROVE_AUTH_CACHE_DIR}
|
|
sudo chown -R $STACK_USER: ${TROVE_CONF_DIR}
|
|
sudo chown -R $STACK_USER: ${TROVE_AUTH_CACHE_DIR}
|
|
|
|
# Copy api-paste file over to the trove conf dir and configure it
|
|
cp $TROVE_LOCAL_CONF_DIR/api-paste.ini $TROVE_CONF_DIR/api-paste.ini
|
|
TROVE_API_PASTE_INI=$TROVE_CONF_DIR/api-paste.ini
|
|
iniset $TROVE_API_PASTE_INI filter:authtoken auth_host $KEYSTONE_AUTH_HOST
|
|
iniset $TROVE_API_PASTE_INI filter:authtoken auth_port $KEYSTONE_AUTH_PORT
|
|
iniset $TROVE_API_PASTE_INI filter:authtoken auth_protocol $KEYSTONE_AUTH_PROTOCOL
|
|
iniset $TROVE_API_PASTE_INI filter:authtoken cafile $KEYSTONE_SSL_CA
|
|
iniset $TROVE_API_PASTE_INI filter:authtoken admin_tenant_name $SERVICE_TENANT_NAME
|
|
iniset $TROVE_API_PASTE_INI filter:authtoken admin_user trove
|
|
iniset $TROVE_API_PASTE_INI filter:authtoken admin_password $SERVICE_PASSWORD
|
|
iniset $TROVE_API_PASTE_INI filter:authtoken signing_dir $TROVE_AUTH_CACHE_DIR
|
|
|
|
# (Re)create trove conf files
|
|
rm -f $TROVE_CONF_DIR/trove.conf
|
|
rm -f $TROVE_CONF_DIR/trove-taskmanager.conf
|
|
rm -f $TROVE_CONF_DIR/trove-conductor.conf
|
|
|
|
iniset $TROVE_CONF_DIR/trove.conf DEFAULT rabbit_password $RABBIT_PASSWORD
|
|
iniset $TROVE_CONF_DIR/trove.conf DEFAULT sql_connection `database_connection_url trove`
|
|
iniset $TROVE_CONF_DIR/trove.conf DEFAULT add_addresses True
|
|
iniset $TROVE_CONF_DIR/trove.conf DEFAULT nova_compute_url $NOVA_SERVICE_PROTOCOL://$NOVA_SERVICE_HOST:$NOVA_SERVICE_PORT/v2
|
|
iniset $TROVE_CONF_DIR/trove.conf DEFAULT cinder_url $CINDER_SERVICE_PROTOCOL://$CINDER_SERVICE_HOST:$CINDER_SERVICE_PORT/v1
|
|
iniset $TROVE_CONF_DIR/trove.conf DEFAULT swift_url http://$SERVICE_HOST:8080/v1/AUTH_
|
|
|
|
iniset $TROVE_LOCAL_CONF_DIR/trove-guestagent.conf.sample DEFAULT rabbit_password $RABBIT_PASSWORD
|
|
sed -i "s/localhost/$NETWORK_GATEWAY/g" $TROVE_LOCAL_CONF_DIR/trove-guestagent.conf.sample
|
|
|
|
setup_trove_logging $TROVE_CONF_DIR/trove.conf
|
|
setup_trove_logging $TROVE_LOCAL_CONF_DIR/trove-guestagent.conf.sample
|
|
|
|
# (Re)create trove taskmanager conf file if needed
|
|
if is_service_enabled tr-tmgr; then
|
|
TROVE_AUTH_ENDPOINT=$KEYSTONE_AUTH_PROTOCOL://$KEYSTONE_AUTH_HOST:$KEYSTONE_AUTH_PORT//v$IDENTITY_API_VERSION
|
|
|
|
iniset $TROVE_CONF_DIR/trove-taskmanager.conf DEFAULT rabbit_password $RABBIT_PASSWORD
|
|
iniset $TROVE_CONF_DIR/trove-taskmanager.conf DEFAULT sql_connection `database_connection_url trove`
|
|
iniset $TROVE_CONF_DIR/trove-taskmanager.conf DEFAULT taskmanager_manager trove.taskmanager.manager.Manager
|
|
iniset $TROVE_CONF_DIR/trove-taskmanager.conf DEFAULT nova_proxy_admin_user radmin
|
|
iniset $TROVE_CONF_DIR/trove-taskmanager.conf DEFAULT nova_proxy_admin_tenant_name trove
|
|
iniset $TROVE_CONF_DIR/trove-taskmanager.conf DEFAULT nova_proxy_admin_pass $RADMIN_USER_PASS
|
|
iniset $TROVE_CONF_DIR/trove-taskmanager.conf DEFAULT nova_compute_url $NOVA_SERVICE_PROTOCOL://$NOVA_SERVICE_HOST:$NOVA_SERVICE_PORT/v2
|
|
iniset $TROVE_CONF_DIR/trove-taskmanager.conf DEFAULT cinder_url $CINDER_SERVICE_PROTOCOL://$CINDER_SERVICE_HOST:$CINDER_SERVICE_PORT/v1
|
|
iniset $TROVE_CONF_DIR/trove-taskmanager.conf DEFAULT swift_url http://$SERVICE_HOST:8080/v1/AUTH_
|
|
iniset $TROVE_CONF_DIR/trove-taskmanager.conf DEFAULT trove_auth_url $TROVE_AUTH_ENDPOINT
|
|
setup_trove_logging $TROVE_CONF_DIR/trove-taskmanager.conf
|
|
fi
|
|
|
|
# (Re)create trove conductor conf file if needed
|
|
if is_service_enabled tr-cond; then
|
|
iniset $TROVE_CONF_DIR/trove-conductor.conf DEFAULT rabbit_password $RABBIT_PASSWORD
|
|
iniset $TROVE_CONF_DIR/trove-conductor.conf DEFAULT sql_connection `database_connection_url trove`
|
|
iniset $TROVE_CONF_DIR/trove-conductor.conf DEFAULT nova_proxy_admin_user radmin
|
|
iniset $TROVE_CONF_DIR/trove-conductor.conf DEFAULT nova_proxy_admin_tenant_name trove
|
|
iniset $TROVE_CONF_DIR/trove-conductor.conf DEFAULT nova_proxy_admin_pass $RADMIN_USER_PASS
|
|
iniset $TROVE_CONF_DIR/trove-conductor.conf DEFAULT trove_auth_url $TROVE_AUTH_ENDPOINT
|
|
iniset $TROVE_CONF_DIR/trove-conductor.conf DEFAULT control_exchange trove
|
|
setup_trove_logging $TROVE_CONF_DIR/trove-conductor.conf
|
|
fi
|
|
}
|
|
|
|
# install_troveclient() - Collect source and prepare
|
|
function install_troveclient {
|
|
git_clone $TROVECLIENT_REPO $TROVECLIENT_DIR $TROVECLIENT_BRANCH
|
|
}
|
|
|
|
# install_trove() - Collect source and prepare
|
|
function install_trove {
|
|
git_clone $TROVE_REPO $TROVE_DIR $TROVE_BRANCH
|
|
}
|
|
|
|
# init_trove() - Initializes Trove Database as a Service
|
|
function init_trove {
|
|
#(Re)Create trove db
|
|
recreate_database trove utf8
|
|
|
|
#Initialize the trove database
|
|
$TROVE_BIN_DIR/trove-manage db_sync
|
|
}
|
|
|
|
# start_trove() - Start running processes, including screen
|
|
function start_trove {
|
|
screen_it tr-api "cd $TROVE_DIR; $TROVE_BIN_DIR/trove-api --config-file=$TROVE_CONF_DIR/trove.conf --debug 2>&1"
|
|
screen_it tr-tmgr "cd $TROVE_DIR; $TROVE_BIN_DIR/trove-taskmanager --config-file=$TROVE_CONF_DIR/trove-taskmanager.conf --debug 2>&1"
|
|
screen_it tr-cond "cd $TROVE_DIR; $TROVE_BIN_DIR/trove-conductor --config-file=$TROVE_CONF_DIR/trove-conductor.conf --debug 2>&1"
|
|
}
|
|
|
|
# stop_trove() - Stop running processes
|
|
function stop_trove {
|
|
# Kill the trove screen windows
|
|
for serv in tr-api tr-tmgr tr-cond; do
|
|
screen_stop $serv
|
|
done
|
|
}
|
|
|
|
# Restore xtrace
|
|
$XTRACE
|
|
|
|
# Tell emacs to use shell-script-mode
|
|
## Local variables:
|
|
## mode: shell-script
|
|
## End:
|