blob: c6e936f3e87c87ffbab8d51eaeda8bdcb70aa5f6 [file] [log] [blame]
Steve Bakerbfdad752012-08-18 09:00:42 +12001# lib/heat
Dean Troyer6d04fd72012-12-21 11:03:37 -06002# Install and start **Heat** service
3
Steve Bakerbfdad752012-08-18 09:00:42 +12004# To enable, add the following to localrc
Steven Hardy08b4e9b2012-11-30 13:31:49 +00005# ENABLED_SERVICES+=,heat,h-api-cfn,h-api-cw,h-eng
Steve Bakerbfdad752012-08-18 09:00:42 +12006
7# Dependencies:
8# - functions
9
10# stack.sh
11# ---------
Dean Troyer6d04fd72012-12-21 11:03:37 -060012# install_heatclient
13# install_heat
14# configure_heatclient
15# configure_heat
16# init_heat
17# start_heat
18# stop_heat
19# cleanup_heat
Steve Bakerbfdad752012-08-18 09:00:42 +120020
Dean Troyer7903b792012-09-13 17:16:12 -050021# Save trace setting
22XTRACE=$(set +o | grep xtrace)
23set +o xtrace
Steve Bakerbfdad752012-08-18 09:00:42 +120024
25
26# Defaults
27# --------
Dean Troyercc6b4432013-04-08 15:38:03 -050028
29# set up default directories
Steve Bakerbfdad752012-08-18 09:00:42 +120030HEAT_DIR=$DEST/heat
Steve Baker32761a42012-11-05 09:57:57 +130031HEATCLIENT_DIR=$DEST/python-heatclient
Steve Bakerc3249082013-04-09 13:41:47 +120032HEAT_AUTH_CACHE_DIR=${HEAT_AUTH_CACHE_DIR:-/var/cache/heat}
Dean Troyercc6b4432013-04-08 15:38:03 -050033
34
35# Functions
36# ---------
Steve Bakerbfdad752012-08-18 09:00:42 +120037
38# cleanup_heat() - Remove residual data files, anything left over from previous
39# runs that a clean run would need to clean up
40function cleanup_heat() {
Steve Bakerc3249082013-04-09 13:41:47 +120041 sudo rm -rf $HEAT_AUTH_CACHE_DIR
Steve Bakerbfdad752012-08-18 09:00:42 +120042}
43
Steve Baker32761a42012-11-05 09:57:57 +130044# configure_heatclient() - Set config files, create data dirs, etc
45function configure_heatclient() {
46 setup_develop $HEATCLIENT_DIR
47}
48
Steve Bakerbfdad752012-08-18 09:00:42 +120049# configure_heat() - Set config files, create data dirs, etc
50function configure_heat() {
51 setup_develop $HEAT_DIR
52
53 HEAT_CONF_DIR=/etc/heat
54 if [[ ! -d $HEAT_CONF_DIR ]]; then
55 sudo mkdir -p $HEAT_CONF_DIR
56 fi
Attila Fazekas91b8d132013-01-06 22:40:09 +010057 sudo chown $STACK_USER $HEAT_CONF_DIR
Steve Bakerbfdad752012-08-18 09:00:42 +120058
Angus Salkelde2790212012-09-11 11:24:09 +100059 HEAT_API_CFN_HOST=${HEAT_API_CFN_HOST:-$SERVICE_HOST}
60 HEAT_API_CFN_PORT=${HEAT_API_CFN_PORT:-8000}
Steve Bakerbfdad752012-08-18 09:00:42 +120061 HEAT_ENGINE_HOST=${HEAT_ENGINE_HOST:-$SERVICE_HOST}
62 HEAT_ENGINE_PORT=${HEAT_ENGINE_PORT:-8001}
Angus Salkelde2790212012-09-11 11:24:09 +100063 HEAT_API_CW_HOST=${HEAT_API_CW_HOST:-$SERVICE_HOST}
64 HEAT_API_CW_PORT=${HEAT_API_CW_PORT:-8003}
Steve Bakerbb421be2012-10-10 13:19:10 +130065 HEAT_API_HOST=${HEAT_API_HOST:-$SERVICE_HOST}
66 HEAT_API_PORT=${HEAT_API_PORT:-8004}
Steve Bakerbfdad752012-08-18 09:00:42 +120067
Dean Troyer6d04fd72012-12-21 11:03:37 -060068 # Cloudformation API
Angus Salkelde2790212012-09-11 11:24:09 +100069 HEAT_API_CFN_CONF=$HEAT_CONF_DIR/heat-api-cfn.conf
70 cp $HEAT_DIR/etc/heat/heat-api-cfn.conf $HEAT_API_CFN_CONF
71 iniset $HEAT_API_CFN_CONF DEFAULT debug True
72 inicomment $HEAT_API_CFN_CONF DEFAULT log_file
73 iniset $HEAT_API_CFN_CONF DEFAULT use_syslog $SYSLOG
74 iniset $HEAT_API_CFN_CONF DEFAULT bind_host $HEAT_API_CFN_HOST
75 iniset $HEAT_API_CFN_CONF DEFAULT bind_port $HEAT_API_CFN_PORT
Steve Bakerc3249082013-04-09 13:41:47 +120076 iniset $HEAT_API_CFN_CONF keystone_authtoken auth_host $KEYSTONE_AUTH_HOST
77 iniset $HEAT_API_CFN_CONF keystone_authtoken auth_port $KEYSTONE_AUTH_PORT
78 iniset $HEAT_API_CFN_CONF keystone_authtoken auth_protocol $KEYSTONE_AUTH_PROTOCOL
79 iniset $HEAT_API_CFN_CONF keystone_authtoken auth_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/v2.0
80 iniset $HEAT_API_CFN_CONF keystone_authtoken admin_tenant_name $SERVICE_TENANT_NAME
81 iniset $HEAT_API_CFN_CONF keystone_authtoken admin_user heat
82 iniset $HEAT_API_CFN_CONF keystone_authtoken admin_password $SERVICE_PASSWORD
83 iniset $HEAT_API_CFN_CONF keystone_authtoken signing_dir $HEAT_AUTH_CACHE_DIR/api-cfn
Steve Bakerbfdad752012-08-18 09:00:42 +120084
Akihiro MOTOKIb0f1c382013-01-13 17:58:12 +090085 iniset_rpc_backend heat $HEAT_API_CFN_CONF DEFAULT
Steve Bakerbfdad752012-08-18 09:00:42 +120086
Angus Salkelde2790212012-09-11 11:24:09 +100087 HEAT_API_CFN_PASTE_INI=$HEAT_CONF_DIR/heat-api-cfn-paste.ini
88 cp $HEAT_DIR/etc/heat/heat-api-cfn-paste.ini $HEAT_API_CFN_PASTE_INI
Angus Salkelde2790212012-09-11 11:24:09 +100089 iniset $HEAT_API_CFN_PASTE_INI filter:ec2authtoken auth_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/v2.0
90 iniset $HEAT_API_CFN_PASTE_INI filter:ec2authtoken keystone_ec2_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/v2.0/ec2tokens
Steve Bakerbfdad752012-08-18 09:00:42 +120091
Dean Troyer6d04fd72012-12-21 11:03:37 -060092 # OpenStack API
Steve Bakerbb421be2012-10-10 13:19:10 +130093 HEAT_API_CONF=$HEAT_CONF_DIR/heat-api.conf
94 cp $HEAT_DIR/etc/heat/heat-api.conf $HEAT_API_CONF
95 iniset $HEAT_API_CONF DEFAULT debug True
96 inicomment $HEAT_API_CONF DEFAULT log_file
97 iniset $HEAT_API_CONF DEFAULT use_syslog $SYSLOG
98 iniset $HEAT_API_CONF DEFAULT bind_host $HEAT_API_HOST
99 iniset $HEAT_API_CONF DEFAULT bind_port $HEAT_API_PORT
Steve Bakerc3249082013-04-09 13:41:47 +1200100 iniset $HEAT_API_CONF keystone_authtoken auth_host $KEYSTONE_AUTH_HOST
101 iniset $HEAT_API_CONF keystone_authtoken auth_port $KEYSTONE_AUTH_PORT
102 iniset $HEAT_API_CONF keystone_authtoken auth_protocol $KEYSTONE_AUTH_PROTOCOL
103 iniset $HEAT_API_CONF keystone_authtoken auth_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/v2.0
104 iniset $HEAT_API_CONF keystone_authtoken admin_tenant_name $SERVICE_TENANT_NAME
105 iniset $HEAT_API_CONF keystone_authtoken admin_user heat
106 iniset $HEAT_API_CONF keystone_authtoken admin_password $SERVICE_PASSWORD
107 iniset $HEAT_API_CONF keystone_authtoken signing_dir $HEAT_AUTH_CACHE_DIR/api
Steve Bakerbb421be2012-10-10 13:19:10 +1300108
Akihiro MOTOKIb0f1c382013-01-13 17:58:12 +0900109 iniset_rpc_backend heat $HEAT_API_CONF DEFAULT
Steve Bakerbb421be2012-10-10 13:19:10 +1300110
111 HEAT_API_PASTE_INI=$HEAT_CONF_DIR/heat-api-paste.ini
112 cp $HEAT_DIR/etc/heat/heat-api-paste.ini $HEAT_API_PASTE_INI
Steve Bakerbb421be2012-10-10 13:19:10 +1300113 iniset $HEAT_API_PASTE_INI filter:ec2authtoken auth_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/v2.0
114 iniset $HEAT_API_PASTE_INI filter:ec2authtoken keystone_ec2_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/v2.0/ec2tokens
115
Angus Salkelde2790212012-09-11 11:24:09 +1000116 # engine
Steve Bakerbfdad752012-08-18 09:00:42 +1200117 HEAT_ENGINE_CONF=$HEAT_CONF_DIR/heat-engine.conf
Angus Salkelde2790212012-09-11 11:24:09 +1000118 cp $HEAT_DIR/etc/heat/heat-engine.conf $HEAT_ENGINE_CONF
Steve Bakerbfdad752012-08-18 09:00:42 +1200119 iniset $HEAT_ENGINE_CONF DEFAULT debug True
120 inicomment $HEAT_ENGINE_CONF DEFAULT log_file
121 iniset $HEAT_ENGINE_CONF DEFAULT use_syslog $SYSLOG
122 iniset $HEAT_ENGINE_CONF DEFAULT bind_host $HEAT_ENGINE_HOST
123 iniset $HEAT_ENGINE_CONF DEFAULT bind_port $HEAT_ENGINE_PORT
Steve Bakerb592b292012-11-21 14:20:12 +1300124 iniset $HEAT_ENGINE_CONF DEFAULT heat_metadata_server_url http://$HEAT_API_CFN_HOST:$HEAT_API_CFN_PORT
Steve Baker9ec34212012-12-11 14:18:02 +1300125 iniset $HEAT_ENGINE_CONF DEFAULT heat_waitcondition_server_url http://$HEAT_API_CFN_HOST:$HEAT_API_CFN_PORT/v1/waitcondition
Steve Bakerb592b292012-11-21 14:20:12 +1300126 iniset $HEAT_ENGINE_CONF DEFAULT heat_watch_server_url http://$HEAT_API_CW_HOST:$HEAT_API_CW_PORT
Attila Fazekas7e79d912013-03-03 12:23:04 +0100127 iniset $HEAT_ENGINE_CONF DEFAULT sql_connection `database_connection_url heat`
Steve Bakerbfdad752012-08-18 09:00:42 +1200128 iniset $HEAT_ENGINE_CONF DEFAULT auth_encryption_key `hexdump -n 16 -v -e '/1 "%02x"' /dev/random`
129
Akihiro MOTOKIb0f1c382013-01-13 17:58:12 +0900130 iniset_rpc_backend heat $HEAT_ENGINE_CONF DEFAULT
Steve Bakerbfdad752012-08-18 09:00:42 +1200131
Dean Troyer6d04fd72012-12-21 11:03:37 -0600132 # Cloudwatch API
Angus Salkelde2790212012-09-11 11:24:09 +1000133 HEAT_API_CW_CONF=$HEAT_CONF_DIR/heat-api-cloudwatch.conf
134 cp $HEAT_DIR/etc/heat/heat-api-cloudwatch.conf $HEAT_API_CW_CONF
135 iniset $HEAT_API_CW_CONF DEFAULT debug True
136 inicomment $HEAT_API_CW_CONF DEFAULT log_file
137 iniset $HEAT_API_CW_CONF DEFAULT use_syslog $SYSLOG
138 iniset $HEAT_API_CW_CONF DEFAULT bind_host $HEAT_API_CW_HOST
139 iniset $HEAT_API_CW_CONF DEFAULT bind_port $HEAT_API_CW_PORT
Steve Bakerc3249082013-04-09 13:41:47 +1200140 iniset $HEAT_API_CW_CONF keystone_authtoken auth_host $KEYSTONE_AUTH_HOST
141 iniset $HEAT_API_CW_CONF keystone_authtoken auth_port $KEYSTONE_AUTH_PORT
142 iniset $HEAT_API_CW_CONF keystone_authtoken auth_protocol $KEYSTONE_AUTH_PROTOCOL
143 iniset $HEAT_API_CW_CONF keystone_authtoken auth_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/v2.0
144 iniset $HEAT_API_CW_CONF keystone_authtoken admin_tenant_name $SERVICE_TENANT_NAME
145 iniset $HEAT_API_CW_CONF keystone_authtoken admin_user heat
146 iniset $HEAT_API_CW_CONF keystone_authtoken admin_password $SERVICE_PASSWORD
147 iniset $HEAT_API_CW_CONF keystone_authtoken signing_dir $HEAT_AUTH_CACHE_DIR/api-cloudwatch
Angus Salkelde2790212012-09-11 11:24:09 +1000148
Akihiro MOTOKIb0f1c382013-01-13 17:58:12 +0900149 iniset_rpc_backend heat $HEAT_API_CW_CONF DEFAULT
Angus Salkelde2790212012-09-11 11:24:09 +1000150
151 HEAT_API_CW_PASTE_INI=$HEAT_CONF_DIR/heat-api-cloudwatch-paste.ini
152 cp $HEAT_DIR/etc/heat/heat-api-cloudwatch-paste.ini $HEAT_API_CW_PASTE_INI
Angus Salkelde2790212012-09-11 11:24:09 +1000153 iniset $HEAT_API_CW_PASTE_INI filter:ec2authtoken auth_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/v2.0
154 iniset $HEAT_API_CW_PASTE_INI filter:ec2authtoken keystone_ec2_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/v2.0/ec2tokens
Steve Bakerbfdad752012-08-18 09:00:42 +1200155}
156
157# init_heat() - Initialize database
158function init_heat() {
159
160 # (re)create heat database
Terry Wilson428af5a2012-11-01 16:12:39 -0400161 recreate_database heat utf8
Steve Bakerbfdad752012-08-18 09:00:42 +1200162
Clint Byrum1bd2a1b2012-12-12 12:57:16 -0800163 $HEAT_DIR/bin/heat-db-setup $os_PACKAGE -r $DATABASE_PASSWORD
Steve Bakerbad9d892012-10-25 14:49:47 +1300164 $HEAT_DIR/tools/nova_create_flavors.sh
Steve Bakerc3249082013-04-09 13:41:47 +1200165 create_heat_cache_dir
166}
167
168# create_heat_cache_dir() - Part of the init_heat() process
169function create_heat_cache_dir() {
170 # Create cache dirs
171 sudo mkdir -p $HEAT_AUTH_CACHE_DIR/api
172 sudo chown $STACK_USER $HEAT_AUTH_CACHE_DIR/api
173 sudo mkdir -p $HEAT_AUTH_CACHE_DIR/api-cfn
174 sudo chown $STACK_USER $HEAT_AUTH_CACHE_DIR/api-cfn
175 sudo mkdir -p $HEAT_AUTH_CACHE_DIR/api-cloudwatch
176 sudo chown $STACK_USER $HEAT_AUTH_CACHE_DIR/api-cloudwatch
Steve Bakerbfdad752012-08-18 09:00:42 +1200177}
178
Steve Baker32761a42012-11-05 09:57:57 +1300179# install_heatclient() - Collect source and prepare
180function install_heatclient() {
181 git_clone $HEATCLIENT_REPO $HEATCLIENT_DIR $HEATCLIENT_BRANCH
182}
183
Steve Bakerbfdad752012-08-18 09:00:42 +1200184# install_heat() - Collect source and prepare
185function install_heat() {
186 git_clone $HEAT_REPO $HEAT_DIR $HEAT_BRANCH
187}
188
189# start_heat() - Start running processes, including screen
190function start_heat() {
191 screen_it h-eng "cd $HEAT_DIR; bin/heat-engine --config-file=$HEAT_CONF_DIR/heat-engine.conf"
Steve Bakerbb421be2012-10-10 13:19:10 +1300192 screen_it h-api "cd $HEAT_DIR; bin/heat-api --config-dir=$HEAT_CONF_DIR/heat-api.conf"
Angus Salkelde2790212012-09-11 11:24:09 +1000193 screen_it h-api-cfn "cd $HEAT_DIR; bin/heat-api-cfn --config-dir=$HEAT_CONF_DIR/heat-api-cfn.conf"
194 screen_it h-api-cw "cd $HEAT_DIR; bin/heat-api-cloudwatch --config-dir=$HEAT_CONF_DIR/heat-api-cloudwatch.conf"
Steve Bakerbfdad752012-08-18 09:00:42 +1200195}
196
Dean Troyer699a29f2012-09-10 14:10:27 -0500197# stop_heat() - Stop running processes
Steve Bakerbfdad752012-08-18 09:00:42 +1200198function stop_heat() {
Dean Troyer699a29f2012-09-10 14:10:27 -0500199 # Kill the cinder screen windows
Steven Hardy08b4e9b2012-11-30 13:31:49 +0000200 for serv in h-eng h-api-cfn h-api-cw; do
Dean Troyer699a29f2012-09-10 14:10:27 -0500201 screen -S $SCREEN_NAME -p $serv -X kill
202 done
Steve Bakerbfdad752012-08-18 09:00:42 +1200203}
Dean Troyer7903b792012-09-13 17:16:12 -0500204
Dean Troyercc6b4432013-04-08 15:38:03 -0500205
Dean Troyer7903b792012-09-13 17:16:12 -0500206# Restore xtrace
207$XTRACE
Sean Dague584d90e2013-03-29 14:34:53 -0400208
209# Local variables:
210# mode: shell-script
211# End: