install database when collector is enabled.

Currently, if we run devstack for compute node, ceilometer-collector
service will be disabled on compute node, but the database is still
installed.

This patch makes sure that database is installed only when collector
is enabled.

Also add check for coordinate and hypervisor requirements.

Change-Id: Ib3614d2e698403c24ad299d95ef42c81815fa76e
Closes-Bug: #1508518
This commit is contained in:
ZhiQiang Fan 2015-11-11 01:15:58 -07:00
parent 191852fbaf
commit 0ba0ba7270

View File

@ -197,11 +197,14 @@ function _ceilometer_cleanup_apache_wsgi {
# cleanup_ceilometer() - Remove residual data files, anything left over # cleanup_ceilometer() - Remove residual data files, anything left over
# from previous runs that a clean run would need to clean up # from previous runs that a clean run would need to clean up
function cleanup_ceilometer { function cleanup_ceilometer {
if [ "$CEILOMETER_BACKEND" = 'mongodb' ] ; then if is_service_enabled ceilometer-collector ceilometer-api ; then
mongo ceilometer --eval "db.dropDatabase();" if [ "$CEILOMETER_BACKEND" = 'mongodb' ] ; then
elif [ "$CEILOMETER_BACKEND" = 'es' ] ; then mongo ceilometer --eval "db.dropDatabase();"
curl -XDELETE "localhost:9200/events_*" elif [ "$CEILOMETER_BACKEND" = 'es' ] ; then
curl -XDELETE "localhost:9200/events_*"
fi
fi fi
if is_service_enabled ceilometer-api && [ "$CEILOMETER_USE_MOD_WSGI" == "True" ]; then if is_service_enabled ceilometer-api && [ "$CEILOMETER_USE_MOD_WSGI" == "True" ]; then
_ceilometer_cleanup_apache_wsgi _ceilometer_cleanup_apache_wsgi
fi fi
@ -281,8 +284,10 @@ function configure_ceilometer {
iniset $CEILOMETER_CONF notification store_events $CEILOMETER_EVENTS iniset $CEILOMETER_CONF notification store_events $CEILOMETER_EVENTS
# Configure storage # Configure storage
_ceilometer_configure_storage_backend if is_service_enabled ceilometer-collector ceilometer-api; then
iniset $CEILOMETER_CONF collector workers $API_WORKERS _ceilometer_configure_storage_backend
iniset $CEILOMETER_CONF collector workers $API_WORKERS
fi
if [[ "$VIRT_DRIVER" = 'vsphere' ]]; then if [[ "$VIRT_DRIVER" = 'vsphere' ]]; then
iniset $CEILOMETER_CONF DEFAULT hypervisor_inspector vsphere iniset $CEILOMETER_CONF DEFAULT hypervisor_inspector vsphere
@ -312,7 +317,7 @@ function init_ceilometer {
sudo install -d -o $STACK_USER $CEILOMETER_AUTH_CACHE_DIR sudo install -d -o $STACK_USER $CEILOMETER_AUTH_CACHE_DIR
rm -f $CEILOMETER_AUTH_CACHE_DIR/* rm -f $CEILOMETER_AUTH_CACHE_DIR/*
if is_service_enabled mysql postgresql; then if is_service_enabled ceilometer-collector ceilometer-api && is_service_enabled mysql postgresql ; then
if [ "$CEILOMETER_BACKEND" = 'mysql' ] || [ "$CEILOMETER_BACKEND" = 'postgresql' ] || [ "$CEILOMETER_BACKEND" = 'es' ] ; then if [ "$CEILOMETER_BACKEND" = 'mysql' ] || [ "$CEILOMETER_BACKEND" = 'postgresql' ] || [ "$CEILOMETER_BACKEND" = 'es' ] ; then
recreate_database ceilometer recreate_database ceilometer
$CEILOMETER_BIN_DIR/ceilometer-dbsync $CEILOMETER_BIN_DIR/ceilometer-dbsync
@ -326,9 +331,18 @@ function init_ceilometer {
# installed. The context is not active during preinstall (when it would # installed. The context is not active during preinstall (when it would
# otherwise makes sense to do the backend services). # otherwise makes sense to do the backend services).
function install_ceilometer { function install_ceilometer {
_ceilometer_prepare_coordination if is_service_enabled ceilometer-acentral ceilometer-anotification ceilometer-alarm-evaluator ; then
_ceilometer_prepare_storage_backend _ceilometer_prepare_coordination
_ceilometer_prepare_virt_drivers fi
if is_service_enabled ceilometer-collector ceilometer-api; then
_ceilometer_prepare_storage_backend
fi
if is_service_enabled ceilometer-acompute ; then
_ceilometer_prepare_virt_drivers
fi
install_ceilometerclient install_ceilometerclient
setup_develop $CEILOMETER_DIR setup_develop $CEILOMETER_DIR
sudo install -d -o $STACK_USER -m 755 $CEILOMETER_CONF_DIR sudo install -d -o $STACK_USER -m 755 $CEILOMETER_CONF_DIR
@ -390,11 +404,13 @@ function start_ceilometer {
# stop_ceilometer() - Stop running processes # stop_ceilometer() - Stop running processes
function stop_ceilometer { function stop_ceilometer {
if [ "$CEILOMETER_USE_MOD_WSGI" == "True" ]; then if is_service_enabled ceilometer-api ; then
disable_apache_site ceilometer if [ "$CEILOMETER_USE_MOD_WSGI" == "True" ]; then
restart_apache_server disable_apache_site ceilometer
else restart_apache_server
stop_process ceilometer-api else
stop_process ceilometer-api
fi
fi fi
# Kill the ceilometer screen windows # Kill the ceilometer screen windows