blob: 9abdbfe286c2281d9ab990d44723d82abcbf870d [file] [log] [blame]
Sean Daguee263c822014-12-05 14:25:28 -05001#!/bin/bash
2#
John H. Tran93361642012-07-26 11:22:05 -07003# lib/ceilometer
Dean Troyer6d04fd72012-12-21 11:03:37 -06004# Install and start **Ceilometer** service
5
Chris Denta9c25942014-12-08 14:26:28 +00006# To enable a minimal set of Ceilometer services, add the following to the
Dean Troyerdc97cb72015-03-28 08:20:50 -05007# ``localrc`` section of ``local.conf``:
Adam Spierscb961592013-10-05 12:11:07 +01008#
Gordon Chung1c402282013-11-26 13:30:11 -05009# enable_service ceilometer-acompute ceilometer-acentral ceilometer-anotification ceilometer-collector ceilometer-api
Eoghan Glynn8d137032013-07-30 14:14:55 +000010#
Chris Denta9c25942014-12-08 14:26:28 +000011# To ensure Ceilometer alarming services are enabled also, further add to the
12# localrc section of local.conf:
Adam Spierscb961592013-10-05 12:11:07 +010013#
Eoghan Glynn19eed742013-09-20 21:11:25 +000014# enable_service ceilometer-alarm-notifier ceilometer-alarm-evaluator
Chris Denta9c25942014-12-08 14:26:28 +000015#
Lianhao Luc39f6402015-03-24 12:36:00 +080016# To enable Ceilometer to collect the IPMI based meters, further add to the
17# localrc section of local.conf:
18#
19# enable_service ceilometer-aipmi
20#
21# NOTE: Currently, there are two ways to get the IPMI based meters in
22# OpenStack. One way is to configure Ironic conductor to report those meters
23# for the nodes managed by Ironic and to have Ceilometer notification
24# agent to collect them. Ironic by default does NOT enable that reporting
25# functionality. So in order to do so, users need to set the option of
26# conductor.send_sensor_data to true in the ironic.conf configuration file
27# for the Ironic conductor service, and also enable the
28# ceilometer-anotification service.
29#
30# The other way is to use Ceilometer ipmi agent only to get the IPMI based
31# meters. To avoid duplicated meters, users need to make sure to set the
32# option of conductor.send_sensor_data to false in the ironic.conf
33# configuration file if the node on which Ceilometer ipmi agent is running
34# is also managed by Ironic.
35#
Chris Denta9c25942014-12-08 14:26:28 +000036# Several variables set in the localrc section adjust common behaviors
37# of Ceilometer (see within for additional settings):
38#
39# CEILOMETER_USE_MOD_WSGI: When True, run the api under mod_wsgi.
Dean Troyerdc97cb72015-03-28 08:20:50 -050040# CEILOMETER_PIPELINE_INTERVAL: Seconds between pipeline processing runs. Default 600.
41# CEILOMETER_BACKEND: Database backend (e.g. 'mysql', 'mongodb', 'es')
42# CEILOMETER_COORDINATION_URL: URL for group membership service provided by tooz.
gordon chung76e724b2015-02-11 18:28:37 -050043# CEILOMETER_EVENTS: Enable event collection
Chris Denta9c25942014-12-08 14:26:28 +000044
John H. Tran93361642012-07-26 11:22:05 -070045# Dependencies:
Adam Spiers6a5aa7c2013-10-24 11:27:02 +010046#
John H. Tran93361642012-07-26 11:22:05 -070047# - functions
Doug Hellmann4a2b1c62012-11-01 16:23:52 -040048# - OS_AUTH_URL for auth in api
Eoghan Glynnad80ead2012-09-27 09:36:33 +010049# - DEST set to the destination directory
Doug Hellmann4a2b1c62012-11-01 16:23:52 -040050# - SERVICE_PASSWORD, SERVICE_TENANT_NAME for auth in api
Attila Fazekas91b8d132013-01-06 22:40:09 +010051# - STACK_USER service user
John H. Tran93361642012-07-26 11:22:05 -070052
53# stack.sh
54# ---------
Adam Spiers6a5aa7c2013-10-24 11:27:02 +010055# - install_ceilometer
56# - configure_ceilometer
57# - init_ceilometer
58# - start_ceilometer
59# - stop_ceilometer
60# - cleanup_ceilometer
John H. Tran93361642012-07-26 11:22:05 -070061
Dean Troyer7903b792012-09-13 17:16:12 -050062# Save trace setting
63XTRACE=$(set +o | grep xtrace)
64set +o xtrace
John H. Tran93361642012-07-26 11:22:05 -070065
66
67# Defaults
68# --------
69
Dean Troyer6d04fd72012-12-21 11:03:37 -060070# Set up default directories
Sean Daguee08ab102014-11-13 17:09:28 -050071GITDIR["python-ceilometerclient"]=$DEST/python-ceilometerclient
gordon chungad61e7f2015-02-12 15:17:25 -050072GITDIR["ceilometermiddleware"]=$DEST/ceilometermiddleware
Sean Dague5cb19062014-11-01 01:37:45 +010073
John H. Tran93361642012-07-26 11:22:05 -070074CEILOMETER_DIR=$DEST/ceilometer
Dean Troyer6d04fd72012-12-21 11:03:37 -060075CEILOMETER_CONF_DIR=/etc/ceilometer
76CEILOMETER_CONF=$CEILOMETER_CONF_DIR/ceilometer.conf
77CEILOMETER_API_LOG_DIR=/var/log/ceilometer-api
Lianhao Lu8c548492013-01-09 10:41:54 +080078CEILOMETER_AUTH_CACHE_DIR=${CEILOMETER_AUTH_CACHE_DIR:-/var/cache/ceilometer}
Chris Dentae6fb182014-09-16 15:17:13 +010079CEILOMETER_WSGI_DIR=${CEILOMETER_WSGI_DIR:-/var/www/ceilometer}
Dean Troyer6d04fd72012-12-21 11:03:37 -060080
Monty Taylor9fbeedd2012-08-17 12:52:27 -040081# Support potential entry-points console scripts
Guangyu Suo9778b3c2013-07-17 15:22:21 +080082CEILOMETER_BIN_DIR=$(get_python_exec_prefix)
John H. Tran93361642012-07-26 11:22:05 -070083
Guangyu Suo9778b3c2013-07-17 15:22:21 +080084# Set up database backend
Julien Danjou69f74572013-08-27 11:43:53 +020085CEILOMETER_BACKEND=${CEILOMETER_BACKEND:-mysql}
Dean Troyercc6b4432013-04-08 15:38:03 -050086
Dirk Muellerfa5ccff2014-01-09 13:27:35 +010087# Ceilometer connection info.
88CEILOMETER_SERVICE_PROTOCOL=http
89CEILOMETER_SERVICE_HOST=$SERVICE_HOST
90CEILOMETER_SERVICE_PORT=${CEILOMETER_SERVICE_PORT:-8777}
Sean Dague53753292014-12-04 19:38:15 -050091CEILOMETER_USE_MOD_WSGI=$(trueorfalse False CEILOMETER_USE_MOD_WSGI)
Dean Troyer4237f592014-01-29 16:22:11 -060092
Boris Pavlovic46e1aba2014-07-01 14:15:52 +040093# To enable OSprofiler change value of this variable to "notifications,profiler"
94CEILOMETER_NOTIFICATION_TOPICS=${CEILOMETER_NOTIFICATION_TOPICS:-notifications}
gordon chung76e724b2015-02-11 18:28:37 -050095CEILOMETER_EVENTS=${CEILOMETER_EVENTS:-True}
Boris Pavlovic46e1aba2014-07-01 14:15:52 +040096
Sean Dague53753292014-12-04 19:38:15 -050097CEILOMETER_COORDINATION_URL=${CEILOMETER_COORDINATION_URL:-}
98CEILOMETER_PIPELINE_INTERVAL=${CEILOMETER_PIPELINE_INTERVAL:-}
99
Dean Troyer4237f592014-01-29 16:22:11 -0600100# Tell Tempest this project is present
101TEMPEST_SERVICES+=,ceilometer
102
Dirk Muellerfa5ccff2014-01-09 13:27:35 +0100103
Dean Troyercc6b4432013-04-08 15:38:03 -0500104# Functions
105# ---------
Dean Troyere4fa7212014-01-15 15:04:49 -0600106
107# Test if any Ceilometer services are enabled
108# is_ceilometer_enabled
109function is_ceilometer_enabled {
110 [[ ,${ENABLED_SERVICES} =~ ,"ceilometer-" ]] && return 0
111 return 1
112}
113
Dean Troyerdc97cb72015-03-28 08:20:50 -0500114# create_ceilometer_accounts() - Set up common required Ceilometer accounts
Chris Dent67bc8e82014-10-08 12:07:46 +0100115#
Dean Troyer42a59c22014-03-03 14:31:29 -0600116# Project User Roles
117# ------------------------------------------------------------------
118# SERVICE_TENANT_NAME ceilometer admin
119# SERVICE_TENANT_NAME ceilometer ResellerAdmin (if Swift is enabled)
Chris Dent67bc8e82014-10-08 12:07:46 +0100120function create_ceilometer_accounts {
Dirk Muellerfa5ccff2014-01-09 13:27:35 +0100121
Dirk Muellerfa5ccff2014-01-09 13:27:35 +0100122 # Ceilometer
123 if [[ "$ENABLED_SERVICES" =~ "ceilometer-api" ]]; then
Jamie Lennox85ff5322015-01-28 14:28:01 +1000124
Chris Dent230e03a2015-02-16 22:07:00 +0000125 create_service_user "ceilometer" "admin"
Bartosz Górski0abde392014-02-28 14:15:19 +0100126
Dirk Muellerfa5ccff2014-01-09 13:27:35 +0100127 if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
Dean Troyer16ef9762014-08-19 19:31:34 -0500128 local ceilometer_service=$(get_or_create_service "ceilometer" \
Bartosz Górski0abde392014-02-28 14:15:19 +0100129 "metering" "OpenStack Telemetry Service")
Dean Troyer16ef9762014-08-19 19:31:34 -0500130 get_or_create_endpoint $ceilometer_service \
Bartosz Górski0abde392014-02-28 14:15:19 +0100131 "$REGION_NAME" \
132 "$CEILOMETER_SERVICE_PROTOCOL://$CEILOMETER_SERVICE_HOST:$CEILOMETER_SERVICE_PORT/" \
133 "$CEILOMETER_SERVICE_PROTOCOL://$CEILOMETER_SERVICE_HOST:$CEILOMETER_SERVICE_PORT/" \
134 "$CEILOMETER_SERVICE_PROTOCOL://$CEILOMETER_SERVICE_HOST:$CEILOMETER_SERVICE_PORT/"
Dirk Muellerfa5ccff2014-01-09 13:27:35 +0100135 fi
Dean Troyer42a59c22014-03-03 14:31:29 -0600136 if is_service_enabled swift; then
Dean Troyerdc97cb72015-03-28 08:20:50 -0500137 # Ceilometer needs ResellerAdmin role to access Swift account stats.
Jamie Lennox9b215db2015-02-10 18:19:57 +1100138 get_or_add_user_project_role "ResellerAdmin" "ceilometer" $SERVICE_TENANT_NAME
Dean Troyer42a59c22014-03-03 14:31:29 -0600139 fi
Dirk Muellerfa5ccff2014-01-09 13:27:35 +0100140 fi
141}
142
Dean Troyercc6b4432013-04-08 15:38:03 -0500143
Dean Troyerdc97cb72015-03-28 08:20:50 -0500144# _cleanup_keystone_apache_wsgi() - Remove WSGI files, disable and remove Apache vhost file
Chris Dentae6fb182014-09-16 15:17:13 +0100145function _cleanup_ceilometer_apache_wsgi {
146 sudo rm -f $CEILOMETER_WSGI_DIR/*
147 sudo rm -f $(apache_site_config_for ceilometer)
148}
149
John H. Tran93361642012-07-26 11:22:05 -0700150# cleanup_ceilometer() - Remove residual data files, anything left over from previous
151# runs that a clean run would need to clean up
Ian Wienandaee18c72014-02-21 15:35:08 +1100152function cleanup_ceilometer {
gordon chung76e724b2015-02-11 18:28:37 -0500153 if [ "$CEILOMETER_BACKEND" = 'mongodb' ] ; then
Ian Wienand936284b2014-03-11 09:35:55 +1100154 mongo ceilometer --eval "db.dropDatabase();"
gordon chung76e724b2015-02-11 18:28:37 -0500155 elif [ "$CEILOMETER_BACKEND" = 'es' ] ; then
156 curl -XDELETE "localhost:9200/events_*"
Ian Wienand936284b2014-03-11 09:35:55 +1100157 fi
Chris Dentae6fb182014-09-16 15:17:13 +0100158 if [ "$CEILOMETER_USE_MOD_WSGI" == "True" ]; then
159 _cleanup_ceilometer_apache_wsgi
160 fi
161}
162
163function _config_ceilometer_apache_wsgi {
164 sudo mkdir -p $CEILOMETER_WSGI_DIR
165
166 local ceilometer_apache_conf=$(apache_site_config_for ceilometer)
167 local apache_version=$(get_apache_version)
168
Dean Troyerdc97cb72015-03-28 08:20:50 -0500169 # Copy proxy vhost and wsgi file
Chris Dentae6fb182014-09-16 15:17:13 +0100170 sudo cp $CEILOMETER_DIR/ceilometer/api/app.wsgi $CEILOMETER_WSGI_DIR/app
171
172 sudo cp $FILES/apache-ceilometer.template $ceilometer_apache_conf
173 sudo sed -e "
174 s|%PORT%|$CEILOMETER_SERVICE_PORT|g;
175 s|%APACHE_NAME%|$APACHE_NAME|g;
176 s|%WSGIAPP%|$CEILOMETER_WSGI_DIR/app|g;
177 s|%USER%|$STACK_USER|g
178 " -i $ceilometer_apache_conf
John H. Tran93361642012-07-26 11:22:05 -0700179}
180
181# configure_ceilometer() - Set config files, create data dirs, etc
Ian Wienandaee18c72014-02-21 15:35:08 +1100182function configure_ceilometer {
Dean Troyer8421c2b2015-03-16 13:52:19 -0500183 sudo install -d -o $STACK_USER -m 755 $CEILOMETER_CONF_DIR $CEILOMETER_API_LOG_DIR
John H. Tran93361642012-07-26 11:22:05 -0700184
Brant Knudson2dd110c2015-03-14 12:39:14 -0500185 iniset_rpc_backend ceilometer $CEILOMETER_CONF
Eoghan Glynnd36268a2013-02-22 21:59:52 +0000186
Boris Pavlovic46e1aba2014-07-01 14:15:52 +0400187 iniset $CEILOMETER_CONF DEFAULT notification_topics "$CEILOMETER_NOTIFICATION_TOPICS"
Julien Danjou4b3e4e52012-10-24 16:32:01 +0200188 iniset $CEILOMETER_CONF DEFAULT verbose True
Nadya Privalova423d7902014-03-06 15:14:59 +0400189 iniset $CEILOMETER_CONF DEFAULT debug "$ENABLE_DEBUG_LOG_LEVEL"
Doug Hellmann53a5f422012-10-02 17:29:23 -0400190
Chris Dent8abd8592014-10-08 15:24:25 +0100191 if [[ -n "$CEILOMETER_COORDINATION_URL" ]]; then
192 iniset $CEILOMETER_CONF coordination backend_url $CEILOMETER_COORDINATION_URL
193 iniset $CEILOMETER_CONF compute workload_partitioning True
194 fi
195
Doug Hellmann4a2b1c62012-11-01 16:23:52 -0400196 # Install the policy file for the API server
197 cp $CEILOMETER_DIR/etc/ceilometer/policy.json $CEILOMETER_CONF_DIR
Chris Dent74a85b02015-04-22 18:02:39 +0000198 iniset $CEILOMETER_CONF oslo_policy policy_file $CEILOMETER_CONF_DIR/policy.json
Doug Hellmann4a2b1c62012-11-01 16:23:52 -0400199
ZhiQiang Fan95053cf2014-05-16 16:27:41 +0800200 cp $CEILOMETER_DIR/etc/ceilometer/pipeline.yaml $CEILOMETER_CONF_DIR
gordon chung99f5bcc2015-02-03 09:23:39 -0500201 cp $CEILOMETER_DIR/etc/ceilometer/event_pipeline.yaml $CEILOMETER_CONF_DIR
ZhiQiang Fan95053cf2014-05-16 16:27:41 +0800202 cp $CEILOMETER_DIR/etc/ceilometer/api_paste.ini $CEILOMETER_CONF_DIR
203 cp $CEILOMETER_DIR/etc/ceilometer/event_definitions.yaml $CEILOMETER_CONF_DIR
204
Mehdi Abaakouk8ceb7942013-10-23 09:26:25 +0200205 if [ "$CEILOMETER_PIPELINE_INTERVAL" ]; then
206 sed -i "s/interval:.*/interval: ${CEILOMETER_PIPELINE_INTERVAL}/" $CEILOMETER_CONF_DIR/pipeline.yaml
207 fi
208
Dean Troyerdc97cb72015-03-28 08:20:50 -0500209 # The compute and central agents need these credentials in order to
210 # call out to other services' public APIs.
211 # The alarm evaluator needs these options to call ceilometer APIs
ZhiQiang Fan1af4afb2014-04-16 14:52:12 +0800212 iniset $CEILOMETER_CONF service_credentials os_username ceilometer
213 iniset $CEILOMETER_CONF service_credentials os_password $SERVICE_PASSWORD
214 iniset $CEILOMETER_CONF service_credentials os_tenant_name $SERVICE_TENANT_NAME
Ethan Lynna134f652015-01-12 12:59:30 +0800215 iniset $CEILOMETER_CONF service_credentials os_region_name $REGION_NAME
216 iniset $CEILOMETER_CONF service_credentials os_auth_url $KEYSTONE_SERVICE_URI/v2.0
Eoghan Glynn14246ac2012-11-14 16:23:04 +0000217
Brant Knudson05952372014-09-19 17:22:22 -0500218 configure_auth_token_middleware $CEILOMETER_CONF ceilometer $CEILOMETER_AUTH_CACHE_DIR
Doug Hellmann4a2b1c62012-11-01 16:23:52 -0400219
gordon chung76e724b2015-02-11 18:28:37 -0500220 iniset $CEILOMETER_CONF notification store_events $CEILOMETER_EVENTS
221
Thomas Maddox246d9bb2013-10-24 18:57:40 +0000222 if [ "$CEILOMETER_BACKEND" = 'mysql' ] || [ "$CEILOMETER_BACKEND" = 'postgresql' ] ; then
gordon chung48bbfe92014-11-19 15:54:17 -0500223 iniset $CEILOMETER_CONF database alarm_connection $(database_connection_url ceilometer)
224 iniset $CEILOMETER_CONF database event_connection $(database_connection_url ceilometer)
225 iniset $CEILOMETER_CONF database metering_connection $(database_connection_url ceilometer)
Dean Troyer05bd7b82014-09-16 17:25:33 -0500226 iniset $CEILOMETER_CONF DEFAULT collector_workers $API_WORKERS
gordon chung76e724b2015-02-11 18:28:37 -0500227 elif [ "$CEILOMETER_BACKEND" = 'es' ] ; then
228 # es is only supported for events. we will use sql for alarming/metering.
229 iniset $CEILOMETER_CONF database alarm_connection $(database_connection_url ceilometer)
230 iniset $CEILOMETER_CONF database event_connection es://localhost:9200
231 iniset $CEILOMETER_CONF database metering_connection $(database_connection_url ceilometer)
232 iniset $CEILOMETER_CONF DEFAULT collector_workers $API_WORKERS
233 ${TOP_DIR}/pkg/elasticsearch.sh start
234 cleanup_ceilometer
Guangyu Suo9778b3c2013-07-17 15:22:21 +0800235 else
gordon chung48bbfe92014-11-19 15:54:17 -0500236 iniset $CEILOMETER_CONF database alarm_connection mongodb://localhost:27017/ceilometer
237 iniset $CEILOMETER_CONF database event_connection mongodb://localhost:27017/ceilometer
238 iniset $CEILOMETER_CONF database metering_connection mongodb://localhost:27017/ceilometer
Guangyu Suo9778b3c2013-07-17 15:22:21 +0800239 configure_mongodb
240 cleanup_ceilometer
241 fi
Piyush Masrani846609b2014-03-14 19:21:48 +0530242
243 if [[ "$VIRT_DRIVER" = 'vsphere' ]]; then
244 iniset $CEILOMETER_CONF DEFAULT hypervisor_inspector vsphere
245 iniset $CEILOMETER_CONF vmware host_ip "$VMWAREAPI_IP"
246 iniset $CEILOMETER_CONF vmware host_username "$VMWAREAPI_USER"
247 iniset $CEILOMETER_CONF vmware host_password "$VMWAREAPI_PASSWORD"
248 fi
Chris Dentae6fb182014-09-16 15:17:13 +0100249
250 if [ "$CEILOMETER_USE_MOD_WSGI" == "True" ]; then
251 iniset $CEILOMETER_CONF api pecan_debug "False"
252 _config_ceilometer_apache_wsgi
253 fi
Lianhao Luc39f6402015-03-24 12:36:00 +0800254
255 if is_service_enabled ceilometer-aipmi; then
256 # Configure rootwrap for the ipmi agent
257 configure_rootwrap ceilometer $CEILOMETER_BIN_DIR/ceilometer-rootwrap $CEILOMETER_DIR/etc/ceilometer
258 fi
John H. Tran93361642012-07-26 11:22:05 -0700259}
260
Ian Wienandaee18c72014-02-21 15:35:08 +1100261function configure_mongodb {
Dean Troyerdc97cb72015-03-28 08:20:50 -0500262 # Server package is the same on all
Ian Wienand936284b2014-03-11 09:35:55 +1100263 local packages=mongodb-server
264
Dean Troyercc6b4432013-04-08 15:38:03 -0500265 if is_fedora; then
Ian Wienand936284b2014-03-11 09:35:55 +1100266 # mongodb client + python bindings
267 packages="${packages} mongodb pymongo"
268 else
269 packages="${packages} python-pymongo"
270 fi
271
272 install_package ${packages}
273
274 if is_fedora; then
Dean Troyerdc97cb72015-03-28 08:20:50 -0500275 # Ensure smallfiles is selected to minimize freespace requirements
Eoghan Glynn285c75e2013-03-04 13:13:03 -0500276 sudo sed -i '/--smallfiles/!s/OPTIONS=\"/OPTIONS=\"--smallfiles /' /etc/sysconfig/mongod
277
278 restart_service mongod
279 fi
Ian Wienand936284b2014-03-11 09:35:55 +1100280
Dean Troyerdc97cb72015-03-28 08:20:50 -0500281 # Give mongodb time to start-up
Ian Wienand936284b2014-03-11 09:35:55 +1100282 sleep 5
Eoghan Glynn285c75e2013-03-04 13:13:03 -0500283}
284
Lianhao Lu8c548492013-01-09 10:41:54 +0800285# init_ceilometer() - Initialize etc.
Ian Wienandaee18c72014-02-21 15:35:08 +1100286function init_ceilometer {
Lianhao Lu8c548492013-01-09 10:41:54 +0800287 # Create cache dir
Dean Troyer8421c2b2015-03-16 13:52:19 -0500288 sudo install -d -o $STACK_USER $CEILOMETER_AUTH_CACHE_DIR
Lianhao Lu8c548492013-01-09 10:41:54 +0800289 rm -f $CEILOMETER_AUTH_CACHE_DIR/*
Guangyu Suo9778b3c2013-07-17 15:22:21 +0800290
Sean Daguec921a952014-02-28 21:09:33 -0500291 if is_service_enabled mysql postgresql; then
gordon chung76e724b2015-02-11 18:28:37 -0500292 if [ "$CEILOMETER_BACKEND" = 'mysql' ] || [ "$CEILOMETER_BACKEND" = 'postgresql' ] || [ "$CEILOMETER_BACKEND" = 'es' ] ; then
Ihar Hrachyshka157c84b2014-10-06 13:29:39 +0200293 recreate_database ceilometer
Sean Daguec921a952014-02-28 21:09:33 -0500294 $CEILOMETER_BIN_DIR/ceilometer-dbsync
295 fi
Guangyu Suo9778b3c2013-07-17 15:22:21 +0800296 fi
Lianhao Lu8c548492013-01-09 10:41:54 +0800297}
298
Chris Dent21127432014-10-21 20:19:23 +0100299# install_redis() - Install the redis server.
300function install_redis {
301 if is_ubuntu; then
302 install_package redis-server
Ilya Tyaptinfe5164a2014-12-23 14:53:43 +0400303 restart_service redis-server
Chris Dent21127432014-10-21 20:19:23 +0100304 else
305 # This will fail (correctly) where a redis package is unavailable
306 install_package redis
Ilya Tyaptinfe5164a2014-12-23 14:53:43 +0400307 restart_service redis
Chris Dent21127432014-10-21 20:19:23 +0100308 fi
Chris Dent21127432014-10-21 20:19:23 +0100309}
310
John H. Tran93361642012-07-26 11:22:05 -0700311# install_ceilometer() - Collect source and prepare
Ian Wienandaee18c72014-02-21 15:35:08 +1100312function install_ceilometer {
John H. Tran93361642012-07-26 11:22:05 -0700313 git_clone $CEILOMETER_REPO $CEILOMETER_DIR $CEILOMETER_BRANCH
Joe Gordon13344bd2014-07-22 14:26:05 -0700314 setup_develop $CEILOMETER_DIR
315
Chris Dent8abd8592014-10-08 15:24:25 +0100316 if echo $CEILOMETER_COORDINATION_URL | grep -q '^memcached:'; then
317 install_package memcached
Chris Dent21127432014-10-21 20:19:23 +0100318 elif echo $CEILOMETER_COORDINATION_URL | grep -q '^redis:'; then
319 install_redis
Chris Dent8abd8592014-10-08 15:24:25 +0100320 fi
gordon chung76e724b2015-02-11 18:28:37 -0500321
322 if [ "$CEILOMETER_BACKEND" = 'es' ] ; then
323 ${TOP_DIR}/pkg/elasticsearch.sh download
324 ${TOP_DIR}/pkg/elasticsearch.sh install
325 fi
John H. Tran93361642012-07-26 11:22:05 -0700326}
327
Yunhong, Jiange583d9b2013-01-09 09:33:07 +0800328# install_ceilometerclient() - Collect source and prepare
Ian Wienandaee18c72014-02-21 15:35:08 +1100329function install_ceilometerclient {
Sean Daguee08ab102014-11-13 17:09:28 -0500330 if use_library_from_git "python-ceilometerclient"; then
331 git_clone_by_name "python-ceilometerclient"
332 setup_dev_lib "python-ceilometerclient"
333 sudo install -D -m 0644 -o $STACK_USER {${GITDIR["python-ceilometerclient"]}/tools/,/etc/bash_completion.d/}ceilometer.bash_completion
Sean Dague5cb19062014-11-01 01:37:45 +0100334 fi
Yunhong, Jiange583d9b2013-01-09 09:33:07 +0800335}
336
gordon chungad61e7f2015-02-12 15:17:25 -0500337# install_ceilometermiddleware() - Collect source and prepare
338function install_ceilometermiddleware {
339 if use_library_from_git "ceilometermiddleware"; then
340 git_clone_by_name "ceilometermiddleware"
341 setup_dev_lib "ceilometermiddleware"
gordon chungb6197e62015-02-12 15:33:35 -0500342 else
Sean Dague60996b12015-04-08 09:06:49 -0400343 # BUG: this should be a pip_install_gr except it was never
344 # included in global-requirements. Needs to be fixed by
345 # https://bugs.launchpad.net/ceilometer/+bug/1441655
gordon chungb6197e62015-02-12 15:33:35 -0500346 pip_install ceilometermiddleware
gordon chungad61e7f2015-02-12 15:17:25 -0500347 fi
348}
349
John H. Tran93361642012-07-26 11:22:05 -0700350# start_ceilometer() - Start running processes, including screen
Ian Wienandaee18c72014-02-21 15:35:08 +1100351function start_ceilometer {
Chris Dent2f27a0e2014-09-09 13:46:02 +0100352 run_process ceilometer-acentral "ceilometer-agent-central --config-file $CEILOMETER_CONF"
353 run_process ceilometer-anotification "ceilometer-agent-notification --config-file $CEILOMETER_CONF"
354 run_process ceilometer-collector "ceilometer-collector --config-file $CEILOMETER_CONF"
Lianhao Luc39f6402015-03-24 12:36:00 +0800355 run_process ceilometer-aipmi "ceilometer-agent-ipmi --config-file $CEILOMETER_CONF"
Chris Dentae6fb182014-09-16 15:17:13 +0100356
357 if [[ "$CEILOMETER_USE_MOD_WSGI" == "False" ]]; then
358 run_process ceilometer-api "ceilometer-api -d -v --log-dir=$CEILOMETER_API_LOG_DIR --config-file $CEILOMETER_CONF"
359 else
360 enable_apache_site ceilometer
361 restart_apache_server
362 tail_log ceilometer /var/log/$APACHE_NAME/ceilometer.log
363 tail_log ceilometer-api /var/log/$APACHE_NAME/ceilometer_access.log
364 fi
365
Chris Dent4922bfa2014-08-12 14:27:58 +0100366
367 # Start the compute agent last to allow time for the collector to
368 # fully wake up and connect to the message bus. See bug #1355809
Mehdi Abaakoukfc1b7782013-10-23 06:46:43 +0000369 if [[ "$VIRT_DRIVER" = 'libvirt' ]]; then
gordon chungbdeea692014-09-17 14:54:21 -0400370 run_process ceilometer-acompute "ceilometer-agent-compute --config-file $CEILOMETER_CONF" $LIBVIRT_GROUP
Mehdi Abaakoukfc1b7782013-10-23 06:46:43 +0000371 fi
Piyush Masrani846609b2014-03-14 19:21:48 +0530372 if [[ "$VIRT_DRIVER" = 'vsphere' ]]; then
Chris Dent2f27a0e2014-09-09 13:46:02 +0100373 run_process ceilometer-acompute "ceilometer-agent-compute --config-file $CEILOMETER_CONF"
Piyush Masrani846609b2014-03-14 19:21:48 +0530374 fi
Mehdi Abaakouk1ed64cb2013-10-23 10:37:05 +0200375
Dean Troyerdc97cb72015-03-28 08:20:50 -0500376 # Only die on API if it was actually intended to be turned on
Sean Dagueb9a70352014-03-04 15:02:04 -0500377 if is_service_enabled ceilometer-api; then
Sean Dague7083b822014-02-28 20:16:20 -0500378 echo "Waiting for ceilometer-api to start..."
sridhargaddamb5ab6462015-02-24 07:23:24 +0000379 if ! wait_for_service $SERVICE_TIMEOUT $CEILOMETER_SERVICE_PROTOCOL://$CEILOMETER_SERVICE_HOST:$CEILOMETER_SERVICE_PORT/v2/; then
Sean Dague7083b822014-02-28 20:16:20 -0500380 die $LINENO "ceilometer-api did not start"
381 fi
Mehdi Abaakouk1ed64cb2013-10-23 10:37:05 +0200382 fi
383
Chris Dent2f27a0e2014-09-09 13:46:02 +0100384 run_process ceilometer-alarm-notifier "ceilometer-alarm-notifier --config-file $CEILOMETER_CONF"
385 run_process ceilometer-alarm-evaluator "ceilometer-alarm-evaluator --config-file $CEILOMETER_CONF"
John H. Tran93361642012-07-26 11:22:05 -0700386}
Dean Troyer7903b792012-09-13 17:16:12 -0500387
Dean Troyer699a29f2012-09-10 14:10:27 -0500388# stop_ceilometer() - Stop running processes
Ian Wienandaee18c72014-02-21 15:35:08 +1100389function stop_ceilometer {
Chris Dentae6fb182014-09-16 15:17:13 +0100390 if [ "$CEILOMETER_USE_MOD_WSGI" == "True" ]; then
391 disable_apache_site ceilometer
392 restart_apache_server
393 fi
Dean Troyer699a29f2012-09-10 14:10:27 -0500394 # Kill the ceilometer screen windows
Lianhao Luc39f6402015-03-24 12:36:00 +0800395 for serv in ceilometer-acompute ceilometer-acentral ceilometer-aipmi ceilometer-anotification ceilometer-collector ceilometer-api ceilometer-alarm-notifier ceilometer-alarm-evaluator; do
Chris Dent2f27a0e2014-09-09 13:46:02 +0100396 stop_process $serv
Dean Troyer699a29f2012-09-10 14:10:27 -0500397 done
398}
399
Dean Troyercc6b4432013-04-08 15:38:03 -0500400
Dean Troyer7903b792012-09-13 17:16:12 -0500401# Restore xtrace
402$XTRACE
Sean Dague584d90e2013-03-29 14:34:53 -0400403
Adam Spiers6a5aa7c2013-10-24 11:27:02 +0100404# Tell emacs to use shell-script-mode
405## Local variables:
406## mode: shell-script
407## End: