2015-06-27 11:13:10 +00:00
# Install and start **Ceilometer** service in devstack
#
# To enable Ceilometer in devstack add an entry to local.conf that
# looks like
#
# [[local|localrc]]
# enable_plugin ceilometer git://git.openstack.org/openstack/ceilometer
#
2016-03-31 01:57:31 +00:00
# By default all ceilometer services are started (see devstack/settings)
# except for the ceilometer-aipmi service. To disable a specific service
# use the disable_service function.
2015-06-27 11:13:10 +00:00
#
# NOTE: Currently, there are two ways to get the IPMI based meters in
# OpenStack. One way is to configure Ironic conductor to report those meters
# for the nodes managed by Ironic and to have Ceilometer notification
# agent to collect them. Ironic by default does NOT enable that reporting
# functionality. So in order to do so, users need to set the option of
# conductor.send_sensor_data to true in the ironic.conf configuration file
# for the Ironic conductor service, and also enable the
2016-03-31 01:57:31 +00:00
# ceilometer-anotification service.
2015-06-27 11:13:10 +00:00
#
# The other way is to use Ceilometer ipmi agent only to get the IPMI based
2016-03-31 01:57:31 +00:00
# meters. To make use of the Ceilometer ipmi agent, it must be explicitly
# enabled with the following setting:
#
# enable_service ceilometer-aipmi
#
# To avoid duplicated meters, users need to make sure to set the
2015-06-27 11:13:10 +00:00
# option of conductor.send_sensor_data to false in the ironic.conf
# configuration file if the node on which Ceilometer ipmi agent is running
# is also managed by Ironic.
#
# Several variables set in the localrc section adjust common behaviors
# of Ceilometer (see within for additional settings):
#
# CEILOMETER_PIPELINE_INTERVAL: Seconds between pipeline processing runs. Default 600.
2017-10-17 16:14:01 +00:00
# CEILOMETER_BACKEND: Database backend (e.g. 'gnocchi', 'none')
2015-06-27 11:13:10 +00:00
# CEILOMETER_COORDINATION_URL: URL for group membership service provided by tooz.
2015-09-01 16:48:05 +00:00
# CEILOMETER_EVENT_ALARM: Set to True to enable publisher for event alarming
2015-06-27 11:13:10 +00:00
2015-07-16 12:49:13 +00:00
# Save trace setting
XTRACE = $( set +o | grep xtrace)
set -o xtrace
2015-06-27 11:13:10 +00:00
# Support potential entry-points console scripts in VENV or not
if [ [ ${ USE_VENV } = True ] ] ; then
PROJECT_VENV[ "ceilometer" ] = ${ CEILOMETER_DIR } .venv
CEILOMETER_BIN_DIR = ${ PROJECT_VENV [ "ceilometer" ] } /bin
else
CEILOMETER_BIN_DIR = $( get_python_exec_prefix)
fi
# Test if any Ceilometer services are enabled
# is_ceilometer_enabled
function is_ceilometer_enabled {
[ [ ,${ ENABLED_SERVICES } = ~ ,"ceilometer-" ] ] && return 0
return 1
}
2017-05-29 10:21:03 +00:00
function gnocchi_service_url {
echo " $GNOCCHI_SERVICE_PROTOCOL :// $GNOCCHI_SERVICE_HOST /metric "
}
2015-06-27 11:13:10 +00:00
2015-07-10 13:04:12 +00:00
# _ceilometer_install_redis() - Install the redis server and python lib.
function _ceilometer_install_redis {
2015-06-27 11:13:10 +00:00
if is_ubuntu; then
install_package redis-server
restart_service redis-server
else
# This will fail (correctly) where a redis package is unavailable
install_package redis
2017-12-19 10:05:42 +00:00
if is_suse; then
# opensuse intsall multi-instance version of redis
# and admin is expected to install the required conf
cp /etc/redis/default.conf.example /etc/redis/default.conf
restart_service redis@default
else
restart_service redis
fi
2015-06-27 11:13:10 +00:00
fi
pip_install_gr redis
}
# Configure mod_wsgi
2015-07-10 13:04:12 +00:00
function _ceilometer_config_apache_wsgi {
2015-06-27 11:13:10 +00:00
sudo mkdir -p $CEILOMETER_WSGI_DIR
local ceilometer_apache_conf = $( apache_site_config_for ceilometer)
local apache_version = $( get_apache_version)
local venv_path = ""
if [ [ ${ USE_VENV } = True ] ] ; then
venv_path = " python-path= ${ PROJECT_VENV [ "ceilometer" ] } /lib/ $( python_version) /site-packages "
fi
sudo cp $CEILOMETER_DIR /devstack/apache-ceilometer.template $ceilometer_apache_conf
sudo sed -e "
s| %PORT%| $CEILOMETER_SERVICE_PORT | g;
s| %APACHE_NAME%| $APACHE_NAME | g;
s| %WSGIAPP%| $CEILOMETER_WSGI_DIR /app| g;
s| %USER%| $STACK_USER | g;
s| %VIRTUALENV%| $venv_path | g
" -i $ceilometer_apache_conf
}
# Install required services for coordination
2015-07-10 13:04:12 +00:00
function _ceilometer_prepare_coordination {
2015-06-27 11:13:10 +00:00
if echo $CEILOMETER_COORDINATION_URL | grep -q '^memcached:' ; then
install_package memcached
2017-05-29 10:21:03 +00:00
elif [ [ " ${ CEILOMETER_COORDINATOR_URL %% : * } " = = "redis" || " ${ CEILOMETER_CACHE_BACKEND ##*. } " = = "redis" || " ${ CEILOMETER_BACKEND } " = = "gnocchi" ] ] ; then
2015-07-10 13:04:12 +00:00
_ceilometer_install_redis
2015-06-27 11:13:10 +00:00
fi
}
# Install the python modules for inspecting nova virt instances
2015-07-10 13:04:12 +00:00
function _ceilometer_prepare_virt_drivers {
2015-06-27 11:13:10 +00:00
# Only install virt drivers if we're running nova compute
if is_service_enabled n-cpu ; then
if [ [ " $VIRT_DRIVER " = 'libvirt' ] ] ; then
pip_install_gr libvirt-python
fi
if [ [ " $VIRT_DRIVER " = 'vsphere' ] ] ; then
2015-08-06 09:27:32 +00:00
pip_install_gr oslo.vmware
2015-06-27 11:13:10 +00:00
fi
fi
}
# Create ceilometer related accounts in Keystone
2016-03-18 06:24:27 +00:00
function ceilometer_create_accounts {
2016-12-20 18:07:26 +00:00
# At this time, the /etc/openstack/clouds.yaml is available,
# we could leverage that by setting OS_CLOUD
OLD_OS_CLOUD = $OS_CLOUD
export OS_CLOUD = 'devstack-admin'
2015-06-27 11:13:10 +00:00
2016-12-20 18:07:26 +00:00
create_service_user "ceilometer" "admin"
2015-06-27 11:13:10 +00:00
2016-12-20 18:07:26 +00:00
if is_service_enabled swift; then
# Ceilometer needs ResellerAdmin role to access Swift account stats.
get_or_add_user_project_role "ResellerAdmin" "ceilometer" $SERVICE_PROJECT_NAME
2015-06-27 11:13:10 +00:00
fi
2016-12-20 18:07:26 +00:00
2017-06-14 21:50:54 +00:00
if ! [ [ $DEVSTACK_PLUGINS = ~ 'gnocchi' ] ] && [ " $CEILOMETER_BACKEND " = = "gnocchi" ] ; then
2017-05-29 10:21:03 +00:00
create_service_user "gnocchi"
local gnocchi_service = $( get_or_create_service "gnocchi" \
"metric" "OpenStack Metric Service" )
get_or_create_endpoint $gnocchi_service \
" $REGION_NAME " \
" $( gnocchi_service_url) " \
" $( gnocchi_service_url) " \
" $( gnocchi_service_url) "
fi
2016-12-20 18:07:26 +00:00
export OS_CLOUD = $OLD_OS_CLOUD
2015-06-27 11:13:10 +00:00
}
2017-05-29 10:21:03 +00:00
function install_gnocchi {
echo_summary "Installing Gnocchi"
if [ $GNOCCHI_GIT_PATH ] ; then
pip_install -e $GNOCCHI_GIT_PATH [ redis,${ DATABASE_TYPE } ,keystone] uwsgi
else
pip_install gnocchi[ redis,${ DATABASE_TYPE } ,keystone] uwsgi
fi
2018-01-16 08:15:39 +00:00
}
function configure_gnocchi {
echo_summary "Configure Gnocchi"
2017-05-29 10:21:03 +00:00
recreate_database gnocchi
sudo install -d -o $STACK_USER -m 755 $GNOCCHI_CONF_DIR
iniset $GNOCCHI_CONF DEFAULT debug " $ENABLE_DEBUG_LOG_LEVEL "
iniset $GNOCCHI_CONF indexer url ` database_connection_url gnocchi`
iniset $GNOCCHI_CONF storage driver redis
iniset $GNOCCHI_CONF storage redis_url redis://localhost:6379
iniset $GNOCCHI_CONF metricd metric_processing_delay " $GNOCCHI_METRICD_PROCESSING_DELAY "
iniset $GNOCCHI_CONF api auth_mode keystone
configure_auth_token_middleware $GNOCCHI_CONF gnocchi $GNOCCHI_AUTH_CACHE_DIR
sudo mkdir -p $GNOCCHI_AUTH_CACHE_DIR
sudo chown $STACK_USER $GNOCCHI_AUTH_CACHE_DIR
rm -f $GNOCCHI_AUTH_CACHE_DIR /*
gnocchi-upgrade
rm -f " $GNOCCHI_UWSGI_FILE "
2017-06-14 20:07:37 +00:00
write_uwsgi_config " $GNOCCHI_UWSGI_FILE " " $CEILOMETER_BIN_DIR /gnocchi-api " "/metric"
2017-05-29 10:21:03 +00:00
if [ -n " $GNOCCHI_COORDINATOR_URL " ] ; then
iniset $GNOCCHI_CONF storage coordination_url " $GNOCCHI_COORDINATOR_URL "
fi
}
2015-06-27 11:13:10 +00:00
# Activities to do before ceilometer has been installed.
function preinstall_ceilometer {
echo_summary "Preinstall not in virtualenv context. Skipping."
}
2015-11-24 17:45:20 +00:00
# cleanup_ceilometer() - Remove residual data files, anything left over
# from previous runs that a clean run would need to clean up
function cleanup_ceilometer {
sudo rm -f " $CEILOMETER_CONF_DIR " /*
sudo rmdir " $CEILOMETER_CONF_DIR "
2015-06-27 11:13:10 +00:00
}
2015-12-09 22:07:47 +00:00
# Set configuraiton for cache backend.
# NOTE(cdent): This currently only works for redis. Still working
# out how to express the other backends.
function _ceilometer_configure_cache_backend {
2016-10-17 16:15:56 +00:00
iniset $CEILOMETER_CONF cache enabled True
2015-12-09 22:07:47 +00:00
iniset $CEILOMETER_CONF cache backend $CEILOMETER_CACHE_BACKEND
2017-02-09 22:30:17 +00:00
inidelete $CEILOMETER_CONF cache backend_argument
iniadd $CEILOMETER_CONF cache backend_argument url:$CEILOMETER_CACHE_URL
iniadd $CEILOMETER_CONF cache backend_argument distributed_lock:True
2015-12-09 22:07:47 +00:00
if [ [ " ${ CEILOMETER_CACHE_BACKEND ##*. } " = = "redis" ] ] ; then
2017-02-09 22:30:17 +00:00
iniadd $CEILOMETER_CONF cache backend_argument db:0
iniadd $CEILOMETER_CONF cache backend_argument redis_expiration_time:600
2015-12-09 22:07:47 +00:00
fi
}
2015-06-27 11:13:10 +00:00
# Set configuration for storage backend.
2015-07-10 13:04:12 +00:00
function _ceilometer_configure_storage_backend {
2017-01-24 15:15:58 +00:00
if [ " $CEILOMETER_BACKEND " = 'none' ] ; then
# It's ok for the backend to be 'none', if panko is enabled. We do not
# combine this condition with the outer if statement, so that the else
# clause below is not executed.
if ! is_service_enabled panko-api; then
echo_summary "All Ceilometer backends seems disabled, set \$CEILOMETER_BACKEND to select one."
fi
2015-12-30 13:34:44 +00:00
elif [ " $CEILOMETER_BACKEND " = 'gnocchi' ] ; then
2017-09-04 11:47:58 +00:00
sed -i " s/gnocchi:\/\//gnocchi:\/\/?archive_policy= ${ GNOCCHI_ARCHIVE_POLICY } \&filter_project=gnocchi_swift/ " $CEILOMETER_CONF_DIR /event_pipeline.yaml $CEILOMETER_CONF_DIR /pipeline.yaml
2018-01-16 08:15:39 +00:00
! [ [ $DEVSTACK_PLUGINS = ~ 'gnocchi' ] ] && configure_gnocchi
2015-06-27 11:13:10 +00:00
else
die $LINENO " Unable to configure unknown CEILOMETER_BACKEND $CEILOMETER_BACKEND "
fi
2017-01-10 17:59:40 +00:00
# configure panko
if is_service_enabled panko-api; then
2017-01-22 04:01:25 +00:00
if ! grep -q 'panko' $CEILOMETER_CONF_DIR /event_pipeline.yaml ; then
2017-03-06 02:55:38 +00:00
echo ' - panko://' >> $CEILOMETER_CONF_DIR /event_pipeline.yaml
2017-01-22 04:01:25 +00:00
fi
2017-01-10 17:59:40 +00:00
fi
2015-06-27 11:13:10 +00:00
}
# Configure Ceilometer
function configure_ceilometer {
2015-10-09 13:12:29 +00:00
local conffile
2015-06-27 11:13:10 +00:00
iniset_rpc_backend ceilometer $CEILOMETER_CONF
2016-03-17 00:55:54 +00:00
iniset $CEILOMETER_CONF oslo_messaging_notifications topics " $CEILOMETER_NOTIFICATION_TOPICS "
2015-06-27 11:13:10 +00:00
iniset $CEILOMETER_CONF DEFAULT debug " $ENABLE_DEBUG_LOG_LEVEL "
if [ [ -n " $CEILOMETER_COORDINATION_URL " ] ] ; then
iniset $CEILOMETER_CONF coordination backend_url $CEILOMETER_COORDINATION_URL
2016-01-14 20:31:24 +00:00
iniset $CEILOMETER_CONF notification workload_partitioning True
iniset $CEILOMETER_CONF notification workers $API_WORKERS
2015-06-27 11:13:10 +00:00
fi
2015-12-09 22:07:47 +00:00
if [ [ -n " $CEILOMETER_CACHE_BACKEND " ] ] ; then
_ceilometer_configure_cache_backend
fi
2015-10-09 13:12:29 +00:00
# Install the policy file and declarative configuration files to
# the conf dir.
# NOTE(cdent): Do not make this a glob as it will conflict
# with rootwrap installation done elsewhere and also clobber
# ceilometer.conf settings that have already been made.
# Anyway, explicit is better than implicit.
2017-06-20 15:04:45 +00:00
cp $CEILOMETER_DIR /etc/ceilometer/polling_all.yaml $CEILOMETER_CONF_DIR /polling.yaml
2015-06-27 11:13:10 +00:00
2017-03-06 02:55:38 +00:00
cp $CEILOMETER_DIR /ceilometer/pipeline/data/*.yaml $CEILOMETER_CONF_DIR
2015-06-27 11:13:10 +00:00
if [ " $CEILOMETER_PIPELINE_INTERVAL " ] ; then
2016-11-30 16:53:08 +00:00
sed -i " s/interval:.*/interval: ${ CEILOMETER_PIPELINE_INTERVAL } / " $CEILOMETER_CONF_DIR /polling.yaml
2015-06-27 11:13:10 +00:00
fi
2015-09-01 16:48:05 +00:00
if [ " $CEILOMETER_EVENT_ALARM " = = "True" ] ; then
if ! grep -q '^ *- notifier://?topic=alarm.all$' $CEILOMETER_CONF_DIR /event_pipeline.yaml; then
sed -i '/^ *publishers:$/,+1s|^\( *\)-.*$|\1- notifier://?topic=alarm.all\n&|' $CEILOMETER_CONF_DIR /event_pipeline.yaml
fi
fi
2015-06-27 11:13:10 +00:00
# The compute and central agents need these credentials in order to
# call out to other services' public APIs.
2016-02-01 07:49:01 +00:00
iniset $CEILOMETER_CONF service_credentials auth_type password
2016-02-10 09:12:25 +00:00
iniset $CEILOMETER_CONF service_credentials user_domain_id default
iniset $CEILOMETER_CONF service_credentials project_domain_id default
2016-02-23 03:41:24 +00:00
iniset $CEILOMETER_CONF service_credentials project_name $SERVICE_PROJECT_NAME
2016-02-01 07:49:01 +00:00
iniset $CEILOMETER_CONF service_credentials username ceilometer
iniset $CEILOMETER_CONF service_credentials password $SERVICE_PASSWORD
iniset $CEILOMETER_CONF service_credentials region_name $REGION_NAME
iniset $CEILOMETER_CONF service_credentials auth_url $KEYSTONE_SERVICE_URI
2015-06-27 11:13:10 +00:00
configure_auth_token_middleware $CEILOMETER_CONF ceilometer $CEILOMETER_AUTH_CACHE_DIR
if [ [ " $VIRT_DRIVER " = 'vsphere' ] ] ; then
iniset $CEILOMETER_CONF DEFAULT hypervisor_inspector vsphere
iniset $CEILOMETER_CONF vmware host_ip " $VMWAREAPI_IP "
iniset $CEILOMETER_CONF vmware host_username " $VMWAREAPI_USER "
iniset $CEILOMETER_CONF vmware host_password " $VMWAREAPI_PASSWORD "
fi
2017-10-16 09:31:51 +00:00
_ceilometer_configure_storage_backend
2015-06-27 11:13:10 +00:00
if is_service_enabled ceilometer-aipmi; then
# Configure rootwrap for the ipmi agent
configure_rootwrap ceilometer
fi
}
# init_ceilometer() - Initialize etc.
function init_ceilometer {
# Create cache dir
sudo install -d -o $STACK_USER $CEILOMETER_AUTH_CACHE_DIR
rm -f $CEILOMETER_AUTH_CACHE_DIR /*
}
# Install Ceilometer.
# The storage and coordination backends are installed here because the
# virtualenv context is active at this point and python drivers need to be
# installed. The context is not active during preinstall (when it would
# otherwise makes sense to do the backend services).
function install_ceilometer {
2017-05-29 10:21:03 +00:00
if is_service_enabled ceilometer-acentral ceilometer-acompute ceilometer-anotification gnocchi-api gnocchi-metricd; then
2015-11-11 08:15:58 +00:00
_ceilometer_prepare_coordination
fi
2017-06-14 21:50:54 +00:00
! [ [ $DEVSTACK_PLUGINS = ~ 'gnocchi' ] ] && [ " $CEILOMETER_BACKEND " = 'gnocchi' ] && install_gnocchi
2017-05-29 10:21:03 +00:00
2015-11-11 08:15:58 +00:00
if is_service_enabled ceilometer-acompute ; then
_ceilometer_prepare_virt_drivers
fi
2017-09-28 12:08:19 +00:00
case $CEILOMETER_BACKEND in
gnocchi) extra = gnocchi; ;
esac
setup_develop $CEILOMETER_DIR $extra
2015-10-22 14:37:14 +00:00
sudo install -d -o $STACK_USER -m 755 $CEILOMETER_CONF_DIR
2015-06-27 11:13:10 +00:00
}
# start_ceilometer() - Start running processes, including screen
function start_ceilometer {
2017-05-29 10:21:03 +00:00
2017-06-14 21:50:54 +00:00
if ! [ [ $DEVSTACK_PLUGINS = ~ 'gnocchi' ] ] && [ " $CEILOMETER_BACKEND " = "gnocchi" ] ; then
2017-06-14 20:07:37 +00:00
run_process gnocchi-api " $CEILOMETER_BIN_DIR /uwsgi --ini $GNOCCHI_UWSGI_FILE " ""
run_process gnocchi-metricd " $CEILOMETER_BIN_DIR /gnocchi-metricd --config-file $GNOCCHI_CONF "
2017-05-29 10:21:03 +00:00
wait_for_service 30 " $( gnocchi_service_url) "
2017-10-17 16:14:01 +00:00
$CEILOMETER_BIN_DIR /ceilometer-upgrade
2017-05-29 10:21:03 +00:00
fi
2015-08-13 12:00:03 +00:00
run_process ceilometer-acentral " $CEILOMETER_BIN_DIR /ceilometer-polling --polling-namespaces central --config-file $CEILOMETER_CONF "
run_process ceilometer-aipmi " $CEILOMETER_BIN_DIR /ceilometer-polling --polling-namespaces ipmi --config-file $CEILOMETER_CONF "
2015-06-27 11:13:10 +00:00
2017-09-14 21:23:37 +00:00
# run the notification agent after restarting apache as it needs
2015-07-15 16:28:36 +00:00
# operational keystone if using gnocchi
2017-03-13 20:11:55 +00:00
run_process ceilometer-anotification " $CEILOMETER_BIN_DIR /ceilometer-agent-notification --config-file $CEILOMETER_CONF "
2015-07-15 16:28:36 +00:00
2017-09-14 21:23:37 +00:00
# Start the compute agent late to allow time for the notification agent to
2015-06-27 11:13:10 +00:00
# fully wake up and connect to the message bus. See bug #1355809
if [ [ " $VIRT_DRIVER " = 'libvirt' ] ] ; then
2015-08-13 12:00:03 +00:00
run_process ceilometer-acompute " $CEILOMETER_BIN_DIR /ceilometer-polling --polling-namespaces compute --config-file $CEILOMETER_CONF " $LIBVIRT_GROUP
2015-06-27 11:13:10 +00:00
fi
if [ [ " $VIRT_DRIVER " = 'vsphere' ] ] ; then
2015-08-13 12:00:03 +00:00
run_process ceilometer-acompute " $CEILOMETER_BIN_DIR /ceilometer-polling --polling-namespaces compute --config-file $CEILOMETER_CONF "
2015-06-27 11:13:10 +00:00
fi
}
# stop_ceilometer() - Stop running processes
function stop_ceilometer {
2015-10-05 14:27:50 +00:00
2015-06-27 11:13:10 +00:00
# Kill the ceilometer screen windows
2017-09-14 21:23:37 +00:00
for serv in ceilometer-acompute ceilometer-acentral ceilometer-aipmi ceilometer-anotification; do
2015-06-27 11:13:10 +00:00
stop_process $serv
done
}
# This is the main for plugin.sh
if is_service_enabled ceilometer; then
if [ [ " $1 " = = "stack" && " $2 " = = "pre-install" ] ] ; then
# Set up other services
echo_summary "Configuring system services for Ceilometer"
preinstall_ceilometer
elif [ [ " $1 " = = "stack" && " $2 " = = "install" ] ] ; then
echo_summary "Installing Ceilometer"
2016-12-07 07:04:04 +00:00
# Use stack_install_service here to account for virtualenv
2015-06-27 11:13:10 +00:00
stack_install_service ceilometer
elif [ [ " $1 " = = "stack" && " $2 " = = "post-config" ] ] ; then
echo_summary "Configuring Ceilometer"
configure_ceilometer
2016-03-18 06:24:27 +00:00
# Get ceilometer keystone settings in place
ceilometer_create_accounts
2015-06-27 11:13:10 +00:00
elif [ [ " $1 " = = "stack" && " $2 " = = "extra" ] ] ; then
echo_summary "Initializing Ceilometer"
# Tidy base for ceilometer
init_ceilometer
# Start the services
start_ceilometer
2017-04-25 12:31:00 +00:00
elif [ [ " $1 " = = "stack" && " $2 " = = "test-config" ] ] ; then
iniset $TEMPEST_CONFIG telemetry alarm_granularity $CEILOMETER_ALARM_GRANULARITY
2015-06-27 11:13:10 +00:00
fi
if [ [ " $1 " = = "unstack" ] ] ; then
echo_summary "Shutting Down Ceilometer"
stop_ceilometer
fi
if [ [ " $1 " = = "clean" ] ] ; then
echo_summary "Cleaning Ceilometer"
cleanup_ceilometer
fi
fi
2015-07-16 12:49:13 +00:00
# Restore xtrace
$XTRACE