blob: 85177738dcb09aa9ba2964af8a58b53c3950c384 [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
Kieran Spear70338292013-05-28 11:31:31 +10005# ENABLED_SERVICES+=,heat,h-api,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
44# configure_heat() - Set config files, create data dirs, etc
45function configure_heat() {
46 setup_develop $HEAT_DIR
47
48 HEAT_CONF_DIR=/etc/heat
49 if [[ ! -d $HEAT_CONF_DIR ]]; then
50 sudo mkdir -p $HEAT_CONF_DIR
51 fi
Attila Fazekas91b8d132013-01-06 22:40:09 +010052 sudo chown $STACK_USER $HEAT_CONF_DIR
Steve Bakerbfdad752012-08-18 09:00:42 +120053
Angus Salkelde2790212012-09-11 11:24:09 +100054 HEAT_API_CFN_HOST=${HEAT_API_CFN_HOST:-$SERVICE_HOST}
55 HEAT_API_CFN_PORT=${HEAT_API_CFN_PORT:-8000}
Steve Bakerbfdad752012-08-18 09:00:42 +120056 HEAT_ENGINE_HOST=${HEAT_ENGINE_HOST:-$SERVICE_HOST}
57 HEAT_ENGINE_PORT=${HEAT_ENGINE_PORT:-8001}
Angus Salkelde2790212012-09-11 11:24:09 +100058 HEAT_API_CW_HOST=${HEAT_API_CW_HOST:-$SERVICE_HOST}
59 HEAT_API_CW_PORT=${HEAT_API_CW_PORT:-8003}
Steve Bakerbb421be2012-10-10 13:19:10 +130060 HEAT_API_HOST=${HEAT_API_HOST:-$SERVICE_HOST}
61 HEAT_API_PORT=${HEAT_API_PORT:-8004}
Steve Bakerd5cd79b2013-04-13 11:14:41 -070062 HEAT_API_PASTE_FILE=$HEAT_CONF_DIR/api-paste.ini
63 HEAT_POLICY_FILE=$HEAT_CONF_DIR/policy.json
64
65 cp $HEAT_DIR/etc/heat/api-paste.ini $HEAT_API_PASTE_FILE
66 cp $HEAT_DIR/etc/heat/policy.json $HEAT_POLICY_FILE
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 Bakerfd1ebe72013-04-13 09:49:14 +100084 iniset $HEAT_API_CFN_CONF ec2authtoken auth_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/v2.0
85 iniset $HEAT_API_CFN_CONF ec2authtoken keystone_ec2_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/v2.0/ec2tokens
Steve Bakerbfdad752012-08-18 09:00:42 +120086
Akihiro MOTOKIb0f1c382013-01-13 17:58:12 +090087 iniset_rpc_backend heat $HEAT_API_CFN_CONF DEFAULT
Steve Bakerbfdad752012-08-18 09:00:42 +120088
Dean Troyer6d04fd72012-12-21 11:03:37 -060089 # OpenStack API
Steve Bakerbb421be2012-10-10 13:19:10 +130090 HEAT_API_CONF=$HEAT_CONF_DIR/heat-api.conf
91 cp $HEAT_DIR/etc/heat/heat-api.conf $HEAT_API_CONF
92 iniset $HEAT_API_CONF DEFAULT debug True
93 inicomment $HEAT_API_CONF DEFAULT log_file
94 iniset $HEAT_API_CONF DEFAULT use_syslog $SYSLOG
95 iniset $HEAT_API_CONF DEFAULT bind_host $HEAT_API_HOST
96 iniset $HEAT_API_CONF DEFAULT bind_port $HEAT_API_PORT
Steve Bakerc3249082013-04-09 13:41:47 +120097 iniset $HEAT_API_CONF keystone_authtoken auth_host $KEYSTONE_AUTH_HOST
98 iniset $HEAT_API_CONF keystone_authtoken auth_port $KEYSTONE_AUTH_PORT
99 iniset $HEAT_API_CONF keystone_authtoken auth_protocol $KEYSTONE_AUTH_PROTOCOL
100 iniset $HEAT_API_CONF keystone_authtoken auth_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/v2.0
101 iniset $HEAT_API_CONF keystone_authtoken admin_tenant_name $SERVICE_TENANT_NAME
102 iniset $HEAT_API_CONF keystone_authtoken admin_user heat
103 iniset $HEAT_API_CONF keystone_authtoken admin_password $SERVICE_PASSWORD
104 iniset $HEAT_API_CONF keystone_authtoken signing_dir $HEAT_AUTH_CACHE_DIR/api
Steve Bakerfd1ebe72013-04-13 09:49:14 +1000105 iniset $HEAT_API_CONF ec2authtoken auth_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/v2.0
106 iniset $HEAT_API_CONF ec2authtoken keystone_ec2_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/v2.0/ec2tokens
Steve Bakerbb421be2012-10-10 13:19:10 +1300107
Akihiro MOTOKIb0f1c382013-01-13 17:58:12 +0900108 iniset_rpc_backend heat $HEAT_API_CONF DEFAULT
Steve Bakerbb421be2012-10-10 13:19:10 +1300109
Steve Bakerbb421be2012-10-10 13:19:10 +1300110
Angus Salkelde2790212012-09-11 11:24:09 +1000111 # engine
Steve Bakerbfdad752012-08-18 09:00:42 +1200112 HEAT_ENGINE_CONF=$HEAT_CONF_DIR/heat-engine.conf
Angus Salkelde2790212012-09-11 11:24:09 +1000113 cp $HEAT_DIR/etc/heat/heat-engine.conf $HEAT_ENGINE_CONF
Steve Bakerbfdad752012-08-18 09:00:42 +1200114 iniset $HEAT_ENGINE_CONF DEFAULT debug True
115 inicomment $HEAT_ENGINE_CONF DEFAULT log_file
116 iniset $HEAT_ENGINE_CONF DEFAULT use_syslog $SYSLOG
117 iniset $HEAT_ENGINE_CONF DEFAULT bind_host $HEAT_ENGINE_HOST
118 iniset $HEAT_ENGINE_CONF DEFAULT bind_port $HEAT_ENGINE_PORT
Steve Bakerb592b292012-11-21 14:20:12 +1300119 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 +1300120 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 +1300121 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 +0100122 iniset $HEAT_ENGINE_CONF DEFAULT sql_connection `database_connection_url heat`
Steve Bakerbfdad752012-08-18 09:00:42 +1200123 iniset $HEAT_ENGINE_CONF DEFAULT auth_encryption_key `hexdump -n 16 -v -e '/1 "%02x"' /dev/random`
124
Akihiro MOTOKIb0f1c382013-01-13 17:58:12 +0900125 iniset_rpc_backend heat $HEAT_ENGINE_CONF DEFAULT
Steve Bakerbfdad752012-08-18 09:00:42 +1200126
Dean Troyer6d04fd72012-12-21 11:03:37 -0600127 # Cloudwatch API
Angus Salkelde2790212012-09-11 11:24:09 +1000128 HEAT_API_CW_CONF=$HEAT_CONF_DIR/heat-api-cloudwatch.conf
129 cp $HEAT_DIR/etc/heat/heat-api-cloudwatch.conf $HEAT_API_CW_CONF
130 iniset $HEAT_API_CW_CONF DEFAULT debug True
131 inicomment $HEAT_API_CW_CONF DEFAULT log_file
132 iniset $HEAT_API_CW_CONF DEFAULT use_syslog $SYSLOG
133 iniset $HEAT_API_CW_CONF DEFAULT bind_host $HEAT_API_CW_HOST
134 iniset $HEAT_API_CW_CONF DEFAULT bind_port $HEAT_API_CW_PORT
Steve Bakerc3249082013-04-09 13:41:47 +1200135 iniset $HEAT_API_CW_CONF keystone_authtoken auth_host $KEYSTONE_AUTH_HOST
136 iniset $HEAT_API_CW_CONF keystone_authtoken auth_port $KEYSTONE_AUTH_PORT
137 iniset $HEAT_API_CW_CONF keystone_authtoken auth_protocol $KEYSTONE_AUTH_PROTOCOL
138 iniset $HEAT_API_CW_CONF keystone_authtoken auth_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/v2.0
139 iniset $HEAT_API_CW_CONF keystone_authtoken admin_tenant_name $SERVICE_TENANT_NAME
140 iniset $HEAT_API_CW_CONF keystone_authtoken admin_user heat
141 iniset $HEAT_API_CW_CONF keystone_authtoken admin_password $SERVICE_PASSWORD
142 iniset $HEAT_API_CW_CONF keystone_authtoken signing_dir $HEAT_AUTH_CACHE_DIR/api-cloudwatch
Steve Bakerfd1ebe72013-04-13 09:49:14 +1000143 iniset $HEAT_API_CW_CONF ec2authtoken auth_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/v2.0
144 iniset $HEAT_API_CW_CONF ec2authtoken keystone_ec2_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/v2.0/ec2tokens
Angus Salkelde2790212012-09-11 11:24:09 +1000145
Akihiro MOTOKIb0f1c382013-01-13 17:58:12 +0900146 iniset_rpc_backend heat $HEAT_API_CW_CONF DEFAULT
Angus Salkelde2790212012-09-11 11:24:09 +1000147
Steve Bakerbfdad752012-08-18 09:00:42 +1200148}
149
150# init_heat() - Initialize database
151function init_heat() {
152
153 # (re)create heat database
Terry Wilson428af5a2012-11-01 16:12:39 -0400154 recreate_database heat utf8
Steve Bakerbfdad752012-08-18 09:00:42 +1200155
Steve Bakere3111322013-06-19 13:57:31 +1200156 $HEAT_DIR/bin/heat-manage db_sync
Steve Bakerc3249082013-04-09 13:41:47 +1200157 create_heat_cache_dir
158}
159
160# create_heat_cache_dir() - Part of the init_heat() process
161function create_heat_cache_dir() {
162 # Create cache dirs
163 sudo mkdir -p $HEAT_AUTH_CACHE_DIR/api
164 sudo chown $STACK_USER $HEAT_AUTH_CACHE_DIR/api
165 sudo mkdir -p $HEAT_AUTH_CACHE_DIR/api-cfn
166 sudo chown $STACK_USER $HEAT_AUTH_CACHE_DIR/api-cfn
167 sudo mkdir -p $HEAT_AUTH_CACHE_DIR/api-cloudwatch
168 sudo chown $STACK_USER $HEAT_AUTH_CACHE_DIR/api-cloudwatch
Steve Bakerbfdad752012-08-18 09:00:42 +1200169}
170
Steve Baker32761a42012-11-05 09:57:57 +1300171# install_heatclient() - Collect source and prepare
172function install_heatclient() {
173 git_clone $HEATCLIENT_REPO $HEATCLIENT_DIR $HEATCLIENT_BRANCH
Sean Dagued644e232013-07-25 15:34:48 -0400174 setup_develop $HEATCLIENT_DIR
Steve Baker32761a42012-11-05 09:57:57 +1300175}
176
Steve Bakerbfdad752012-08-18 09:00:42 +1200177# install_heat() - Collect source and prepare
178function install_heat() {
179 git_clone $HEAT_REPO $HEAT_DIR $HEAT_BRANCH
180}
181
182# start_heat() - Start running processes, including screen
183function start_heat() {
184 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 +1300185 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 +1000186 screen_it h-api-cfn "cd $HEAT_DIR; bin/heat-api-cfn --config-dir=$HEAT_CONF_DIR/heat-api-cfn.conf"
187 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 +1200188}
189
Dean Troyer699a29f2012-09-10 14:10:27 -0500190# stop_heat() - Stop running processes
Steve Bakerbfdad752012-08-18 09:00:42 +1200191function stop_heat() {
Kieran Spear70338292013-05-28 11:31:31 +1000192 # Kill the screen windows
193 for serv in h-eng h-api h-api-cfn h-api-cw; do
Dean Troyer699a29f2012-09-10 14:10:27 -0500194 screen -S $SCREEN_NAME -p $serv -X kill
195 done
Steve Bakerbfdad752012-08-18 09:00:42 +1200196}
Dean Troyer7903b792012-09-13 17:16:12 -0500197
Dean Troyercc6b4432013-04-08 15:38:03 -0500198
Dean Troyer7903b792012-09-13 17:16:12 -0500199# Restore xtrace
200$XTRACE
Sean Dague584d90e2013-03-29 14:34:53 -0400201
202# Local variables:
203# mode: shell-script
204# End: