blob: a088e828865da9337063ddb56734d815bf2e6143 [file] [log] [blame]
Sean Daguee263c822014-12-05 14:25:28 -05001#!/bin/bash
2#
Mate Lakat45ea0812013-09-25 10:00:29 +01003# lib/heat
Dean Troyer6d04fd72012-12-21 11:03:37 -06004# Install and start **Heat** service
5
Steve Bakerbfdad752012-08-18 09:00:42 +12006# To enable, add the following to localrc
Adam Spiers6a5aa7c2013-10-24 11:27:02 +01007#
8# ENABLED_SERVICES+=,heat,h-api,h-api-cfn,h-api-cw,h-eng
Steve Bakerbfdad752012-08-18 09:00:42 +12009
10# Dependencies:
Steve Baker249e36d2015-03-05 14:01:45 +130011# (none)
Steve Bakerbfdad752012-08-18 09:00:42 +120012
13# stack.sh
14# ---------
Adam Spiers6a5aa7c2013-10-24 11:27:02 +010015# - install_heatclient
16# - install_heat
17# - configure_heatclient
18# - configure_heat
19# - init_heat
20# - start_heat
21# - stop_heat
22# - cleanup_heat
Steve Bakerbfdad752012-08-18 09:00:42 +120023
Dean Troyer7903b792012-09-13 17:16:12 -050024# Save trace setting
25XTRACE=$(set +o | grep xtrace)
26set +o xtrace
Steve Bakerbfdad752012-08-18 09:00:42 +120027
28
29# Defaults
30# --------
Dean Troyercc6b4432013-04-08 15:38:03 -050031
32# set up default directories
Sean Daguee08ab102014-11-13 17:09:28 -050033GITDIR["python-heatclient"]=$DEST/python-heatclient
Sean Dague5cb19062014-11-01 01:37:45 +010034
Steve Bakerbfdad752012-08-18 09:00:42 +120035HEAT_DIR=$DEST/heat
Steve Baker315971d2014-05-27 12:24:18 +120036HEAT_CFNTOOLS_DIR=$DEST/heat-cfntools
37HEAT_TEMPLATES_REPO_DIR=$DEST/heat-templates
Steve Baker249e36d2015-03-05 14:01:45 +130038OCC_DIR=$DEST/os-collect-config
39ORC_DIR=$DEST/os-refresh-config
40OAC_DIR=$DEST/os-apply-config
41
42HEAT_PIP_REPO=$DATA_DIR/heat-pip-repo
43HEAT_PIP_REPO_PORT=${HEAT_PIP_REPO_PORT:-8899}
44
Steve Bakerc3249082013-04-09 13:41:47 +120045HEAT_AUTH_CACHE_DIR=${HEAT_AUTH_CACHE_DIR:-/var/cache/heat}
Sean Dague53753292014-12-04 19:38:15 -050046HEAT_STANDALONE=$(trueorfalse False HEAT_STANDALONE)
47HEAT_ENABLE_ADOPT_ABANDON=$(trueorfalse False HEAT_ENABLE_ADOPT_ABANDON)
Angus Salkeldf645a852013-08-26 10:13:36 +100048HEAT_CONF_DIR=/etc/heat
Angus Salkelda213e2c2013-08-30 10:48:46 +100049HEAT_CONF=$HEAT_CONF_DIR/heat.conf
Angus Salkeldf645a852013-08-26 10:13:36 +100050HEAT_ENV_DIR=$HEAT_CONF_DIR/environment.d
Angus Salkeldfb71a272013-08-26 10:15:38 +100051HEAT_TEMPLATES_DIR=$HEAT_CONF_DIR/templates
Sean Dague53753292014-12-04 19:38:15 -050052HEAT_STACK_DOMAIN=$(trueorfalse True HEAT_STACK_DOMAIN)
Steve Bakere389aed2014-09-23 17:10:39 +120053HEAT_API_HOST=${HEAT_API_HOST:-$HOST_IP}
54HEAT_API_PORT=${HEAT_API_PORT:-8004}
Steven Hardy3163c172015-01-23 13:26:29 +000055
Dean Troyercc6b4432013-04-08 15:38:03 -050056
Steven Hardyf83cf932014-03-12 16:54:01 +000057# other default options
58HEAT_DEFERRED_AUTH=${HEAT_DEFERRED_AUTH:-trusts}
59
Dean Troyer4237f592014-01-29 16:22:11 -060060# Tell Tempest this project is present
61TEMPEST_SERVICES+=,heat
62
63
Dean Troyercc6b4432013-04-08 15:38:03 -050064# Functions
65# ---------
Steve Bakerbfdad752012-08-18 09:00:42 +120066
Sean Dague29870cc2014-03-14 14:32:01 -040067# Test if any Heat services are enabled
68# is_heat_enabled
69function is_heat_enabled {
70 [[ ,${ENABLED_SERVICES} =~ ,"h-" ]] && return 0
71 return 1
72}
73
Steve Bakerbfdad752012-08-18 09:00:42 +120074# cleanup_heat() - Remove residual data files, anything left over from previous
75# runs that a clean run would need to clean up
Ian Wienandaee18c72014-02-21 15:35:08 +110076function cleanup_heat {
Steve Bakerc3249082013-04-09 13:41:47 +120077 sudo rm -rf $HEAT_AUTH_CACHE_DIR
Angus Salkeldf645a852013-08-26 10:13:36 +100078 sudo rm -rf $HEAT_ENV_DIR
Angus Salkeldfb71a272013-08-26 10:15:38 +100079 sudo rm -rf $HEAT_TEMPLATES_DIR
Steve Bakerbfdad752012-08-18 09:00:42 +120080}
81
82# configure_heat() - Set config files, create data dirs, etc
Ian Wienandaee18c72014-02-21 15:35:08 +110083function configure_heat {
Steve Bakere389aed2014-09-23 17:10:39 +120084 if [[ "$HEAT_STANDALONE" = "True" ]]; then
85 setup_develop $HEAT_DIR/contrib/heat_keystoneclient_v2
86 fi
Steve Bakerbfdad752012-08-18 09:00:42 +120087
Steve Bakerbfdad752012-08-18 09:00:42 +120088 if [[ ! -d $HEAT_CONF_DIR ]]; then
89 sudo mkdir -p $HEAT_CONF_DIR
90 fi
Attila Fazekas91b8d132013-01-06 22:40:09 +010091 sudo chown $STACK_USER $HEAT_CONF_DIR
Angus Salkelda213e2c2013-08-30 10:48:46 +100092 # remove old config files
93 rm -f $HEAT_CONF_DIR/heat-*.conf
Steve Bakerbfdad752012-08-18 09:00:42 +120094
Steve Bakere61bc612014-01-27 15:21:29 +130095 HEAT_API_CFN_HOST=${HEAT_API_CFN_HOST:-$HOST_IP}
Angus Salkelde2790212012-09-11 11:24:09 +100096 HEAT_API_CFN_PORT=${HEAT_API_CFN_PORT:-8000}
Steve Bakerbfdad752012-08-18 09:00:42 +120097 HEAT_ENGINE_HOST=${HEAT_ENGINE_HOST:-$SERVICE_HOST}
98 HEAT_ENGINE_PORT=${HEAT_ENGINE_PORT:-8001}
Steve Bakere61bc612014-01-27 15:21:29 +130099 HEAT_API_CW_HOST=${HEAT_API_CW_HOST:-$HOST_IP}
Angus Salkelde2790212012-09-11 11:24:09 +1000100 HEAT_API_CW_PORT=${HEAT_API_CW_PORT:-8003}
Steve Bakerd5cd79b2013-04-13 11:14:41 -0700101 HEAT_API_PASTE_FILE=$HEAT_CONF_DIR/api-paste.ini
102 HEAT_POLICY_FILE=$HEAT_CONF_DIR/policy.json
103
104 cp $HEAT_DIR/etc/heat/api-paste.ini $HEAT_API_PASTE_FILE
105 cp $HEAT_DIR/etc/heat/policy.json $HEAT_POLICY_FILE
Steve Bakerbfdad752012-08-18 09:00:42 +1200106
Angus Salkelda213e2c2013-08-30 10:48:46 +1000107 # common options
108 iniset_rpc_backend heat $HEAT_CONF DEFAULT
109 iniset $HEAT_CONF DEFAULT heat_metadata_server_url http://$HEAT_API_CFN_HOST:$HEAT_API_CFN_PORT
110 iniset $HEAT_CONF DEFAULT heat_waitcondition_server_url http://$HEAT_API_CFN_HOST:$HEAT_API_CFN_PORT/v1/waitcondition
111 iniset $HEAT_CONF DEFAULT heat_watch_server_url http://$HEAT_API_CW_HOST:$HEAT_API_CW_PORT
Angus Salkelde2314382013-11-14 14:36:46 +1100112 iniset $HEAT_CONF database connection `database_connection_url heat`
Attila Fazekasf71b5002014-05-28 09:52:22 +0200113 iniset $HEAT_CONF DEFAULT auth_encryption_key $(generate_hex_string 16)
Steve Bakerbfdad752012-08-18 09:00:42 +1200114
Bartosz Górski0abde392014-02-28 14:15:19 +0100115 iniset $HEAT_CONF DEFAULT region_name_for_services "$REGION_NAME"
116
Angus Salkelda213e2c2013-08-30 10:48:46 +1000117 # logging
118 iniset $HEAT_CONF DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL
119 iniset $HEAT_CONF DEFAULT use_syslog $SYSLOG
Steve Baker556ffe42013-08-06 16:42:38 +1200120 if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then
121 # Add color to logging output
Arata Notsu4897ff52013-10-09 18:49:32 +0900122 setup_colorized_logging $HEAT_CONF DEFAULT tenant user
Steve Baker556ffe42013-08-06 16:42:38 +1200123 fi
124
Jamie Lennox78b77262014-12-19 12:56:01 +1000125 # NOTE(jamielennox): heat re-uses specific values from the
126 # keystone_authtoken middleware group and so currently fails when using the
127 # auth plugin setup. This should be fixed in heat. Heat is also the only
128 # service that requires the auth_uri to include a /v2.0. Remove this custom
129 # setup when bug #1300246 is resolved.
130 iniset $HEAT_CONF keystone_authtoken identity_uri $KEYSTONE_AUTH_URI
131 iniset $HEAT_CONF keystone_authtoken auth_uri $KEYSTONE_SERVICE_URI/v2.0
132 iniset $HEAT_CONF keystone_authtoken admin_user heat
133 iniset $HEAT_CONF keystone_authtoken admin_password $SERVICE_PASSWORD
134 iniset $HEAT_CONF keystone_authtoken admin_tenant_name $SERVICE_TENANT_NAME
135 iniset $HEAT_CONF keystone_authtoken cafile $SSL_BUNDLE_FILE
136 iniset $HEAT_CONF keystone_authtoken signing_dir $HEAT_AUTH_CACHE_DIR
Angus Salkelde2790212012-09-11 11:24:09 +1000137
Angus Salkelda213e2c2013-08-30 10:48:46 +1000138 # ec2authtoken
Jamie Lennox3561d7f2014-05-21 17:18:43 +1000139 iniset $HEAT_CONF ec2authtoken auth_uri $KEYSTONE_SERVICE_URI/v2.0
Angus Salkelda213e2c2013-08-30 10:48:46 +1000140
141 # paste_deploy
Steve Bakere389aed2014-09-23 17:10:39 +1200142 if [[ "$HEAT_STANDALONE" = "True" ]]; then
143 iniset $HEAT_CONF paste_deploy flavor standalone
144 iniset $HEAT_CONF DEFAULT keystone_backend heat_keystoneclient_v2.client.KeystoneClientV2
145 iniset $HEAT_CONF clients_heat url "http://$HEAT_API_HOST:$HEAT_API_PORT/v1/%(tenant_id)s"
146 fi
Angus Salkelda213e2c2013-08-30 10:48:46 +1000147
148 # OpenStack API
Angus Salkelda213e2c2013-08-30 10:48:46 +1000149 iniset $HEAT_CONF heat_api bind_port $HEAT_API_PORT
Davanum Srinivas905275e2015-01-24 19:21:34 -0500150 iniset $HEAT_CONF heat_api workers "$API_WORKERS"
Angus Salkelda213e2c2013-08-30 10:48:46 +1000151
152 # Cloudformation API
Angus Salkelda213e2c2013-08-30 10:48:46 +1000153 iniset $HEAT_CONF heat_api_cfn bind_port $HEAT_API_CFN_PORT
154
155 # Cloudwatch API
Angus Salkelda213e2c2013-08-30 10:48:46 +1000156 iniset $HEAT_CONF heat_api_cloudwatch bind_port $HEAT_API_CW_PORT
Angus Salkelde2790212012-09-11 11:24:09 +1000157
Rob Crittenden18d47782014-03-19 17:47:42 -0400158 if is_ssl_enabled_service "key" || is_service_enabled tls-proxy; then
159 iniset $HEAT_CONF clients_keystone ca_file $SSL_BUNDLE_FILE
160 fi
161
162 if is_ssl_enabled_service "nova" || is_service_enabled tls-proxy; then
163 iniset $HEAT_CONF clients_nova ca_file $SSL_BUNDLE_FILE
164 fi
165
166 if is_ssl_enabled_service "cinder" || is_service_enabled tls-proxy; then
167 iniset $HEAT_CONF clients_cinder ca_file $SSL_BUNDLE_FILE
168 fi
169
Angus Salkeld826e4502015-01-07 17:52:05 +1000170 if [[ "$HEAT_ENABLE_ADOPT_ABANDON" = "True" ]]; then
171 iniset $HEAT_CONF DEFAULT enable_stack_adopt true
172 iniset $HEAT_CONF DEFAULT enable_stack_abandon true
173 fi
174
Angus Salkeldf645a852013-08-26 10:13:36 +1000175 # heat environment
176 sudo mkdir -p $HEAT_ENV_DIR
177 sudo chown $STACK_USER $HEAT_ENV_DIR
178 # copy the default environment
179 cp $HEAT_DIR/etc/heat/environment.d/* $HEAT_ENV_DIR/
180
Angus Salkeldfb71a272013-08-26 10:15:38 +1000181 # heat template resources.
182 sudo mkdir -p $HEAT_TEMPLATES_DIR
183 sudo chown $STACK_USER $HEAT_TEMPLATES_DIR
184 # copy the default templates
185 cp $HEAT_DIR/etc/heat/templates/* $HEAT_TEMPLATES_DIR/
186
Steve Bakerbfdad752012-08-18 09:00:42 +1200187}
188
189# init_heat() - Initialize database
Ian Wienandaee18c72014-02-21 15:35:08 +1100190function init_heat {
Steve Bakerbfdad752012-08-18 09:00:42 +1200191
192 # (re)create heat database
Ihar Hrachyshka157c84b2014-10-06 13:29:39 +0200193 recreate_database heat
Steve Bakerbfdad752012-08-18 09:00:42 +1200194
Steve Bakere3111322013-06-19 13:57:31 +1200195 $HEAT_DIR/bin/heat-manage db_sync
Steve Bakerc3249082013-04-09 13:41:47 +1200196 create_heat_cache_dir
197}
198
199# create_heat_cache_dir() - Part of the init_heat() process
Ian Wienandaee18c72014-02-21 15:35:08 +1100200function create_heat_cache_dir {
Steve Bakerc3249082013-04-09 13:41:47 +1200201 # Create cache dirs
Angus Salkelde1186552013-09-06 13:35:09 +1000202 sudo mkdir -p $HEAT_AUTH_CACHE_DIR
203 sudo chown $STACK_USER $HEAT_AUTH_CACHE_DIR
Steve Bakerbfdad752012-08-18 09:00:42 +1200204}
205
Steve Baker32761a42012-11-05 09:57:57 +1300206# install_heatclient() - Collect source and prepare
Ian Wienandaee18c72014-02-21 15:35:08 +1100207function install_heatclient {
Sean Daguee08ab102014-11-13 17:09:28 -0500208 if use_library_from_git "python-heatclient"; then
209 git_clone_by_name "python-heatclient"
210 setup_dev_lib "python-heatclient"
211 sudo install -D -m 0644 -o $STACK_USER {${GITDIR["python-heatclient"]}/tools/,/etc/bash_completion.d/}heat.bash_completion
Sean Dague5cb19062014-11-01 01:37:45 +0100212 fi
Steve Baker32761a42012-11-05 09:57:57 +1300213}
214
Steve Bakerbfdad752012-08-18 09:00:42 +1200215# install_heat() - Collect source and prepare
Ian Wienandaee18c72014-02-21 15:35:08 +1100216function install_heat {
Steve Bakerbfdad752012-08-18 09:00:42 +1200217 git_clone $HEAT_REPO $HEAT_DIR $HEAT_BRANCH
Sergey Krayneva38bc5b2014-12-16 04:25:11 -0500218 setup_develop $HEAT_DIR
Steve Bakerbfdad752012-08-18 09:00:42 +1200219}
220
Steve Baker315971d2014-05-27 12:24:18 +1200221# install_heat_other() - Collect source and prepare
222function install_heat_other {
223 git_clone $HEAT_CFNTOOLS_REPO $HEAT_CFNTOOLS_DIR $HEAT_CFNTOOLS_BRANCH
224 git_clone $HEAT_TEMPLATES_REPO $HEAT_TEMPLATES_REPO_DIR $HEAT_TEMPLATES_BRANCH
225}
226
Steve Bakerbfdad752012-08-18 09:00:42 +1200227# start_heat() - Start running processes, including screen
Ian Wienandaee18c72014-02-21 15:35:08 +1100228function start_heat {
Chris Dent2f27a0e2014-09-09 13:46:02 +0100229 run_process h-eng "$HEAT_DIR/bin/heat-engine --config-file=$HEAT_CONF"
230 run_process h-api "$HEAT_DIR/bin/heat-api --config-file=$HEAT_CONF"
231 run_process h-api-cfn "$HEAT_DIR/bin/heat-api-cfn --config-file=$HEAT_CONF"
232 run_process h-api-cw "$HEAT_DIR/bin/heat-api-cloudwatch --config-file=$HEAT_CONF"
Steve Bakerbfdad752012-08-18 09:00:42 +1200233}
234
Dean Troyer699a29f2012-09-10 14:10:27 -0500235# stop_heat() - Stop running processes
Ian Wienandaee18c72014-02-21 15:35:08 +1100236function stop_heat {
Kieran Spear70338292013-05-28 11:31:31 +1000237 # Kill the screen windows
Dean Troyer7d31bdc2014-07-25 12:50:05 -0500238 local serv
Kieran Spear70338292013-05-28 11:31:31 +1000239 for serv in h-eng h-api h-api-cfn h-api-cw; do
Chris Dent2f27a0e2014-09-09 13:46:02 +0100240 stop_process $serv
Dean Troyer699a29f2012-09-10 14:10:27 -0500241 done
Steve Bakerbfdad752012-08-18 09:00:42 +1200242}
Dean Troyer7903b792012-09-13 17:16:12 -0500243
Steven Hardy33d1f862014-02-13 15:00:33 +0000244# create_heat_accounts() - Set up common required heat accounts
Ian Wienandaee18c72014-02-21 15:35:08 +1100245function create_heat_accounts {
Jamie Lennox85ff5322015-01-28 14:28:01 +1000246 create_service_user "heat" "admin"
Bartosz Górski0abde392014-02-28 14:15:19 +0100247
Steven Hardy57d478d2014-02-28 16:37:43 +0000248 if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
Bartosz Górski0abde392014-02-28 14:15:19 +0100249
Dean Troyer7d31bdc2014-07-25 12:50:05 -0500250 local heat_service=$(get_or_create_service "heat" \
Bartosz Górski0abde392014-02-28 14:15:19 +0100251 "orchestration" "Heat Orchestration Service")
Dean Troyer7d31bdc2014-07-25 12:50:05 -0500252 get_or_create_endpoint $heat_service \
Bartosz Górski0abde392014-02-28 14:15:19 +0100253 "$REGION_NAME" \
254 "$SERVICE_PROTOCOL://$HEAT_API_HOST:$HEAT_API_PORT/v1/\$(tenant_id)s" \
255 "$SERVICE_PROTOCOL://$HEAT_API_HOST:$HEAT_API_PORT/v1/\$(tenant_id)s" \
256 "$SERVICE_PROTOCOL://$HEAT_API_HOST:$HEAT_API_PORT/v1/\$(tenant_id)s"
257
Dean Troyer7d31bdc2014-07-25 12:50:05 -0500258 local heat_cfn_service=$(get_or_create_service "heat-cfn" \
Bartosz Górski0abde392014-02-28 14:15:19 +0100259 "cloudformation" "Heat CloudFormation Service")
Dean Troyer7d31bdc2014-07-25 12:50:05 -0500260 get_or_create_endpoint $heat_cfn_service \
Bartosz Górski0abde392014-02-28 14:15:19 +0100261 "$REGION_NAME" \
262 "$SERVICE_PROTOCOL://$HEAT_API_CFN_HOST:$HEAT_API_CFN_PORT/v1" \
263 "$SERVICE_PROTOCOL://$HEAT_API_CFN_HOST:$HEAT_API_CFN_PORT/v1" \
264 "$SERVICE_PROTOCOL://$HEAT_API_CFN_HOST:$HEAT_API_CFN_PORT/v1"
Steven Hardy57d478d2014-02-28 16:37:43 +0000265 fi
266
267 # heat_stack_user role is for users created by Heat
Bartosz Górski0abde392014-02-28 14:15:19 +0100268 get_or_create_role "heat_stack_user"
Steven Hardy57d478d2014-02-28 16:37:43 +0000269
Steven Hardyf83cf932014-03-12 16:54:01 +0000270 if [[ $HEAT_DEFERRED_AUTH == trusts ]]; then
Steven Hardyf83cf932014-03-12 16:54:01 +0000271 iniset $HEAT_CONF DEFAULT deferred_auth_method trusts
272 fi
Steven Hardy2ca3bf12014-03-03 18:07:33 +0000273
Steve Baker16aca8a2014-03-11 14:01:57 +1300274 if [[ "$HEAT_STACK_DOMAIN" == "True" ]]; then
275 # Note we have to pass token/endpoint here because the current endpoint and
276 # version negotiation in OSC means just --os-identity-api-version=3 won't work
Steve Martinellib74e01c2014-12-18 01:35:35 -0500277 D_ID=$(openstack --os-token $OS_TOKEN --os-url=$KEYSTONE_SERVICE_URI_V3 \
Bartosz Górski0abde392014-02-28 14:15:19 +0100278 --os-identity-api-version=3 domain list | grep ' heat ' | get_field 1)
279
280 if [[ -z "$D_ID" ]]; then
Steve Martinellib74e01c2014-12-18 01:35:35 -0500281 D_ID=$(openstack --os-token $OS_TOKEN --os-url=$KEYSTONE_SERVICE_URI_V3 \
Bartosz Górski0abde392014-02-28 14:15:19 +0100282 --os-identity-api-version=3 domain create heat \
283 --description "Owns users and projects created by heat" \
284 | grep ' id ' | get_field 2)
Sirushti Murugesan2f92c8d2014-10-09 14:35:38 +0530285 iniset $HEAT_CONF DEFAULT stack_user_domain_id ${D_ID}
Bartosz Górski0abde392014-02-28 14:15:19 +0100286
Steve Martinellib74e01c2014-12-18 01:35:35 -0500287 openstack --os-token $OS_TOKEN --os-url=$KEYSTONE_SERVICE_URI_V3 \
Bartosz Górski0abde392014-02-28 14:15:19 +0100288 --os-identity-api-version=3 user create --password $SERVICE_PASSWORD \
289 --domain $D_ID heat_domain_admin \
290 --description "Manages users and projects created by heat"
Steve Martinellib74e01c2014-12-18 01:35:35 -0500291 openstack --os-token $OS_TOKEN --os-url=$KEYSTONE_SERVICE_URI_V3 \
Bartosz Górski0abde392014-02-28 14:15:19 +0100292 --os-identity-api-version=3 role add \
293 --user heat_domain_admin --domain ${D_ID} admin
294 iniset $HEAT_CONF DEFAULT stack_domain_admin heat_domain_admin
295 iniset $HEAT_CONF DEFAULT stack_domain_admin_password $SERVICE_PASSWORD
296 fi
Steve Baker16aca8a2014-03-11 14:01:57 +1300297 fi
Steven Hardy33d1f862014-02-13 15:00:33 +0000298}
299
Steve Baker249e36d2015-03-05 14:01:45 +1300300# build_heat_pip_mirror() - Build a pip mirror containing heat agent projects
301function build_heat_pip_mirror {
302 local project_dirs="$OCC_DIR $OAC_DIR $ORC_DIR $HEAT_CFNTOOLS_DIR"
303 local projpath proj package
Steve Baker2a6009c2014-05-05 16:13:39 +1200304
Steve Baker249e36d2015-03-05 14:01:45 +1300305 rm -rf $HEAT_PIP_REPO
306 mkdir -p $HEAT_PIP_REPO
Steve Baker2a6009c2014-05-05 16:13:39 +1200307
Steve Baker249e36d2015-03-05 14:01:45 +1300308 echo "<html><body>" > $HEAT_PIP_REPO/index.html
309 for projpath in $project_dirs; do
310 proj=$(basename $projpath)
311 mkdir -p $HEAT_PIP_REPO/$proj
312 pushd $projpath
313 rm -rf dist
314 python setup.py sdist
315 pushd dist
316 package=$(ls *)
317 mv $package $HEAT_PIP_REPO/$proj/$package
318 popd
319
320 echo "<html><body><a href=\"$package\">$package</a></body></html>" > $HEAT_PIP_REPO/$proj/index.html
321 echo "<a href=\"$proj\">$proj</a><br/>" >> $HEAT_PIP_REPO/index.html
322
323 popd
324 done
325
326 echo "</body></html>" >> $HEAT_PIP_REPO/index.html
327
328 local heat_pip_repo_apache_conf=$(apache_site_config_for heat_pip_repo)
329
330 sudo cp $FILES/apache-heat-pip-repo.template $heat_pip_repo_apache_conf
331 sudo sed -e "
332 s|%HEAT_PIP_REPO%|$HEAT_PIP_REPO|g;
333 s|%HEAT_PIP_REPO_PORT%|$HEAT_PIP_REPO_PORT|g;
334 s|%APACHE_NAME%|$APACHE_NAME|g;
335 " -i $heat_pip_repo_apache_conf
336 enable_apache_site heat_pip_repo
337 restart_apache_server
Steve Baker2a6009c2014-05-05 16:13:39 +1200338}
339
Dean Troyer7903b792012-09-13 17:16:12 -0500340# Restore xtrace
341$XTRACE
Sean Dague584d90e2013-03-29 14:34:53 -0400342
Adam Spiers6a5aa7c2013-10-24 11:27:02 +0100343# Tell emacs to use shell-script-mode
344## Local variables:
345## mode: shell-script
346## End: