blob: 6f442f877ac67ee6eb893751bba87d66d3ccf9c1 [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
4# ENABLED_SERVICES+=,heat,h-api,h-eng,h-meta
5
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
18# Print the commands being run so that we can see the command that triggers
19# an error. It is also useful for following along as the install occurs.
20set -o xtrace
21
22
23# Defaults
24# --------
25HEAT_DIR=$DEST/heat
26
27# 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
36# configure_heat() - Set config files, create data dirs, etc
37function configure_heat() {
38 setup_develop $HEAT_DIR
39
40 HEAT_CONF_DIR=/etc/heat
41 if [[ ! -d $HEAT_CONF_DIR ]]; then
42 sudo mkdir -p $HEAT_CONF_DIR
43 fi
44 sudo chown `whoami` $HEAT_CONF_DIR
45
46 HEAT_API_HOST=${HEAT_API_HOST:-$SERVICE_HOST}
47 HEAT_API_PORT=${HEAT_API_PORT:-8000}
48 HEAT_ENGINE_HOST=${HEAT_ENGINE_HOST:-$SERVICE_HOST}
49 HEAT_ENGINE_PORT=${HEAT_ENGINE_PORT:-8001}
50 HEAT_METADATA_HOST=${HEAT_METADATA_HOST:-$SERVICE_HOST}
51 HEAT_METADATA_PORT=${HEAT_METADATA_PORT:-8002}
52
53 HEAT_API_CONF=$HEAT_CONF_DIR/heat-api.conf
54 cp $HEAT_DIR/etc/heat-api.conf $HEAT_API_CONF
55 iniset $HEAT_API_CONF DEFAULT debug True
56 inicomment $HEAT_API_CONF DEFAULT log_file
57 iniset $HEAT_API_CONF DEFAULT use_syslog $SYSLOG
58 iniset $HEAT_API_CONF DEFAULT bind_host $HEAT_API_HOST
59 iniset $HEAT_API_CONF DEFAULT bind_port $HEAT_API_PORT
60
61 if is_service_enabled rabbit; then
62 iniset $HEAT_API_CONF DEFAULT rpc_backend heat.openstack.common.rpc.impl_kombu
63 iniset $HEAT_API_CONF DEFAULT rabbit_password $RABBIT_PASSWORD
64 iniset $HEAT_API_CONF DEFAULT rabbit_host $RABBIT_HOST
65 elif is_service_enabled qpid; then
66 iniset $HEAT_API_CONF DEFAULT rpc_backend heat.openstack.common.rpc.impl_qpid
67 fi
68
69 HEAT_API_PASTE_INI=$HEAT_CONF_DIR/heat-api-paste.ini
70 cp $HEAT_DIR/etc/heat-api-paste.ini $HEAT_API_PASTE_INI
71 iniset $HEAT_API_PASTE_INI filter:authtoken auth_host $KEYSTONE_AUTH_HOST
72 iniset $HEAT_API_PASTE_INI filter:authtoken auth_port $KEYSTONE_AUTH_PORT
73 iniset $HEAT_API_PASTE_INI filter:authtoken auth_protocol $KEYSTONE_AUTH_PROTOCOL
74 iniset $HEAT_API_PASTE_INI filter:authtoken auth_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/v2.0
75 iniset $HEAT_API_PASTE_INI filter:authtoken admin_tenant_name $SERVICE_TENANT_NAME
76 iniset $HEAT_API_PASTE_INI filter:authtoken admin_user heat
77 iniset $HEAT_API_PASTE_INI filter:authtoken admin_password $SERVICE_PASSWORD
78 iniset $HEAT_API_PASTE_INI filter:ec2authtoken auth_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/v2.0
79 iniset $HEAT_API_PASTE_INI filter:ec2authtoken keystone_ec2_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/v2.0/ec2tokens
80
81 HEAT_ENGINE_CONF=$HEAT_CONF_DIR/heat-engine.conf
82 cp $HEAT_DIR/etc/heat-engine.conf $HEAT_ENGINE_CONF
83 iniset $HEAT_ENGINE_CONF DEFAULT debug True
84 inicomment $HEAT_ENGINE_CONF DEFAULT log_file
85 iniset $HEAT_ENGINE_CONF DEFAULT use_syslog $SYSLOG
86 iniset $HEAT_ENGINE_CONF DEFAULT bind_host $HEAT_ENGINE_HOST
87 iniset $HEAT_ENGINE_CONF DEFAULT bind_port $HEAT_ENGINE_PORT
88 iniset $HEAT_ENGINE_CONF DEFAULT sql_connection $BASE_SQL_CONN/heat?charset=utf8
89 iniset $HEAT_ENGINE_CONF DEFAULT auth_encryption_key `hexdump -n 16 -v -e '/1 "%02x"' /dev/random`
90
91 if is_service_enabled rabbit; then
92 iniset $HEAT_ENGINE_CONF DEFAULT rpc_backend heat.openstack.common.rpc.impl_kombu
93 iniset $HEAT_ENGINE_CONF DEFAULT rabbit_password $RABBIT_PASSWORD
94 iniset $HEAT_ENGINE_CONF DEFAULT rabbit_host $RABBIT_HOST
95 elif is_service_enabled qpid; then
96 iniset $HEAT_ENGINE_CONF DEFAULT rpc_backend heat.openstack.common.rpc.impl_qpid
97 fi
98
99 HEAT_ENGINE_PASTE_INI=$HEAT_CONF_DIR/heat-engine-paste.ini
100 cp $HEAT_DIR/etc/heat-engine-paste.ini $HEAT_ENGINE_PASTE_INI
101 iniset $HEAT_ENGINE_PASTE_INI filter:authtoken auth_host $KEYSTONE_AUTH_HOST
102 iniset $HEAT_ENGINE_PASTE_INI filter:authtoken auth_port $KEYSTONE_AUTH_PORT
103 iniset $HEAT_ENGINE_PASTE_INI filter:authtoken auth_protocol $KEYSTONE_AUTH_PROTOCOL
104 iniset $HEAT_ENGINE_PASTE_INI filter:authtoken auth_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/v2.0
105 iniset $HEAT_ENGINE_PASTE_INI filter:authtoken admin_tenant_name $SERVICE_TENANT_NAME
106 iniset $HEAT_ENGINE_PASTE_INI filter:authtoken admin_user heat
107 iniset $HEAT_ENGINE_PASTE_INI filter:authtoken admin_password $SERVICE_PASSWORD
108
109 HEAT_METADATA_CONF=$HEAT_CONF_DIR/heat-metadata.conf
110 cp $HEAT_DIR/etc/heat-metadata.conf $HEAT_METADATA_CONF
111 iniset $HEAT_METADATA_CONF DEFAULT debug True
112 inicomment $HEAT_METADATA_CONF DEFAULT log_file
113 iniset $HEAT_METADATA_CONF DEFAULT use_syslog $SYSLOG
114 iniset $HEAT_METADATA_CONF DEFAULT bind_host $HEAT_METADATA_HOST
115 iniset $HEAT_METADATA_CONF DEFAULT bind_port $HEAT_METADATA_PORT
116
117 if is_service_enabled rabbit; then
118 iniset $HEAT_METADATA_CONF DEFAULT rpc_backend heat.openstack.common.rpc.impl_kombu
119 iniset $HEAT_METADATA_CONF DEFAULT rabbit_password $RABBIT_PASSWORD
120 iniset $HEAT_METADATA_CONF DEFAULT rabbit_host $RABBIT_HOST
121 elif is_service_enabled qpid; then
122 iniset $HEAT_METADATA_CONF DEFAULT rpc_backend heat.openstack.common.rpc.impl_qpid
123 fi
124
125 HEAT_METADATA_PASTE_INI=$HEAT_CONF_DIR/heat-metadata-paste.ini
126 cp $HEAT_DIR/etc/heat-metadata-paste.ini $HEAT_METADATA_PASTE_INI
127
128}
129
130# init_heat() - Initialize database
131function init_heat() {
132
133 # (re)create heat database
134 mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'DROP DATABASE IF EXISTS heat;'
135 mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'CREATE DATABASE heat CHARACTER SET utf8;'
136
137 $HEAT_DIR/bin/heat-db-setup $os_PACKAGE -r $MYSQL_PASSWORD
138}
139
140# install_heat() - Collect source and prepare
141function install_heat() {
142 git_clone $HEAT_REPO $HEAT_DIR $HEAT_BRANCH
143}
144
145# start_heat() - Start running processes, including screen
146function start_heat() {
147 screen_it h-eng "cd $HEAT_DIR; bin/heat-engine --config-file=$HEAT_CONF_DIR/heat-engine.conf"
148 screen_it h-api "cd $HEAT_DIR; bin/heat-api --config-dir=$HEAT_CONF_DIR/heat-api.conf"
149 screen_it h-meta "cd $HEAT_DIR; bin/heat-metadata --config-dir=$HEAT_CONF_DIR/heat-metadata.conf"
150}
151
152# stop_heat() - Stop running processes (non-screen)
153function stop_heat() {
154 # This function intentionally left blank
155 :
156}