blob: 76ab254d5fbcf45e32d1c0a318d780579599641a [file] [log] [blame]
John H. Tran93361642012-07-26 11:22:05 -07001# lib/ceilometer
Dean Troyer6d04fd72012-12-21 11:03:37 -06002# Install and start **Ceilometer** service
3
Surya Prabhakar31d31852012-09-17 20:25:41 +05304# To enable, add the following to localrc
5# ENABLED_SERVICES+=ceilometer-acompute,ceilometer-acentral,ceilometer-collector,ceilometer-api
6
John H. Tran93361642012-07-26 11:22:05 -07007# 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# ---------
Dean Troyer6d04fd72012-12-21 11:03:37 -060015# install_ceilometer
16# configure_ceilometer
17# init_ceilometer
18# start_ceilometer
19# stop_ceilometer
20# cleanup_ceilometer
John H. Tran93361642012-07-26 11:22:05 -070021
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
Dean Troyer6d04fd72012-12-21 11:03:37 -060030# Set up default directories
John H. Tran93361642012-07-26 11:22:05 -070031CEILOMETER_DIR=$DEST/ceilometer
Dean Troyer6d04fd72012-12-21 11:03:37 -060032CEILOMETER_CONF_DIR=/etc/ceilometer
33CEILOMETER_CONF=$CEILOMETER_CONF_DIR/ceilometer.conf
34CEILOMETER_API_LOG_DIR=/var/log/ceilometer-api
35
Monty Taylor9fbeedd2012-08-17 12:52:27 -040036# Support potential entry-points console scripts
37if [ -d $CEILOMETER_DIR/bin ] ; then
38 CEILOMETER_BIN_DIR=$CEILOMETER_DIR/bin
39else
40 CEILOMETER_BIN_DIR=/usr/local/bin
41fi
John H. Tran93361642012-07-26 11:22:05 -070042
43# cleanup_ceilometer() - Remove residual data files, anything left over from previous
44# runs that a clean run would need to clean up
45function cleanup_ceilometer() {
David Kranz867cf422012-10-26 13:25:19 -040046 mongo ceilometer --eval "db.dropDatabase();"
John H. Tran93361642012-07-26 11:22:05 -070047}
48
49# configure_ceilometer() - Set config files, create data dirs, etc
50function configure_ceilometer() {
51 setup_develop $CEILOMETER_DIR
Surya Prabhakar31d31852012-09-17 20:25:41 +053052
Doug Hellmannc5259b42012-09-22 10:52:31 -040053 [ ! -d $CEILOMETER_CONF_DIR ] && sudo mkdir -m 755 -p $CEILOMETER_CONF_DIR
Surya Prabhakar31d31852012-09-17 20:25:41 +053054 sudo chown $USER $CEILOMETER_CONF_DIR
55
Doug Hellmannc5259b42012-09-22 10:52:31 -040056 [ ! -d $CEILOMETER_API_LOG_DIR ] && sudo mkdir -m 755 -p $CEILOMETER_API_LOG_DIR
Surya Prabhakar31d31852012-09-17 20:25:41 +053057 sudo chown $USER $CEILOMETER_API_LOG_DIR
John H. Tran93361642012-07-26 11:22:05 -070058
Julien Danjou4b3e4e52012-10-24 16:32:01 +020059 iniset $CEILOMETER_CONF DEFAULT rpc_backend 'ceilometer.openstack.common.rpc.impl_kombu'
60 iniset $CEILOMETER_CONF DEFAULT notification_topics 'notifications,glance_notifications'
61 iniset $CEILOMETER_CONF DEFAULT verbose True
62 iniset $CEILOMETER_CONF DEFAULT rabbit_host $RABBIT_HOST
63 iniset $CEILOMETER_CONF DEFAULT rabbit_password $RABBIT_PASSWORD
64 iniset $CEILOMETER_CONF DEFAULT sql_connection $BASE_SQL_CONN/nova?charset=utf8
Doug Hellmann53a5f422012-10-02 17:29:23 -040065
Doug Hellmann4a2b1c62012-11-01 16:23:52 -040066 # Install the policy file for the API server
67 cp $CEILOMETER_DIR/etc/ceilometer/policy.json $CEILOMETER_CONF_DIR
68 iniset $CEILOMETER_CONF DEFAULT policy_file $CEILOMETER_CONF_DIR/policy.json
69
Eoghan Glynn14246ac2012-11-14 16:23:04 +000070 # the compute and central agents need these credentials in order to
71 # call out to the public nova and glance APIs
72 iniset $CEILOMETER_CONF DEFAULT os_username ceilometer
73 iniset $CEILOMETER_CONF DEFAULT os_password $SERVICE_PASSWORD
74 iniset $CEILOMETER_CONF DEFAULT os_tenant_name $SERVICE_TENANT_NAME
75 iniset $CEILOMETER_CONF DEFAULT os_auth_url $OS_AUTH_URL
76
Julien Danjou4b3e4e52012-10-24 16:32:01 +020077 iniset $CEILOMETER_CONF keystone_authtoken auth_protocol http
Doug Hellmann4a2b1c62012-11-01 16:23:52 -040078 iniset $CEILOMETER_CONF keystone_authtoken admin_user ceilometer
79 iniset $CEILOMETER_CONF keystone_authtoken admin_password $SERVICE_PASSWORD
80 iniset $CEILOMETER_CONF keystone_authtoken admin_tenant_name $SERVICE_TENANT_NAME
81
David Kranz867cf422012-10-26 13:25:19 -040082 cleanup_ceilometer
John H. Tran93361642012-07-26 11:22:05 -070083}
84
85# install_ceilometer() - Collect source and prepare
86function install_ceilometer() {
87 git_clone $CEILOMETER_REPO $CEILOMETER_DIR $CEILOMETER_BRANCH
88}
89
90# start_ceilometer() - Start running processes, including screen
91function start_ceilometer() {
Julien Danjou4b3e4e52012-10-24 16:32:01 +020092 screen_it ceilometer-acompute "cd $CEILOMETER_DIR && sg libvirtd \"$CEILOMETER_BIN_DIR/ceilometer-agent-compute --config-file $CEILOMETER_CONF\""
Eoghan Glynn14246ac2012-11-14 16:23:04 +000093 screen_it ceilometer-acentral "cd $CEILOMETER_DIR && $CEILOMETER_BIN_DIR/ceilometer-agent-central --config-file $CEILOMETER_CONF"
Julien Danjou4b3e4e52012-10-24 16:32:01 +020094 screen_it ceilometer-collector "cd $CEILOMETER_DIR && $CEILOMETER_BIN_DIR/ceilometer-collector --config-file $CEILOMETER_CONF"
95 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 -070096}
Dean Troyer7903b792012-09-13 17:16:12 -050097
Dean Troyer699a29f2012-09-10 14:10:27 -050098# stop_ceilometer() - Stop running processes
99function stop_ceilometer() {
100 # Kill the ceilometer screen windows
101 for serv in ceilometer-acompute ceilometer-acentral ceilometer-collector ceilometer-api; do
102 screen -S $SCREEN_NAME -p $serv -X kill
103 done
104}
105
Dean Troyer7903b792012-09-13 17:16:12 -0500106# Restore xtrace
107$XTRACE