blob: efdcfad33cf63aa1be4eaecf136acb099ebbb897 [file] [log] [blame]
Steve Bakerbfdad752012-08-18 09:00:42 +12001# lib/heat
2# Install and start Heat service
3# To enable, add the following to localrc
Angus Salkelde2790212012-09-11 11:24:09 +10004# ENABLED_SERVICES+=,heat,h-api-cfn,h-api-cw,h-eng,h-meta
Steve Bakerbfdad752012-08-18 09:00:42 +12005
6# Dependencies:
7# - functions
8
9# stack.sh
10# ---------
11# install_XXX
12# configure_XXX
13# init_XXX
14# start_XXX
15# stop_XXX
16# cleanup_XXX
17
Dean Troyer7903b792012-09-13 17:16:12 -050018# Save trace setting
19XTRACE=$(set +o | grep xtrace)
20set +o xtrace
Steve Bakerbfdad752012-08-18 09:00:42 +120021
22
23# Defaults
24# --------
25HEAT_DIR=$DEST/heat
Steve Baker32761a42012-11-05 09:57:57 +130026HEATCLIENT_DIR=$DEST/python-heatclient
Steve Bakerbfdad752012-08-18 09:00:42 +120027# set up default directories
28
29# cleanup_heat() - Remove residual data files, anything left over from previous
30# runs that a clean run would need to clean up
31function cleanup_heat() {
32 # This function intentionally left blank
33 :
34}
35
Steve Baker32761a42012-11-05 09:57:57 +130036# configure_heatclient() - Set config files, create data dirs, etc
37function configure_heatclient() {
38 setup_develop $HEATCLIENT_DIR
39}
40
Steve Bakerbfdad752012-08-18 09:00:42 +120041# configure_heat() - Set config files, create data dirs, etc
42function configure_heat() {
43 setup_develop $HEAT_DIR
44
45 HEAT_CONF_DIR=/etc/heat
46 if [[ ! -d $HEAT_CONF_DIR ]]; then
47 sudo mkdir -p $HEAT_CONF_DIR
48 fi
49 sudo chown `whoami` $HEAT_CONF_DIR
50
Angus Salkelde2790212012-09-11 11:24:09 +100051 HEAT_API_CFN_HOST=${HEAT_API_CFN_HOST:-$SERVICE_HOST}
52 HEAT_API_CFN_PORT=${HEAT_API_CFN_PORT:-8000}
Steve Bakerbfdad752012-08-18 09:00:42 +120053 HEAT_ENGINE_HOST=${HEAT_ENGINE_HOST:-$SERVICE_HOST}
54 HEAT_ENGINE_PORT=${HEAT_ENGINE_PORT:-8001}
55 HEAT_METADATA_HOST=${HEAT_METADATA_HOST:-$SERVICE_HOST}
56 HEAT_METADATA_PORT=${HEAT_METADATA_PORT:-8002}
Angus Salkelde2790212012-09-11 11:24:09 +100057 HEAT_API_CW_HOST=${HEAT_API_CW_HOST:-$SERVICE_HOST}
58 HEAT_API_CW_PORT=${HEAT_API_CW_PORT:-8003}
Steve Bakerbb421be2012-10-10 13:19:10 +130059 HEAT_API_HOST=${HEAT_API_HOST:-$SERVICE_HOST}
60 HEAT_API_PORT=${HEAT_API_PORT:-8004}
Steve Bakerbfdad752012-08-18 09:00:42 +120061
Angus Salkelde2790212012-09-11 11:24:09 +100062 # cloudformation api
63 HEAT_API_CFN_CONF=$HEAT_CONF_DIR/heat-api-cfn.conf
64 cp $HEAT_DIR/etc/heat/heat-api-cfn.conf $HEAT_API_CFN_CONF
65 iniset $HEAT_API_CFN_CONF DEFAULT debug True
66 inicomment $HEAT_API_CFN_CONF DEFAULT log_file
67 iniset $HEAT_API_CFN_CONF DEFAULT use_syslog $SYSLOG
68 iniset $HEAT_API_CFN_CONF DEFAULT bind_host $HEAT_API_CFN_HOST
69 iniset $HEAT_API_CFN_CONF DEFAULT bind_port $HEAT_API_CFN_PORT
Steve Bakerbfdad752012-08-18 09:00:42 +120070
71 if is_service_enabled rabbit; then
Angus Salkelde2790212012-09-11 11:24:09 +100072 iniset $HEAT_API_CFN_CONF DEFAULT rpc_backend heat.openstack.common.rpc.impl_kombu
73 iniset $HEAT_API_CFN_CONF DEFAULT rabbit_password $RABBIT_PASSWORD
74 iniset $HEAT_API_CFN_CONF DEFAULT rabbit_host $RABBIT_HOST
Steve Bakerbfdad752012-08-18 09:00:42 +120075 elif is_service_enabled qpid; then
Angus Salkelde2790212012-09-11 11:24:09 +100076 iniset $HEAT_API_CFN_CONF DEFAULT rpc_backend heat.openstack.common.rpc.impl_qpid
Steve Bakerbfdad752012-08-18 09:00:42 +120077 fi
78
Angus Salkelde2790212012-09-11 11:24:09 +100079 HEAT_API_CFN_PASTE_INI=$HEAT_CONF_DIR/heat-api-cfn-paste.ini
80 cp $HEAT_DIR/etc/heat/heat-api-cfn-paste.ini $HEAT_API_CFN_PASTE_INI
81 iniset $HEAT_API_CFN_PASTE_INI filter:authtoken auth_host $KEYSTONE_AUTH_HOST
82 iniset $HEAT_API_CFN_PASTE_INI filter:authtoken auth_port $KEYSTONE_AUTH_PORT
83 iniset $HEAT_API_CFN_PASTE_INI filter:authtoken auth_protocol $KEYSTONE_AUTH_PROTOCOL
84 iniset $HEAT_API_CFN_PASTE_INI filter:authtoken auth_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/v2.0
85 iniset $HEAT_API_CFN_PASTE_INI filter:authtoken admin_tenant_name $SERVICE_TENANT_NAME
86 iniset $HEAT_API_CFN_PASTE_INI filter:authtoken admin_user heat
87 iniset $HEAT_API_CFN_PASTE_INI filter:authtoken admin_password $SERVICE_PASSWORD
88 iniset $HEAT_API_CFN_PASTE_INI filter:ec2authtoken auth_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/v2.0
89 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 +120090
Steve Bakerbb421be2012-10-10 13:19:10 +130091 # openstack api
92 HEAT_API_CONF=$HEAT_CONF_DIR/heat-api.conf
93 cp $HEAT_DIR/etc/heat/heat-api.conf $HEAT_API_CONF
94 iniset $HEAT_API_CONF DEFAULT debug True
95 inicomment $HEAT_API_CONF DEFAULT log_file
96 iniset $HEAT_API_CONF DEFAULT use_syslog $SYSLOG
97 iniset $HEAT_API_CONF DEFAULT bind_host $HEAT_API_HOST
98 iniset $HEAT_API_CONF DEFAULT bind_port $HEAT_API_PORT
99
100 if is_service_enabled rabbit; then
101 iniset $HEAT_API_CONF DEFAULT rpc_backend heat.openstack.common.rpc.impl_kombu
102 iniset $HEAT_API_CONF DEFAULT rabbit_password $RABBIT_PASSWORD
103 iniset $HEAT_API_CONF DEFAULT rabbit_host $RABBIT_HOST
104 elif is_service_enabled qpid; then
105 iniset $HEAT_API_CONF DEFAULT rpc_backend heat.openstack.common.rpc.impl_qpid
106 fi
107
108 HEAT_API_PASTE_INI=$HEAT_CONF_DIR/heat-api-paste.ini
109 cp $HEAT_DIR/etc/heat/heat-api-paste.ini $HEAT_API_PASTE_INI
110 iniset $HEAT_API_PASTE_INI filter:authtoken auth_host $KEYSTONE_AUTH_HOST
111 iniset $HEAT_API_PASTE_INI filter:authtoken auth_port $KEYSTONE_AUTH_PORT
112 iniset $HEAT_API_PASTE_INI filter:authtoken auth_protocol $KEYSTONE_AUTH_PROTOCOL
113 iniset $HEAT_API_PASTE_INI filter:authtoken auth_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/v2.0
114 iniset $HEAT_API_PASTE_INI filter:authtoken admin_tenant_name $SERVICE_TENANT_NAME
115 iniset $HEAT_API_PASTE_INI filter:authtoken admin_user heat
116 iniset $HEAT_API_PASTE_INI filter:authtoken admin_password $SERVICE_PASSWORD
117 iniset $HEAT_API_PASTE_INI filter:ec2authtoken auth_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/v2.0
118 iniset $HEAT_API_PASTE_INI filter:ec2authtoken keystone_ec2_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/v2.0/ec2tokens
119
Angus Salkelde2790212012-09-11 11:24:09 +1000120 # engine
Steve Bakerbfdad752012-08-18 09:00:42 +1200121 HEAT_ENGINE_CONF=$HEAT_CONF_DIR/heat-engine.conf
Angus Salkelde2790212012-09-11 11:24:09 +1000122 cp $HEAT_DIR/etc/heat/heat-engine.conf $HEAT_ENGINE_CONF
Steve Bakerbfdad752012-08-18 09:00:42 +1200123 iniset $HEAT_ENGINE_CONF DEFAULT debug True
124 inicomment $HEAT_ENGINE_CONF DEFAULT log_file
125 iniset $HEAT_ENGINE_CONF DEFAULT use_syslog $SYSLOG
126 iniset $HEAT_ENGINE_CONF DEFAULT bind_host $HEAT_ENGINE_HOST
127 iniset $HEAT_ENGINE_CONF DEFAULT bind_port $HEAT_ENGINE_PORT
Terry Wilson428af5a2012-11-01 16:12:39 -0400128 local dburl
129 database_connection_url dburl heat
130 iniset $HEAT_ENGINE_CONF DEFAULT sql_connection $dburl
Steve Bakerbfdad752012-08-18 09:00:42 +1200131 iniset $HEAT_ENGINE_CONF DEFAULT auth_encryption_key `hexdump -n 16 -v -e '/1 "%02x"' /dev/random`
132
133 if is_service_enabled rabbit; then
134 iniset $HEAT_ENGINE_CONF DEFAULT rpc_backend heat.openstack.common.rpc.impl_kombu
135 iniset $HEAT_ENGINE_CONF DEFAULT rabbit_password $RABBIT_PASSWORD
136 iniset $HEAT_ENGINE_CONF DEFAULT rabbit_host $RABBIT_HOST
137 elif is_service_enabled qpid; then
138 iniset $HEAT_ENGINE_CONF DEFAULT rpc_backend heat.openstack.common.rpc.impl_qpid
139 fi
140
Angus Salkelde2790212012-09-11 11:24:09 +1000141 # metadata api
Steve Bakerbfdad752012-08-18 09:00:42 +1200142 HEAT_METADATA_CONF=$HEAT_CONF_DIR/heat-metadata.conf
Angus Salkelde2790212012-09-11 11:24:09 +1000143 cp $HEAT_DIR/etc/heat/heat-metadata.conf $HEAT_METADATA_CONF
Steve Bakerbfdad752012-08-18 09:00:42 +1200144 iniset $HEAT_METADATA_CONF DEFAULT debug True
145 inicomment $HEAT_METADATA_CONF DEFAULT log_file
146 iniset $HEAT_METADATA_CONF DEFAULT use_syslog $SYSLOG
147 iniset $HEAT_METADATA_CONF DEFAULT bind_host $HEAT_METADATA_HOST
148 iniset $HEAT_METADATA_CONF DEFAULT bind_port $HEAT_METADATA_PORT
149
150 if is_service_enabled rabbit; then
151 iniset $HEAT_METADATA_CONF DEFAULT rpc_backend heat.openstack.common.rpc.impl_kombu
152 iniset $HEAT_METADATA_CONF DEFAULT rabbit_password $RABBIT_PASSWORD
153 iniset $HEAT_METADATA_CONF DEFAULT rabbit_host $RABBIT_HOST
154 elif is_service_enabled qpid; then
155 iniset $HEAT_METADATA_CONF DEFAULT rpc_backend heat.openstack.common.rpc.impl_qpid
156 fi
157
158 HEAT_METADATA_PASTE_INI=$HEAT_CONF_DIR/heat-metadata-paste.ini
Angus Salkelde2790212012-09-11 11:24:09 +1000159 cp $HEAT_DIR/etc/heat/heat-metadata-paste.ini $HEAT_METADATA_PASTE_INI
Steve Bakerbfdad752012-08-18 09:00:42 +1200160
Angus Salkelde2790212012-09-11 11:24:09 +1000161 # cloudwatch api
162 HEAT_API_CW_CONF=$HEAT_CONF_DIR/heat-api-cloudwatch.conf
163 cp $HEAT_DIR/etc/heat/heat-api-cloudwatch.conf $HEAT_API_CW_CONF
164 iniset $HEAT_API_CW_CONF DEFAULT debug True
165 inicomment $HEAT_API_CW_CONF DEFAULT log_file
166 iniset $HEAT_API_CW_CONF DEFAULT use_syslog $SYSLOG
167 iniset $HEAT_API_CW_CONF DEFAULT bind_host $HEAT_API_CW_HOST
168 iniset $HEAT_API_CW_CONF DEFAULT bind_port $HEAT_API_CW_PORT
169
170 if is_service_enabled rabbit; then
171 iniset $HEAT_API_CW_CONF DEFAULT rpc_backend heat.openstack.common.rpc.impl_kombu
172 iniset $HEAT_API_CW_CONF DEFAULT rabbit_password $RABBIT_PASSWORD
173 iniset $HEAT_API_CW_CONF DEFAULT rabbit_host $RABBIT_HOST
174 elif is_service_enabled qpid; then
175 iniset $HEAT_API_CW_CONF DEFAULT rpc_backend heat.openstack.common.rpc.impl_qpid
176 fi
177
178 HEAT_API_CW_PASTE_INI=$HEAT_CONF_DIR/heat-api-cloudwatch-paste.ini
179 cp $HEAT_DIR/etc/heat/heat-api-cloudwatch-paste.ini $HEAT_API_CW_PASTE_INI
180 iniset $HEAT_API_CW_PASTE_INI filter:authtoken auth_host $KEYSTONE_AUTH_HOST
181 iniset $HEAT_API_CW_PASTE_INI filter:authtoken auth_port $KEYSTONE_AUTH_PORT
182 iniset $HEAT_API_CW_PASTE_INI filter:authtoken auth_protocol $KEYSTONE_AUTH_PROTOCOL
183 iniset $HEAT_API_CW_PASTE_INI filter:authtoken auth_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/v2.0
184 iniset $HEAT_API_CW_PASTE_INI filter:authtoken admin_tenant_name $SERVICE_TENANT_NAME
185 iniset $HEAT_API_CW_PASTE_INI filter:authtoken admin_user heat
186 iniset $HEAT_API_CW_PASTE_INI filter:authtoken admin_password $SERVICE_PASSWORD
187 iniset $HEAT_API_CW_PASTE_INI filter:ec2authtoken auth_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/v2.0
188 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 +1200189}
190
191# init_heat() - Initialize database
192function init_heat() {
193
194 # (re)create heat database
Terry Wilson428af5a2012-11-01 16:12:39 -0400195 recreate_database heat utf8
Steve Bakerbfdad752012-08-18 09:00:42 +1200196
197 $HEAT_DIR/bin/heat-db-setup $os_PACKAGE -r $MYSQL_PASSWORD
Steve Bakerbad9d892012-10-25 14:49:47 +1300198 $HEAT_DIR/tools/nova_create_flavors.sh
Steve Bakerbfdad752012-08-18 09:00:42 +1200199}
200
Steve Baker32761a42012-11-05 09:57:57 +1300201# install_heatclient() - Collect source and prepare
202function install_heatclient() {
203 git_clone $HEATCLIENT_REPO $HEATCLIENT_DIR $HEATCLIENT_BRANCH
204}
205
Steve Bakerbfdad752012-08-18 09:00:42 +1200206# install_heat() - Collect source and prepare
207function install_heat() {
208 git_clone $HEAT_REPO $HEAT_DIR $HEAT_BRANCH
209}
210
211# start_heat() - Start running processes, including screen
212function start_heat() {
213 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 +1300214 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 +1000215 screen_it h-api-cfn "cd $HEAT_DIR; bin/heat-api-cfn --config-dir=$HEAT_CONF_DIR/heat-api-cfn.conf"
216 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 +1200217 screen_it h-meta "cd $HEAT_DIR; bin/heat-metadata --config-dir=$HEAT_CONF_DIR/heat-metadata.conf"
218}
219
Dean Troyer699a29f2012-09-10 14:10:27 -0500220# stop_heat() - Stop running processes
Steve Bakerbfdad752012-08-18 09:00:42 +1200221function stop_heat() {
Dean Troyer699a29f2012-09-10 14:10:27 -0500222 # Kill the cinder screen windows
223 for serv in h-eng h-api-cfn h-api-cw h-meta; do
224 screen -S $SCREEN_NAME -p $serv -X kill
225 done
Steve Bakerbfdad752012-08-18 09:00:42 +1200226}
Dean Troyer7903b792012-09-13 17:16:12 -0500227
228# Restore xtrace
229$XTRACE