blob: c31fcb920c65ea41b317402a08bb31bb05c0e72c [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
Yunhong, Jiange583d9b2013-01-09 09:33:07 +080032CEILOMETERCLIENT_DIR=$DEST/python-ceilometerclient
Dean Troyer6d04fd72012-12-21 11:03:37 -060033CEILOMETER_CONF_DIR=/etc/ceilometer
34CEILOMETER_CONF=$CEILOMETER_CONF_DIR/ceilometer.conf
35CEILOMETER_API_LOG_DIR=/var/log/ceilometer-api
36
Monty Taylor9fbeedd2012-08-17 12:52:27 -040037# Support potential entry-points console scripts
38if [ -d $CEILOMETER_DIR/bin ] ; then
39 CEILOMETER_BIN_DIR=$CEILOMETER_DIR/bin
40else
41 CEILOMETER_BIN_DIR=/usr/local/bin
42fi
John H. Tran93361642012-07-26 11:22:05 -070043
44# cleanup_ceilometer() - Remove residual data files, anything left over from previous
45# runs that a clean run would need to clean up
46function cleanup_ceilometer() {
David Kranz867cf422012-10-26 13:25:19 -040047 mongo ceilometer --eval "db.dropDatabase();"
John H. Tran93361642012-07-26 11:22:05 -070048}
49
Yunhong, Jiange583d9b2013-01-09 09:33:07 +080050# configure_ceilometerclient() - Set config files, create data dirs, etc
51function configure_ceilometerclient() {
52 setup_develop $CEILOMETERCLIENT_DIR
53}
54
John H. Tran93361642012-07-26 11:22:05 -070055# configure_ceilometer() - Set config files, create data dirs, etc
56function configure_ceilometer() {
57 setup_develop $CEILOMETER_DIR
Surya Prabhakar31d31852012-09-17 20:25:41 +053058
Doug Hellmannc5259b42012-09-22 10:52:31 -040059 [ ! -d $CEILOMETER_CONF_DIR ] && sudo mkdir -m 755 -p $CEILOMETER_CONF_DIR
Surya Prabhakar31d31852012-09-17 20:25:41 +053060 sudo chown $USER $CEILOMETER_CONF_DIR
61
Doug Hellmannc5259b42012-09-22 10:52:31 -040062 [ ! -d $CEILOMETER_API_LOG_DIR ] && sudo mkdir -m 755 -p $CEILOMETER_API_LOG_DIR
Surya Prabhakar31d31852012-09-17 20:25:41 +053063 sudo chown $USER $CEILOMETER_API_LOG_DIR
John H. Tran93361642012-07-26 11:22:05 -070064
Julien Danjou4b3e4e52012-10-24 16:32:01 +020065 iniset $CEILOMETER_CONF DEFAULT rpc_backend 'ceilometer.openstack.common.rpc.impl_kombu'
66 iniset $CEILOMETER_CONF DEFAULT notification_topics 'notifications,glance_notifications'
67 iniset $CEILOMETER_CONF DEFAULT verbose True
68 iniset $CEILOMETER_CONF DEFAULT rabbit_host $RABBIT_HOST
69 iniset $CEILOMETER_CONF DEFAULT rabbit_password $RABBIT_PASSWORD
70 iniset $CEILOMETER_CONF DEFAULT sql_connection $BASE_SQL_CONN/nova?charset=utf8
Doug Hellmann53a5f422012-10-02 17:29:23 -040071
Doug Hellmann4a2b1c62012-11-01 16:23:52 -040072 # Install the policy file for the API server
73 cp $CEILOMETER_DIR/etc/ceilometer/policy.json $CEILOMETER_CONF_DIR
74 iniset $CEILOMETER_CONF DEFAULT policy_file $CEILOMETER_CONF_DIR/policy.json
75
Eoghan Glynn14246ac2012-11-14 16:23:04 +000076 # the compute and central agents need these credentials in order to
77 # call out to the public nova and glance APIs
78 iniset $CEILOMETER_CONF DEFAULT os_username ceilometer
79 iniset $CEILOMETER_CONF DEFAULT os_password $SERVICE_PASSWORD
80 iniset $CEILOMETER_CONF DEFAULT os_tenant_name $SERVICE_TENANT_NAME
81 iniset $CEILOMETER_CONF DEFAULT os_auth_url $OS_AUTH_URL
82
Julien Danjou4b3e4e52012-10-24 16:32:01 +020083 iniset $CEILOMETER_CONF keystone_authtoken auth_protocol http
Doug Hellmann4a2b1c62012-11-01 16:23:52 -040084 iniset $CEILOMETER_CONF keystone_authtoken admin_user ceilometer
85 iniset $CEILOMETER_CONF keystone_authtoken admin_password $SERVICE_PASSWORD
86 iniset $CEILOMETER_CONF keystone_authtoken admin_tenant_name $SERVICE_TENANT_NAME
87
David Kranz867cf422012-10-26 13:25:19 -040088 cleanup_ceilometer
John H. Tran93361642012-07-26 11:22:05 -070089}
90
91# install_ceilometer() - Collect source and prepare
92function install_ceilometer() {
93 git_clone $CEILOMETER_REPO $CEILOMETER_DIR $CEILOMETER_BRANCH
94}
95
Yunhong, Jiange583d9b2013-01-09 09:33:07 +080096# install_ceilometerclient() - Collect source and prepare
97function install_ceilometerclient() {
98 git_clone $CEILOMETERCLIENT_REPO $CEILOMETERCLIENT_DIR $CEILOMETERCLIENT_BRANCH
99}
100
John H. Tran93361642012-07-26 11:22:05 -0700101# start_ceilometer() - Start running processes, including screen
102function start_ceilometer() {
Julien Danjou4b3e4e52012-10-24 16:32:01 +0200103 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 +0000104 screen_it ceilometer-acentral "cd $CEILOMETER_DIR && $CEILOMETER_BIN_DIR/ceilometer-agent-central --config-file $CEILOMETER_CONF"
Julien Danjou4b3e4e52012-10-24 16:32:01 +0200105 screen_it ceilometer-collector "cd $CEILOMETER_DIR && $CEILOMETER_BIN_DIR/ceilometer-collector --config-file $CEILOMETER_CONF"
106 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 -0700107}
Dean Troyer7903b792012-09-13 17:16:12 -0500108
Dean Troyer699a29f2012-09-10 14:10:27 -0500109# stop_ceilometer() - Stop running processes
110function stop_ceilometer() {
111 # Kill the ceilometer screen windows
112 for serv in ceilometer-acompute ceilometer-acentral ceilometer-collector ceilometer-api; do
113 screen -S $SCREEN_NAME -p $serv -X kill
114 done
115}
116
Dean Troyer7903b792012-09-13 17:16:12 -0500117# Restore xtrace
118$XTRACE