devstack/lib/ceilometer
Eoghan Glynn 14246ac16b Provide credentials via ceilometer config file
Fixes bug 1076831

Previously we passed these credentials to the ceilometer central
agent via the OS_* environment variables.

Since these credentials are now needed by the compute agent also,
and have already leaked into the config file to enable the keystone
auth token middleware, we now switch over to using the config file
only and drop the environment variable usage.

Change-Id: I0298d711905a99aa5355fe034bb0e51e53b3be21
2012-11-14 16:27:52 +00:00

107 lines
3.9 KiB
Plaintext

# lib/ceilometer
# Install and start Ceilometer service
# To enable, add the following to localrc
# ENABLED_SERVICES+=ceilometer-acompute,ceilometer-acentral,ceilometer-collector,ceilometer-api
# Dependencies:
# - functions
# - OS_AUTH_URL for auth in api
# - DEST set to the destination directory
# - SERVICE_PASSWORD, SERVICE_TENANT_NAME for auth in api
# stack.sh
# ---------
# install_XXX
# configure_XXX
# init_XXX
# start_XXX
# stop_XXX
# cleanup_XXX
# Save trace setting
XTRACE=$(set +o | grep xtrace)
set +o xtrace
# Defaults
# --------
# set up default directories
CEILOMETER_DIR=$DEST/ceilometer
# Support potential entry-points console scripts
if [ -d $CEILOMETER_DIR/bin ] ; then
CEILOMETER_BIN_DIR=$CEILOMETER_DIR/bin
else
CEILOMETER_BIN_DIR=/usr/local/bin
fi
CEILOMETER_CONF_DIR=/etc/ceilometer
CEILOMETER_CONF=$CEILOMETER_CONF_DIR/ceilometer.conf
CEILOMETER_API_LOG_DIR=/var/log/ceilometer-api
# cleanup_ceilometer() - Remove residual data files, anything left over from previous
# runs that a clean run would need to clean up
function cleanup_ceilometer() {
mongo ceilometer --eval "db.dropDatabase();"
}
# configure_ceilometer() - Set config files, create data dirs, etc
function configure_ceilometer() {
setup_develop $CEILOMETER_DIR
[ ! -d $CEILOMETER_CONF_DIR ] && sudo mkdir -m 755 -p $CEILOMETER_CONF_DIR
sudo chown $USER $CEILOMETER_CONF_DIR
[ ! -d $CEILOMETER_API_LOG_DIR ] && sudo mkdir -m 755 -p $CEILOMETER_API_LOG_DIR
sudo chown $USER $CEILOMETER_API_LOG_DIR
iniset $CEILOMETER_CONF DEFAULT rpc_backend 'ceilometer.openstack.common.rpc.impl_kombu'
iniset $CEILOMETER_CONF DEFAULT notification_topics 'notifications,glance_notifications'
iniset $CEILOMETER_CONF DEFAULT verbose True
iniset $CEILOMETER_CONF DEFAULT rabbit_host $RABBIT_HOST
iniset $CEILOMETER_CONF DEFAULT rabbit_password $RABBIT_PASSWORD
iniset $CEILOMETER_CONF DEFAULT sql_connection $BASE_SQL_CONN/nova?charset=utf8
# Install the policy file for the API server
cp $CEILOMETER_DIR/etc/ceilometer/policy.json $CEILOMETER_CONF_DIR
iniset $CEILOMETER_CONF DEFAULT policy_file $CEILOMETER_CONF_DIR/policy.json
# the compute and central agents need these credentials in order to
# call out to the public nova and glance APIs
iniset $CEILOMETER_CONF DEFAULT os_username ceilometer
iniset $CEILOMETER_CONF DEFAULT os_password $SERVICE_PASSWORD
iniset $CEILOMETER_CONF DEFAULT os_tenant_name $SERVICE_TENANT_NAME
iniset $CEILOMETER_CONF DEFAULT os_auth_url $OS_AUTH_URL
iniset $CEILOMETER_CONF keystone_authtoken auth_protocol http
iniset $CEILOMETER_CONF keystone_authtoken admin_user ceilometer
iniset $CEILOMETER_CONF keystone_authtoken admin_password $SERVICE_PASSWORD
iniset $CEILOMETER_CONF keystone_authtoken admin_tenant_name $SERVICE_TENANT_NAME
cleanup_ceilometer
}
# install_ceilometer() - Collect source and prepare
function install_ceilometer() {
git_clone $CEILOMETER_REPO $CEILOMETER_DIR $CEILOMETER_BRANCH
}
# start_ceilometer() - Start running processes, including screen
function start_ceilometer() {
screen_it ceilometer-acompute "cd $CEILOMETER_DIR && sg libvirtd \"$CEILOMETER_BIN_DIR/ceilometer-agent-compute --config-file $CEILOMETER_CONF\""
screen_it ceilometer-acentral "cd $CEILOMETER_DIR && $CEILOMETER_BIN_DIR/ceilometer-agent-central --config-file $CEILOMETER_CONF"
screen_it ceilometer-collector "cd $CEILOMETER_DIR && $CEILOMETER_BIN_DIR/ceilometer-collector --config-file $CEILOMETER_CONF"
screen_it ceilometer-api "cd $CEILOMETER_DIR && $CEILOMETER_BIN_DIR/ceilometer-api -d -v --log-dir=$CEILOMETER_API_LOG_DIR --config-file $CEILOMETER_CONF"
}
# stop_ceilometer() - Stop running processes
function stop_ceilometer() {
# Kill the ceilometer screen windows
for serv in ceilometer-acompute ceilometer-acentral ceilometer-collector ceilometer-api; do
screen -S $SCREEN_NAME -p $serv -X kill
done
}
# Restore xtrace
$XTRACE