blob: 2b014b05b8c2dc492c4d45d7250a995d5e28b2fd [file] [log] [blame]
John H. Tran93361642012-07-26 11:22:05 -07001# lib/ceilometer
2# Install and start Ceilometer service
Surya Prabhakar31d31852012-09-17 20:25:41 +05303# To enable, add the following to localrc
4# ENABLED_SERVICES+=ceilometer-acompute,ceilometer-acentral,ceilometer-collector,ceilometer-api
5
John H. Tran93361642012-07-26 11:22:05 -07006
7# Dependencies:
8# - functions
Doug Hellmann4a2b1c62012-11-01 16:23:52 -04009# - OS_AUTH_URL for auth in api
Eoghan Glynnad80ead2012-09-27 09:36:33 +010010# - DEST set to the destination directory
Doug Hellmann4a2b1c62012-11-01 16:23:52 -040011# - SERVICE_PASSWORD, SERVICE_TENANT_NAME for auth in api
John H. Tran93361642012-07-26 11:22:05 -070012
13# stack.sh
14# ---------
15# install_XXX
16# configure_XXX
17# init_XXX
18# start_XXX
19# stop_XXX
20# cleanup_XXX
21
Dean Troyer7903b792012-09-13 17:16:12 -050022# Save trace setting
23XTRACE=$(set +o | grep xtrace)
24set +o xtrace
John H. Tran93361642012-07-26 11:22:05 -070025
26
27# Defaults
28# --------
29
30# set up default directories
31CEILOMETER_DIR=$DEST/ceilometer
Monty Taylor9fbeedd2012-08-17 12:52:27 -040032# Support potential entry-points console scripts
33if [ -d $CEILOMETER_DIR/bin ] ; then
34 CEILOMETER_BIN_DIR=$CEILOMETER_DIR/bin
35else
36 CEILOMETER_BIN_DIR=/usr/local/bin
37fi
John H. Tran93361642012-07-26 11:22:05 -070038CEILOMETER_CONF_DIR=/etc/ceilometer
Julien Danjou4b3e4e52012-10-24 16:32:01 +020039CEILOMETER_CONF=$CEILOMETER_CONF_DIR/ceilometer.conf
Surya Prabhakar31d31852012-09-17 20:25:41 +053040CEILOMETER_API_LOG_DIR=/var/log/ceilometer-api
John H. Tran93361642012-07-26 11:22:05 -070041
42# cleanup_ceilometer() - Remove residual data files, anything left over from previous
43# runs that a clean run would need to clean up
44function cleanup_ceilometer() {
David Kranz867cf422012-10-26 13:25:19 -040045 mongo ceilometer --eval "db.dropDatabase();"
John H. Tran93361642012-07-26 11:22:05 -070046}
47
48# configure_ceilometer() - Set config files, create data dirs, etc
49function configure_ceilometer() {
50 setup_develop $CEILOMETER_DIR
Surya Prabhakar31d31852012-09-17 20:25:41 +053051
Doug Hellmannc5259b42012-09-22 10:52:31 -040052 [ ! -d $CEILOMETER_CONF_DIR ] && sudo mkdir -m 755 -p $CEILOMETER_CONF_DIR
Surya Prabhakar31d31852012-09-17 20:25:41 +053053 sudo chown $USER $CEILOMETER_CONF_DIR
54
Doug Hellmannc5259b42012-09-22 10:52:31 -040055 [ ! -d $CEILOMETER_API_LOG_DIR ] && sudo mkdir -m 755 -p $CEILOMETER_API_LOG_DIR
Surya Prabhakar31d31852012-09-17 20:25:41 +053056 sudo chown $USER $CEILOMETER_API_LOG_DIR
John H. Tran93361642012-07-26 11:22:05 -070057
Julien Danjou4b3e4e52012-10-24 16:32:01 +020058 iniset $CEILOMETER_CONF DEFAULT rpc_backend 'ceilometer.openstack.common.rpc.impl_kombu'
59 iniset $CEILOMETER_CONF DEFAULT notification_topics 'notifications,glance_notifications'
60 iniset $CEILOMETER_CONF DEFAULT verbose True
61 iniset $CEILOMETER_CONF DEFAULT rabbit_host $RABBIT_HOST
62 iniset $CEILOMETER_CONF DEFAULT rabbit_password $RABBIT_PASSWORD
63 iniset $CEILOMETER_CONF DEFAULT sql_connection $BASE_SQL_CONN/nova?charset=utf8
Doug Hellmann53a5f422012-10-02 17:29:23 -040064
Doug Hellmann4a2b1c62012-11-01 16:23:52 -040065 # Install the policy file for the API server
66 cp $CEILOMETER_DIR/etc/ceilometer/policy.json $CEILOMETER_CONF_DIR
67 iniset $CEILOMETER_CONF DEFAULT policy_file $CEILOMETER_CONF_DIR/policy.json
68
Julien Danjou4b3e4e52012-10-24 16:32:01 +020069 iniset $CEILOMETER_CONF keystone_authtoken auth_protocol http
Doug Hellmann4a2b1c62012-11-01 16:23:52 -040070 iniset $CEILOMETER_CONF keystone_authtoken admin_user ceilometer
71 iniset $CEILOMETER_CONF keystone_authtoken admin_password $SERVICE_PASSWORD
72 iniset $CEILOMETER_CONF keystone_authtoken admin_tenant_name $SERVICE_TENANT_NAME
73
David Kranz867cf422012-10-26 13:25:19 -040074 cleanup_ceilometer
John H. Tran93361642012-07-26 11:22:05 -070075}
76
77# install_ceilometer() - Collect source and prepare
78function install_ceilometer() {
79 git_clone $CEILOMETER_REPO $CEILOMETER_DIR $CEILOMETER_BRANCH
80}
81
82# start_ceilometer() - Start running processes, including screen
83function start_ceilometer() {
Julien Danjou4b3e4e52012-10-24 16:32:01 +020084 screen_it ceilometer-acompute "cd $CEILOMETER_DIR && sg libvirtd \"$CEILOMETER_BIN_DIR/ceilometer-agent-compute --config-file $CEILOMETER_CONF\""
Doug Hellmann4a2b1c62012-11-01 16:23:52 -040085 screen_it ceilometer-acentral "export OS_USERNAME=ceilometer OS_PASSWORD=$SERVICE_PASSWORD OS_TENANT_NAME=$SERVICE_TENANT_NAME OS_AUTH_URL=$OS_AUTH_URL && cd $CEILOMETER_DIR && $CEILOMETER_BIN_DIR/ceilometer-agent-central --config-file $CEILOMETER_CONF"
Julien Danjou4b3e4e52012-10-24 16:32:01 +020086 screen_it ceilometer-collector "cd $CEILOMETER_DIR && $CEILOMETER_BIN_DIR/ceilometer-collector --config-file $CEILOMETER_CONF"
87 screen_it ceilometer-api "cd $CEILOMETER_DIR && $CEILOMETER_BIN_DIR/ceilometer-api -d -v --log-dir=$CEILOMETER_API_LOG_DIR --config-file $CEILOMETER_CONF"
John H. Tran93361642012-07-26 11:22:05 -070088}
Dean Troyer7903b792012-09-13 17:16:12 -050089
Dean Troyer699a29f2012-09-10 14:10:27 -050090# stop_ceilometer() - Stop running processes
91function stop_ceilometer() {
92 # Kill the ceilometer screen windows
93 for serv in ceilometer-acompute ceilometer-acentral ceilometer-collector ceilometer-api; do
94 screen -S $SCREEN_NAME -p $serv -X kill
95 done
96}
97
Dean Troyer7903b792012-09-13 17:16:12 -050098# Restore xtrace
99$XTRACE