blob: bd4ab0f2ddda06dd91361dfecd780c7e2013c66c [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
Shengjie Mineda55792013-05-13 18:00:57 +01004# To enable Ceilometer services, add the following to localrc
5# enable_service ceilometer-acompute ceilometer-acentral ceilometer-collector ceilometer-api
Surya Prabhakar31d31852012-09-17 20:25:41 +05306
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
Attila Fazekas91b8d132013-01-06 22:40:09 +010012# - STACK_USER service user
John H. Tran93361642012-07-26 11:22:05 -070013
14# stack.sh
15# ---------
Dean Troyer6d04fd72012-12-21 11:03:37 -060016# install_ceilometer
17# configure_ceilometer
18# init_ceilometer
19# start_ceilometer
20# stop_ceilometer
21# cleanup_ceilometer
John H. Tran93361642012-07-26 11:22:05 -070022
Dean Troyer7903b792012-09-13 17:16:12 -050023# Save trace setting
24XTRACE=$(set +o | grep xtrace)
25set +o xtrace
John H. Tran93361642012-07-26 11:22:05 -070026
27
28# Defaults
29# --------
30
Dean Troyer6d04fd72012-12-21 11:03:37 -060031# Set up default directories
John H. Tran93361642012-07-26 11:22:05 -070032CEILOMETER_DIR=$DEST/ceilometer
Yunhong, Jiange583d9b2013-01-09 09:33:07 +080033CEILOMETERCLIENT_DIR=$DEST/python-ceilometerclient
Dean Troyer6d04fd72012-12-21 11:03:37 -060034CEILOMETER_CONF_DIR=/etc/ceilometer
35CEILOMETER_CONF=$CEILOMETER_CONF_DIR/ceilometer.conf
36CEILOMETER_API_LOG_DIR=/var/log/ceilometer-api
Lianhao Lu8c548492013-01-09 10:41:54 +080037CEILOMETER_AUTH_CACHE_DIR=${CEILOMETER_AUTH_CACHE_DIR:-/var/cache/ceilometer}
Dean Troyer6d04fd72012-12-21 11:03:37 -060038
Monty Taylor9fbeedd2012-08-17 12:52:27 -040039# Support potential entry-points console scripts
Dean Troyercc6b4432013-04-08 15:38:03 -050040if [[ -d $CEILOMETER_DIR/bin ]]; then
Monty Taylor9fbeedd2012-08-17 12:52:27 -040041 CEILOMETER_BIN_DIR=$CEILOMETER_DIR/bin
42else
Jakub Ruzicka4196d552013-01-30 15:35:54 +010043 CEILOMETER_BIN_DIR=$(get_python_exec_prefix)
Monty Taylor9fbeedd2012-08-17 12:52:27 -040044fi
John H. Tran93361642012-07-26 11:22:05 -070045
Dean Troyercc6b4432013-04-08 15:38:03 -050046
47# Functions
48# ---------
49
John H. Tran93361642012-07-26 11:22:05 -070050# cleanup_ceilometer() - Remove residual data files, anything left over from previous
51# runs that a clean run would need to clean up
52function cleanup_ceilometer() {
David Kranz867cf422012-10-26 13:25:19 -040053 mongo ceilometer --eval "db.dropDatabase();"
John H. Tran93361642012-07-26 11:22:05 -070054}
55
Yunhong, Jiange583d9b2013-01-09 09:33:07 +080056# configure_ceilometerclient() - Set config files, create data dirs, etc
57function configure_ceilometerclient() {
58 setup_develop $CEILOMETERCLIENT_DIR
59}
60
John H. Tran93361642012-07-26 11:22:05 -070061# configure_ceilometer() - Set config files, create data dirs, etc
62function configure_ceilometer() {
63 setup_develop $CEILOMETER_DIR
Surya Prabhakar31d31852012-09-17 20:25:41 +053064
Doug Hellmannc5259b42012-09-22 10:52:31 -040065 [ ! -d $CEILOMETER_CONF_DIR ] && sudo mkdir -m 755 -p $CEILOMETER_CONF_DIR
Surya Prabhakar31d31852012-09-17 20:25:41 +053066 sudo chown $USER $CEILOMETER_CONF_DIR
67
Doug Hellmannc5259b42012-09-22 10:52:31 -040068 [ ! -d $CEILOMETER_API_LOG_DIR ] && sudo mkdir -m 755 -p $CEILOMETER_API_LOG_DIR
Surya Prabhakar31d31852012-09-17 20:25:41 +053069 sudo chown $USER $CEILOMETER_API_LOG_DIR
John H. Tran93361642012-07-26 11:22:05 -070070
Eoghan Glynn8c11f562013-03-01 12:09:01 +000071 iniset_rpc_backend ceilometer $CEILOMETER_CONF DEFAULT
Eoghan Glynnd36268a2013-02-22 21:59:52 +000072
Gordon Chung701eb612013-05-10 10:45:50 -040073 iniset $CEILOMETER_CONF DEFAULT notification_topics 'notifications'
Julien Danjou4b3e4e52012-10-24 16:32:01 +020074 iniset $CEILOMETER_CONF DEFAULT verbose True
Doug Hellmann53a5f422012-10-02 17:29:23 -040075
Doug Hellmann4a2b1c62012-11-01 16:23:52 -040076 # Install the policy file for the API server
77 cp $CEILOMETER_DIR/etc/ceilometer/policy.json $CEILOMETER_CONF_DIR
Yunhong, Jiang8407b2d2013-02-07 13:48:33 +080078 cp $CEILOMETER_DIR/etc/ceilometer/pipeline.yaml $CEILOMETER_CONF_DIR
Doug Hellmann4a2b1c62012-11-01 16:23:52 -040079 iniset $CEILOMETER_CONF DEFAULT policy_file $CEILOMETER_CONF_DIR/policy.json
80
Eoghan Glynn14246ac2012-11-14 16:23:04 +000081 # the compute and central agents need these credentials in order to
82 # call out to the public nova and glance APIs
83 iniset $CEILOMETER_CONF DEFAULT os_username ceilometer
84 iniset $CEILOMETER_CONF DEFAULT os_password $SERVICE_PASSWORD
85 iniset $CEILOMETER_CONF DEFAULT os_tenant_name $SERVICE_TENANT_NAME
86 iniset $CEILOMETER_CONF DEFAULT os_auth_url $OS_AUTH_URL
87
Julien Danjou4b3e4e52012-10-24 16:32:01 +020088 iniset $CEILOMETER_CONF keystone_authtoken auth_protocol http
Doug Hellmann4a2b1c62012-11-01 16:23:52 -040089 iniset $CEILOMETER_CONF keystone_authtoken admin_user ceilometer
90 iniset $CEILOMETER_CONF keystone_authtoken admin_password $SERVICE_PASSWORD
91 iniset $CEILOMETER_CONF keystone_authtoken admin_tenant_name $SERVICE_TENANT_NAME
Lianhao Lu8c548492013-01-09 10:41:54 +080092 iniset $CEILOMETER_CONF keystone_authtoken signing_dir $CEILOMETER_AUTH_CACHE_DIR
Doug Hellmann4a2b1c62012-11-01 16:23:52 -040093
Gordon Chung8f3af422013-05-31 08:58:30 -040094 iniset $CEILOMETER_CONF database connection mongodb://localhost:27017/ceilometer
95
Eoghan Glynn285c75e2013-03-04 13:13:03 -050096 configure_mongodb
97
David Kranz867cf422012-10-26 13:25:19 -040098 cleanup_ceilometer
John H. Tran93361642012-07-26 11:22:05 -070099}
100
Eoghan Glynn285c75e2013-03-04 13:13:03 -0500101function configure_mongodb() {
Dean Troyercc6b4432013-04-08 15:38:03 -0500102 if is_fedora; then
Eoghan Glynn285c75e2013-03-04 13:13:03 -0500103 # ensure smallfiles selected to minimize freespace requirements
104 sudo sed -i '/--smallfiles/!s/OPTIONS=\"/OPTIONS=\"--smallfiles /' /etc/sysconfig/mongod
105
106 restart_service mongod
107 fi
108}
109
Lianhao Lu8c548492013-01-09 10:41:54 +0800110# init_ceilometer() - Initialize etc.
111function init_ceilometer() {
112 # Create cache dir
113 sudo mkdir -p $CEILOMETER_AUTH_CACHE_DIR
Attila Fazekas91b8d132013-01-06 22:40:09 +0100114 sudo chown $STACK_USER $CEILOMETER_AUTH_CACHE_DIR
Lianhao Lu8c548492013-01-09 10:41:54 +0800115 rm -f $CEILOMETER_AUTH_CACHE_DIR/*
116}
117
John H. Tran93361642012-07-26 11:22:05 -0700118# install_ceilometer() - Collect source and prepare
119function install_ceilometer() {
120 git_clone $CEILOMETER_REPO $CEILOMETER_DIR $CEILOMETER_BRANCH
121}
122
Yunhong, Jiange583d9b2013-01-09 09:33:07 +0800123# install_ceilometerclient() - Collect source and prepare
124function install_ceilometerclient() {
125 git_clone $CEILOMETERCLIENT_REPO $CEILOMETERCLIENT_DIR $CEILOMETERCLIENT_BRANCH
126}
127
John H. Tran93361642012-07-26 11:22:05 -0700128# start_ceilometer() - Start running processes, including screen
129function start_ceilometer() {
Gordon Chung5ecfd482013-06-06 00:25:16 -0400130 screen_it ceilometer-acompute "sg $LIBVIRT_GROUP \"ceilometer-agent-compute --config-file $CEILOMETER_CONF\""
131 screen_it ceilometer-acentral "ceilometer-agent-central --config-file $CEILOMETER_CONF"
132 screen_it ceilometer-collector "ceilometer-collector --config-file $CEILOMETER_CONF"
133 screen_it ceilometer-api "ceilometer-api -d -v --log-dir=$CEILOMETER_API_LOG_DIR --config-file $CEILOMETER_CONF"
John H. Tran93361642012-07-26 11:22:05 -0700134}
Dean Troyer7903b792012-09-13 17:16:12 -0500135
Dean Troyer699a29f2012-09-10 14:10:27 -0500136# stop_ceilometer() - Stop running processes
137function stop_ceilometer() {
138 # Kill the ceilometer screen windows
139 for serv in ceilometer-acompute ceilometer-acentral ceilometer-collector ceilometer-api; do
140 screen -S $SCREEN_NAME -p $serv -X kill
141 done
142}
143
Dean Troyercc6b4432013-04-08 15:38:03 -0500144
Dean Troyer7903b792012-09-13 17:16:12 -0500145# Restore xtrace
146$XTRACE
Sean Dague584d90e2013-03-29 14:34:53 -0400147
148# Local variables:
149# mode: shell-script
150# End: