Sean Dague | e263c82 | 2014-12-05 14:25:28 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
Mate Lakat | 45ea081 | 2013-09-25 10:00:29 +0100 | [diff] [blame] | 3 | # lib/heat |
Dean Troyer | 6d04fd7 | 2012-12-21 11:03:37 -0600 | [diff] [blame] | 4 | # Install and start **Heat** service |
| 5 | |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 6 | # To enable, add the following to localrc |
Adam Spiers | 6a5aa7c | 2013-10-24 11:27:02 +0100 | [diff] [blame] | 7 | # |
| 8 | # ENABLED_SERVICES+=,heat,h-api,h-api-cfn,h-api-cw,h-eng |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 9 | |
| 10 | # Dependencies: |
Steve Baker | 249e36d | 2015-03-05 14:01:45 +1300 | [diff] [blame] | 11 | # (none) |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 12 | |
| 13 | # stack.sh |
| 14 | # --------- |
Adam Spiers | 6a5aa7c | 2013-10-24 11:27:02 +0100 | [diff] [blame] | 15 | # - install_heatclient |
| 16 | # - install_heat |
| 17 | # - configure_heatclient |
| 18 | # - configure_heat |
Oleksii Chuprykov | a692810 | 2015-06-11 08:56:58 -0400 | [diff] [blame] | 19 | # - _config_heat_apache_wsgi |
Adam Spiers | 6a5aa7c | 2013-10-24 11:27:02 +0100 | [diff] [blame] | 20 | # - init_heat |
| 21 | # - start_heat |
| 22 | # - stop_heat |
| 23 | # - cleanup_heat |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 24 | |
Dean Troyer | 7903b79 | 2012-09-13 17:16:12 -0500 | [diff] [blame] | 25 | # Save trace setting |
Ian Wienand | 523f488 | 2015-10-13 11:03:03 +1100 | [diff] [blame] | 26 | _XTRACE_HEAT=$(set +o | grep xtrace) |
Dean Troyer | 7903b79 | 2012-09-13 17:16:12 -0500 | [diff] [blame] | 27 | set +o xtrace |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 28 | |
| 29 | |
| 30 | # Defaults |
| 31 | # -------- |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 32 | |
| 33 | # set up default directories |
Sean Dague | e08ab10 | 2014-11-13 17:09:28 -0500 | [diff] [blame] | 34 | GITDIR["python-heatclient"]=$DEST/python-heatclient |
Sean Dague | 5cb1906 | 2014-11-01 01:37:45 +0100 | [diff] [blame] | 35 | |
Oleksii Chuprykov | a692810 | 2015-06-11 08:56:58 -0400 | [diff] [blame] | 36 | # Toggle for deploying Heat-API under HTTPD + mod_wsgi |
| 37 | HEAT_USE_MOD_WSGI=${HEAT_USE_MOD_WSGI:-False} |
| 38 | |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 39 | HEAT_DIR=$DEST/heat |
Steve Baker | 315971d | 2014-05-27 12:24:18 +1200 | [diff] [blame] | 40 | HEAT_CFNTOOLS_DIR=$DEST/heat-cfntools |
| 41 | HEAT_TEMPLATES_REPO_DIR=$DEST/heat-templates |
Steve Baker | 249e36d | 2015-03-05 14:01:45 +1300 | [diff] [blame] | 42 | OCC_DIR=$DEST/os-collect-config |
| 43 | ORC_DIR=$DEST/os-refresh-config |
| 44 | OAC_DIR=$DEST/os-apply-config |
| 45 | |
| 46 | HEAT_PIP_REPO=$DATA_DIR/heat-pip-repo |
| 47 | HEAT_PIP_REPO_PORT=${HEAT_PIP_REPO_PORT:-8899} |
| 48 | |
Steve Baker | c324908 | 2013-04-09 13:41:47 +1200 | [diff] [blame] | 49 | HEAT_AUTH_CACHE_DIR=${HEAT_AUTH_CACHE_DIR:-/var/cache/heat} |
Sean Dague | 5375329 | 2014-12-04 19:38:15 -0500 | [diff] [blame] | 50 | HEAT_STANDALONE=$(trueorfalse False HEAT_STANDALONE) |
| 51 | HEAT_ENABLE_ADOPT_ABANDON=$(trueorfalse False HEAT_ENABLE_ADOPT_ABANDON) |
Angus Salkeld | f645a85 | 2013-08-26 10:13:36 +1000 | [diff] [blame] | 52 | HEAT_CONF_DIR=/etc/heat |
Angus Salkeld | a213e2c | 2013-08-30 10:48:46 +1000 | [diff] [blame] | 53 | HEAT_CONF=$HEAT_CONF_DIR/heat.conf |
Angus Salkeld | f645a85 | 2013-08-26 10:13:36 +1000 | [diff] [blame] | 54 | HEAT_ENV_DIR=$HEAT_CONF_DIR/environment.d |
Angus Salkeld | fb71a27 | 2013-08-26 10:15:38 +1000 | [diff] [blame] | 55 | HEAT_TEMPLATES_DIR=$HEAT_CONF_DIR/templates |
Steve Baker | e389aed | 2014-09-23 17:10:39 +1200 | [diff] [blame] | 56 | HEAT_API_HOST=${HEAT_API_HOST:-$HOST_IP} |
| 57 | HEAT_API_PORT=${HEAT_API_PORT:-8004} |
Steven Hardy | 2a68844 | 2015-12-08 13:26:29 +0000 | [diff] [blame] | 58 | HEAT_SERVICE_USER=${HEAT_SERVICE_USER:-heat} |
| 59 | HEAT_TRUSTEE_USER=${HEAT_TRUSTEE_USER:-$HEAT_SERVICE_USER} |
| 60 | HEAT_TRUSTEE_PASSWORD=${HEAT_TRUSTEE_PASSWORD:-$SERVICE_PASSWORD} |
| 61 | HEAT_TRUSTEE_DOMAIN=${HEAT_TRUSTEE_DOMAIN:-default} |
Steven Hardy | 3163c17 | 2015-01-23 13:26:29 +0000 | [diff] [blame] | 62 | |
Sirushti Murugesan | 9e68af7 | 2015-06-16 23:25:17 +0530 | [diff] [blame] | 63 | # Support entry points installation of console scripts |
| 64 | HEAT_BIN_DIR=$(get_python_exec_prefix) |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 65 | |
Steven Hardy | f83cf93 | 2014-03-12 16:54:01 +0000 | [diff] [blame] | 66 | # other default options |
Steve Baker | 744c2af | 2014-12-16 12:00:40 +1300 | [diff] [blame] | 67 | if [[ "$HEAT_STANDALONE" = "True" ]]; then |
| 68 | # for standalone, use defaults which require no service user |
Ian Wienand | e82bac0 | 2015-08-25 14:29:08 +1000 | [diff] [blame] | 69 | HEAT_STACK_DOMAIN=$(trueorfalse False HEAT_STACK_DOMAIN) |
Steve Baker | 744c2af | 2014-12-16 12:00:40 +1300 | [diff] [blame] | 70 | HEAT_DEFERRED_AUTH=${HEAT_DEFERRED_AUTH:-password} |
Joe D'Andrea | 779d867 | 2015-11-30 15:35:13 +0000 | [diff] [blame] | 71 | if [[ ${HEAT_DEFERRED_AUTH} != "password" ]]; then |
| 72 | # Heat does not support keystone trusts when deployed in |
| 73 | # standalone mode |
| 74 | die $LINENO \ |
| 75 | 'HEAT_DEFERRED_AUTH can only be set to "password" when HEAT_STANDALONE is True.' |
| 76 | fi |
Steve Baker | 744c2af | 2014-12-16 12:00:40 +1300 | [diff] [blame] | 77 | else |
Ian Wienand | e82bac0 | 2015-08-25 14:29:08 +1000 | [diff] [blame] | 78 | HEAT_STACK_DOMAIN=$(trueorfalse True HEAT_STACK_DOMAIN) |
Steven Hardy | 2a68844 | 2015-12-08 13:26:29 +0000 | [diff] [blame] | 79 | HEAT_DEFERRED_AUTH=${HEAT_DEFERRED_AUTH:-} |
Steve Baker | 744c2af | 2014-12-16 12:00:40 +1300 | [diff] [blame] | 80 | fi |
Nicolas Simonds | 347dbac | 2015-01-21 13:40:42 -0800 | [diff] [blame] | 81 | HEAT_PLUGIN_DIR=${HEAT_PLUGIN_DIR:-$DATA_DIR/heat/plugins} |
| 82 | ENABLE_HEAT_PLUGINS=${ENABLE_HEAT_PLUGINS:-} |
Steven Hardy | f83cf93 | 2014-03-12 16:54:01 +0000 | [diff] [blame] | 83 | |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 84 | # Functions |
| 85 | # --------- |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 86 | |
Sean Dague | 29870cc | 2014-03-14 14:32:01 -0400 | [diff] [blame] | 87 | # Test if any Heat services are enabled |
| 88 | # is_heat_enabled |
| 89 | function is_heat_enabled { |
| 90 | [[ ,${ENABLED_SERVICES} =~ ,"h-" ]] && return 0 |
| 91 | return 1 |
| 92 | } |
| 93 | |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 94 | # cleanup_heat() - Remove residual data files, anything left over from previous |
| 95 | # runs that a clean run would need to clean up |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 96 | function cleanup_heat { |
Steve Baker | c324908 | 2013-04-09 13:41:47 +1200 | [diff] [blame] | 97 | sudo rm -rf $HEAT_AUTH_CACHE_DIR |
Angus Salkeld | f645a85 | 2013-08-26 10:13:36 +1000 | [diff] [blame] | 98 | sudo rm -rf $HEAT_ENV_DIR |
Angus Salkeld | fb71a27 | 2013-08-26 10:15:38 +1000 | [diff] [blame] | 99 | sudo rm -rf $HEAT_TEMPLATES_DIR |
Steve Baker | 744c2af | 2014-12-16 12:00:40 +1300 | [diff] [blame] | 100 | sudo rm -rf $HEAT_CONF_DIR |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | # configure_heat() - Set config files, create data dirs, etc |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 104 | function configure_heat { |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 105 | |
Dean Troyer | 8421c2b | 2015-03-16 13:52:19 -0500 | [diff] [blame] | 106 | sudo install -d -o $STACK_USER $HEAT_CONF_DIR |
Angus Salkeld | a213e2c | 2013-08-30 10:48:46 +1000 | [diff] [blame] | 107 | # remove old config files |
| 108 | rm -f $HEAT_CONF_DIR/heat-*.conf |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 109 | |
Steve Baker | e61bc61 | 2014-01-27 15:21:29 +1300 | [diff] [blame] | 110 | HEAT_API_CFN_HOST=${HEAT_API_CFN_HOST:-$HOST_IP} |
Angus Salkeld | e279021 | 2012-09-11 11:24:09 +1000 | [diff] [blame] | 111 | HEAT_API_CFN_PORT=${HEAT_API_CFN_PORT:-8000} |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 112 | HEAT_ENGINE_HOST=${HEAT_ENGINE_HOST:-$SERVICE_HOST} |
| 113 | HEAT_ENGINE_PORT=${HEAT_ENGINE_PORT:-8001} |
Steve Baker | e61bc61 | 2014-01-27 15:21:29 +1300 | [diff] [blame] | 114 | HEAT_API_CW_HOST=${HEAT_API_CW_HOST:-$HOST_IP} |
Angus Salkeld | e279021 | 2012-09-11 11:24:09 +1000 | [diff] [blame] | 115 | HEAT_API_CW_PORT=${HEAT_API_CW_PORT:-8003} |
Steve Baker | d5cd79b | 2013-04-13 11:14:41 -0700 | [diff] [blame] | 116 | HEAT_API_PASTE_FILE=$HEAT_CONF_DIR/api-paste.ini |
| 117 | HEAT_POLICY_FILE=$HEAT_CONF_DIR/policy.json |
| 118 | |
| 119 | cp $HEAT_DIR/etc/heat/api-paste.ini $HEAT_API_PASTE_FILE |
| 120 | cp $HEAT_DIR/etc/heat/policy.json $HEAT_POLICY_FILE |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 121 | |
Angus Salkeld | a213e2c | 2013-08-30 10:48:46 +1000 | [diff] [blame] | 122 | # common options |
Brant Knudson | 2dd110c | 2015-03-14 12:39:14 -0500 | [diff] [blame] | 123 | iniset_rpc_backend heat $HEAT_CONF |
Angus Salkeld | a213e2c | 2013-08-30 10:48:46 +1000 | [diff] [blame] | 124 | iniset $HEAT_CONF DEFAULT heat_metadata_server_url http://$HEAT_API_CFN_HOST:$HEAT_API_CFN_PORT |
| 125 | iniset $HEAT_CONF DEFAULT heat_waitcondition_server_url http://$HEAT_API_CFN_HOST:$HEAT_API_CFN_PORT/v1/waitcondition |
| 126 | iniset $HEAT_CONF DEFAULT heat_watch_server_url http://$HEAT_API_CW_HOST:$HEAT_API_CW_PORT |
Angus Salkeld | e231438 | 2013-11-14 14:36:46 +1100 | [diff] [blame] | 127 | iniset $HEAT_CONF database connection `database_connection_url heat` |
Attila Fazekas | f71b500 | 2014-05-28 09:52:22 +0200 | [diff] [blame] | 128 | iniset $HEAT_CONF DEFAULT auth_encryption_key $(generate_hex_string 16) |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 129 | |
Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 130 | iniset $HEAT_CONF DEFAULT region_name_for_services "$REGION_NAME" |
| 131 | |
Angus Salkeld | a213e2c | 2013-08-30 10:48:46 +1000 | [diff] [blame] | 132 | # logging |
| 133 | iniset $HEAT_CONF DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL |
| 134 | iniset $HEAT_CONF DEFAULT use_syslog $SYSLOG |
Oleksii Chuprykov | a692810 | 2015-06-11 08:56:58 -0400 | [diff] [blame] | 135 | if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ] && [ "$HEAT_USE_MOD_WSGI" == "False" ] ; then |
Steve Baker | 556ffe4 | 2013-08-06 16:42:38 +1200 | [diff] [blame] | 136 | # Add color to logging output |
Arata Notsu | 4897ff5 | 2013-10-09 18:49:32 +0900 | [diff] [blame] | 137 | setup_colorized_logging $HEAT_CONF DEFAULT tenant user |
Steve Baker | 556ffe4 | 2013-08-06 16:42:38 +1200 | [diff] [blame] | 138 | fi |
| 139 | |
Steven Hardy | 2a68844 | 2015-12-08 13:26:29 +0000 | [diff] [blame] | 140 | if [ ! -z "$HEAT_DEFERRED_AUTH" ]; then |
| 141 | iniset $HEAT_CONF DEFAULT deferred_auth_method $HEAT_DEFERRED_AUTH |
| 142 | fi |
Angus Salkeld | 93b906d | 2015-03-26 12:53:51 +1000 | [diff] [blame] | 143 | |
Oleksii Chuprykov | a692810 | 2015-06-11 08:56:58 -0400 | [diff] [blame] | 144 | if [ "$HEAT_USE_MOD_WSGI" == "True" ]; then |
| 145 | _config_heat_apache_wsgi |
| 146 | fi |
| 147 | |
Steve Baker | 744c2af | 2014-12-16 12:00:40 +1300 | [diff] [blame] | 148 | if [[ "$HEAT_STANDALONE" = "True" ]]; then |
| 149 | iniset $HEAT_CONF paste_deploy flavor standalone |
| 150 | iniset $HEAT_CONF clients_heat url "http://$HEAT_API_HOST:$HEAT_API_PORT/v1/%(tenant_id)s" |
| 151 | else |
liyingjun | 44ee7e3 | 2015-12-25 10:32:14 +0800 | [diff] [blame] | 152 | configure_auth_token_middleware $HEAT_CONF heat $HEAT_AUTH_CACHE_DIR |
Steve Baker | 744c2af | 2014-12-16 12:00:40 +1300 | [diff] [blame] | 153 | fi |
Angus Salkeld | e279021 | 2012-09-11 11:24:09 +1000 | [diff] [blame] | 154 | |
Steven Hardy | 2a68844 | 2015-12-08 13:26:29 +0000 | [diff] [blame] | 155 | # If HEAT_DEFERRED_AUTH is unset or explicitly set to trusts, configure |
| 156 | # the section for the client plugin associated with the trustee |
| 157 | if [ -z "$HEAT_DEFERRED_AUTH" -o "trusts" == "$HEAT_DEFERRED_AUTH" ]; then |
ricolin | 9a0d1f9 | 2016-06-15 01:13:45 +0800 | [diff] [blame] | 158 | iniset $HEAT_CONF trustee auth_type password |
Steven Hardy | 2a68844 | 2015-12-08 13:26:29 +0000 | [diff] [blame] | 159 | iniset $HEAT_CONF trustee auth_url $KEYSTONE_AUTH_URI |
| 160 | iniset $HEAT_CONF trustee username $HEAT_TRUSTEE_USER |
| 161 | iniset $HEAT_CONF trustee password $HEAT_TRUSTEE_PASSWORD |
| 162 | iniset $HEAT_CONF trustee user_domain_id $HEAT_TRUSTEE_DOMAIN |
| 163 | fi |
| 164 | |
| 165 | # clients_keystone |
| 166 | iniset $HEAT_CONF clients_keystone auth_uri $KEYSTONE_AUTH_URI |
| 167 | |
Angus Salkeld | a213e2c | 2013-08-30 10:48:46 +1000 | [diff] [blame] | 168 | # OpenStack API |
Angus Salkeld | a213e2c | 2013-08-30 10:48:46 +1000 | [diff] [blame] | 169 | iniset $HEAT_CONF heat_api bind_port $HEAT_API_PORT |
Davanum Srinivas | 905275e | 2015-01-24 19:21:34 -0500 | [diff] [blame] | 170 | iniset $HEAT_CONF heat_api workers "$API_WORKERS" |
Angus Salkeld | a213e2c | 2013-08-30 10:48:46 +1000 | [diff] [blame] | 171 | |
| 172 | # Cloudformation API |
Angus Salkeld | a213e2c | 2013-08-30 10:48:46 +1000 | [diff] [blame] | 173 | iniset $HEAT_CONF heat_api_cfn bind_port $HEAT_API_CFN_PORT |
| 174 | |
| 175 | # Cloudwatch API |
Angus Salkeld | a213e2c | 2013-08-30 10:48:46 +1000 | [diff] [blame] | 176 | iniset $HEAT_CONF heat_api_cloudwatch bind_port $HEAT_API_CW_PORT |
Angus Salkeld | e279021 | 2012-09-11 11:24:09 +1000 | [diff] [blame] | 177 | |
Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 178 | if is_ssl_enabled_service "key" || is_service_enabled tls-proxy; then |
| 179 | iniset $HEAT_CONF clients_keystone ca_file $SSL_BUNDLE_FILE |
| 180 | fi |
| 181 | |
| 182 | if is_ssl_enabled_service "nova" || is_service_enabled tls-proxy; then |
| 183 | iniset $HEAT_CONF clients_nova ca_file $SSL_BUNDLE_FILE |
| 184 | fi |
| 185 | |
| 186 | if is_ssl_enabled_service "cinder" || is_service_enabled tls-proxy; then |
| 187 | iniset $HEAT_CONF clients_cinder ca_file $SSL_BUNDLE_FILE |
| 188 | fi |
| 189 | |
Angus Salkeld | 826e450 | 2015-01-07 17:52:05 +1000 | [diff] [blame] | 190 | if [[ "$HEAT_ENABLE_ADOPT_ABANDON" = "True" ]]; then |
| 191 | iniset $HEAT_CONF DEFAULT enable_stack_adopt true |
| 192 | iniset $HEAT_CONF DEFAULT enable_stack_abandon true |
| 193 | fi |
| 194 | |
Thomas Herve | 728730a | 2016-02-12 08:31:23 +0100 | [diff] [blame] | 195 | iniset $HEAT_CONF cache enabled "True" |
| 196 | iniset $HEAT_CONF cache backend "dogpile.cache.memory" |
| 197 | |
Dean Troyer | 8421c2b | 2015-03-16 13:52:19 -0500 | [diff] [blame] | 198 | sudo install -d -o $STACK_USER $HEAT_ENV_DIR $HEAT_TEMPLATES_DIR |
| 199 | |
Angus Salkeld | f645a85 | 2013-08-26 10:13:36 +1000 | [diff] [blame] | 200 | # copy the default environment |
| 201 | cp $HEAT_DIR/etc/heat/environment.d/* $HEAT_ENV_DIR/ |
| 202 | |
Angus Salkeld | fb71a27 | 2013-08-26 10:15:38 +1000 | [diff] [blame] | 203 | # copy the default templates |
| 204 | cp $HEAT_DIR/etc/heat/templates/* $HEAT_TEMPLATES_DIR/ |
| 205 | |
Nicolas Simonds | 347dbac | 2015-01-21 13:40:42 -0800 | [diff] [blame] | 206 | # Enable heat plugins. |
| 207 | # NOTE(nic): The symlink nonsense is necessary because when |
| 208 | # plugins are installed in "developer mode", the final component |
| 209 | # of their target directory is always "resources", which confuses |
| 210 | # Heat's plugin loader into believing that all plugins are named |
| 211 | # "resources", and therefore are all the same plugin; so it |
| 212 | # will only load one of them. Linking them all to a common |
| 213 | # location with unique names avoids that type of collision, |
| 214 | # while still allowing the plugins to be edited in-tree. |
| 215 | local err_count=0 |
| 216 | |
| 217 | if [ -n "$ENABLE_HEAT_PLUGINS" ]; then |
| 218 | mkdir -p $HEAT_PLUGIN_DIR |
| 219 | # Clean up cruft from any previous runs |
| 220 | rm -f $HEAT_PLUGIN_DIR/* |
| 221 | iniset $HEAT_CONF DEFAULT plugin_dirs $HEAT_PLUGIN_DIR |
| 222 | fi |
| 223 | |
| 224 | for heat_plugin in $ENABLE_HEAT_PLUGINS; do |
| 225 | if [ -d $HEAT_DIR/contrib/$heat_plugin ]; then |
| 226 | setup_package $HEAT_DIR/contrib/$heat_plugin -e |
| 227 | ln -s $HEAT_DIR/contrib/$heat_plugin/$heat_plugin/resources $HEAT_PLUGIN_DIR/$heat_plugin |
| 228 | else |
| 229 | : # clear retval on the test so that we can roll up errors |
| 230 | err $LINENO "Requested Heat plugin(${heat_plugin}) not found." |
| 231 | err_count=$(($err_count + 1)) |
| 232 | fi |
| 233 | done |
| 234 | [ $err_count -eq 0 ] || die $LINENO "$err_count of the requested Heat plugins could not be installed." |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 235 | } |
| 236 | |
| 237 | # init_heat() - Initialize database |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 238 | function init_heat { |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 239 | |
| 240 | # (re)create heat database |
Ihar Hrachyshka | 157c84b | 2014-10-06 13:29:39 +0200 | [diff] [blame] | 241 | recreate_database heat |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 242 | |
Einst Crazy | 4f55c2d | 2016-05-04 08:14:01 +0000 | [diff] [blame] | 243 | $HEAT_BIN_DIR/heat-manage --config-file $HEAT_CONF db_sync |
Steve Baker | c324908 | 2013-04-09 13:41:47 +1200 | [diff] [blame] | 244 | create_heat_cache_dir |
| 245 | } |
| 246 | |
| 247 | # create_heat_cache_dir() - Part of the init_heat() process |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 248 | function create_heat_cache_dir { |
Steve Baker | c324908 | 2013-04-09 13:41:47 +1200 | [diff] [blame] | 249 | # Create cache dirs |
Dean Troyer | 8421c2b | 2015-03-16 13:52:19 -0500 | [diff] [blame] | 250 | sudo install -d -o $STACK_USER $HEAT_AUTH_CACHE_DIR |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 251 | } |
| 252 | |
Steve Baker | 32761a4 | 2012-11-05 09:57:57 +1300 | [diff] [blame] | 253 | # install_heatclient() - Collect source and prepare |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 254 | function install_heatclient { |
Sean Dague | e08ab10 | 2014-11-13 17:09:28 -0500 | [diff] [blame] | 255 | if use_library_from_git "python-heatclient"; then |
| 256 | git_clone_by_name "python-heatclient" |
| 257 | setup_dev_lib "python-heatclient" |
| 258 | sudo install -D -m 0644 -o $STACK_USER {${GITDIR["python-heatclient"]}/tools/,/etc/bash_completion.d/}heat.bash_completion |
Sean Dague | 5cb1906 | 2014-11-01 01:37:45 +0100 | [diff] [blame] | 259 | fi |
Steve Baker | 32761a4 | 2012-11-05 09:57:57 +1300 | [diff] [blame] | 260 | } |
| 261 | |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 262 | # install_heat() - Collect source and prepare |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 263 | function install_heat { |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 264 | git_clone $HEAT_REPO $HEAT_DIR $HEAT_BRANCH |
Sergey Kraynev | a38bc5b | 2014-12-16 04:25:11 -0500 | [diff] [blame] | 265 | setup_develop $HEAT_DIR |
Oleksii Chuprykov | a692810 | 2015-06-11 08:56:58 -0400 | [diff] [blame] | 266 | if [ "$HEAT_USE_MOD_WSGI" == "True" ]; then |
| 267 | install_apache_wsgi |
| 268 | fi |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 269 | } |
| 270 | |
Steve Baker | 315971d | 2014-05-27 12:24:18 +1200 | [diff] [blame] | 271 | # install_heat_other() - Collect source and prepare |
| 272 | function install_heat_other { |
| 273 | git_clone $HEAT_CFNTOOLS_REPO $HEAT_CFNTOOLS_DIR $HEAT_CFNTOOLS_BRANCH |
| 274 | git_clone $HEAT_TEMPLATES_REPO $HEAT_TEMPLATES_REPO_DIR $HEAT_TEMPLATES_BRANCH |
Steve Baker | 1681995 | 2015-03-18 13:45:40 +1300 | [diff] [blame] | 275 | git_clone $OAC_REPO $OAC_DIR $OAC_BRANCH |
| 276 | git_clone $OCC_REPO $OCC_DIR $OCC_BRANCH |
| 277 | git_clone $ORC_REPO $ORC_DIR $ORC_BRANCH |
Steve Baker | 315971d | 2014-05-27 12:24:18 +1200 | [diff] [blame] | 278 | } |
| 279 | |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 280 | # start_heat() - Start running processes, including screen |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 281 | function start_heat { |
Sirushti Murugesan | 9e68af7 | 2015-06-16 23:25:17 +0530 | [diff] [blame] | 282 | run_process h-eng "$HEAT_BIN_DIR/heat-engine --config-file=$HEAT_CONF" |
Oleksii Chuprykov | a692810 | 2015-06-11 08:56:58 -0400 | [diff] [blame] | 283 | |
| 284 | # If the site is not enabled then we are in a grenade scenario |
Ian Wienand | 5cdee8d | 2015-10-19 14:17:18 +1100 | [diff] [blame] | 285 | local enabled_site_file |
| 286 | enabled_site_file=$(apache_site_config_for heat-api) |
Oleksii Chuprykov | a692810 | 2015-06-11 08:56:58 -0400 | [diff] [blame] | 287 | if [ -f ${enabled_site_file} ] && [ "$HEAT_USE_MOD_WSGI" == "True" ]; then |
| 288 | enable_apache_site heat-api |
| 289 | enable_apache_site heat-api-cfn |
| 290 | enable_apache_site heat-api-cloudwatch |
| 291 | restart_apache_server |
| 292 | tail_log heat-api /var/log/$APACHE_NAME/heat-api.log |
| 293 | tail_log heat-api-cfn /var/log/$APACHE_NAME/heat-api-cfn.log |
| 294 | tail_log heat-api-cloudwatch /var/log/$APACHE_NAME/heat-api-cloudwatch.log |
| 295 | else |
| 296 | run_process h-api "$HEAT_BIN_DIR/heat-api --config-file=$HEAT_CONF" |
| 297 | run_process h-api-cfn "$HEAT_BIN_DIR/heat-api-cfn --config-file=$HEAT_CONF" |
| 298 | run_process h-api-cw "$HEAT_BIN_DIR/heat-api-cloudwatch --config-file=$HEAT_CONF" |
| 299 | fi |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 300 | } |
| 301 | |
Dean Troyer | 699a29f | 2012-09-10 14:10:27 -0500 | [diff] [blame] | 302 | # stop_heat() - Stop running processes |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 303 | function stop_heat { |
Kieran Spear | 7033829 | 2013-05-28 11:31:31 +1000 | [diff] [blame] | 304 | # Kill the screen windows |
Oleksii Chuprykov | a692810 | 2015-06-11 08:56:58 -0400 | [diff] [blame] | 305 | stop_process h-eng |
| 306 | |
| 307 | if [ "$HEAT_USE_MOD_WSGI" == "True" ]; then |
| 308 | disable_apache_site heat-api |
| 309 | disable_apache_site heat-api-cfn |
| 310 | disable_apache_site heat-api-cloudwatch |
| 311 | restart_apache_server |
| 312 | else |
| 313 | local serv |
| 314 | for serv in h-api h-api-cfn h-api-cw; do |
| 315 | stop_process $serv |
| 316 | done |
| 317 | fi |
| 318 | |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 319 | } |
Dean Troyer | 7903b79 | 2012-09-13 17:16:12 -0500 | [diff] [blame] | 320 | |
Oleksii Chuprykov | a692810 | 2015-06-11 08:56:58 -0400 | [diff] [blame] | 321 | # _cleanup_heat_apache_wsgi() - Remove wsgi files, disable and remove apache vhost file |
| 322 | function _cleanup_heat_apache_wsgi { |
| 323 | sudo rm -f $(apache_site_config_for heat-api) |
| 324 | sudo rm -f $(apache_site_config_for heat-api-cfn) |
| 325 | sudo rm -f $(apache_site_config_for heat-api-cloudwatch) |
| 326 | } |
| 327 | |
| 328 | # _config_heat_apache_wsgi() - Set WSGI config files of Heat |
| 329 | function _config_heat_apache_wsgi { |
| 330 | |
Ian Wienand | 5cdee8d | 2015-10-19 14:17:18 +1100 | [diff] [blame] | 331 | local heat_apache_conf |
| 332 | heat_apache_conf=$(apache_site_config_for heat-api) |
| 333 | local heat_cfn_apache_conf |
| 334 | heat_cfn_apache_conf=$(apache_site_config_for heat-api-cfn) |
| 335 | local heat_cloudwatch_apache_conf |
| 336 | heat_cloudwatch_apache_conf=$(apache_site_config_for heat-api-cloudwatch) |
Oleksii Chuprykov | a692810 | 2015-06-11 08:56:58 -0400 | [diff] [blame] | 337 | local heat_ssl="" |
| 338 | local heat_certfile="" |
| 339 | local heat_keyfile="" |
| 340 | local heat_api_port=$HEAT_API_PORT |
| 341 | local heat_cfn_api_port=$HEAT_API_CFN_PORT |
| 342 | local heat_cw_api_port=$HEAT_API_CW_PORT |
| 343 | local venv_path="" |
| 344 | |
| 345 | sudo cp $FILES/apache-heat-api.template $heat_apache_conf |
| 346 | sudo sed -e " |
| 347 | s|%PUBLICPORT%|$heat_api_port|g; |
| 348 | s|%APACHE_NAME%|$APACHE_NAME|g; |
| 349 | s|%HEAT_BIN_DIR%|$HEAT_BIN_DIR|g; |
| 350 | s|%SSLENGINE%|$heat_ssl|g; |
| 351 | s|%SSLCERTFILE%|$heat_certfile|g; |
| 352 | s|%SSLKEYFILE%|$heat_keyfile|g; |
| 353 | s|%USER%|$STACK_USER|g; |
| 354 | s|%VIRTUALENV%|$venv_path|g |
| 355 | " -i $heat_apache_conf |
| 356 | |
| 357 | sudo cp $FILES/apache-heat-api-cfn.template $heat_cfn_apache_conf |
| 358 | sudo sed -e " |
| 359 | s|%PUBLICPORT%|$heat_cfn_api_port|g; |
| 360 | s|%APACHE_NAME%|$APACHE_NAME|g; |
| 361 | s|%HEAT_BIN_DIR%|$HEAT_BIN_DIR|g; |
| 362 | s|%SSLENGINE%|$heat_ssl|g; |
| 363 | s|%SSLCERTFILE%|$heat_certfile|g; |
| 364 | s|%SSLKEYFILE%|$heat_keyfile|g; |
| 365 | s|%USER%|$STACK_USER|g; |
| 366 | s|%VIRTUALENV%|$venv_path|g |
| 367 | " -i $heat_cfn_apache_conf |
| 368 | |
| 369 | sudo cp $FILES/apache-heat-api-cloudwatch.template $heat_cloudwatch_apache_conf |
| 370 | sudo sed -e " |
| 371 | s|%PUBLICPORT%|$heat_cw_api_port|g; |
| 372 | s|%APACHE_NAME%|$APACHE_NAME|g; |
| 373 | s|%HEAT_BIN_DIR%|$HEAT_BIN_DIR|g; |
| 374 | s|%SSLENGINE%|$heat_ssl|g; |
| 375 | s|%SSLCERTFILE%|$heat_certfile|g; |
| 376 | s|%SSLKEYFILE%|$heat_keyfile|g; |
| 377 | s|%USER%|$STACK_USER|g; |
| 378 | s|%VIRTUALENV%|$venv_path|g |
| 379 | " -i $heat_cloudwatch_apache_conf |
| 380 | } |
| 381 | |
| 382 | |
Steven Hardy | 33d1f86 | 2014-02-13 15:00:33 +0000 | [diff] [blame] | 383 | # create_heat_accounts() - Set up common required heat accounts |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 384 | function create_heat_accounts { |
Steve Baker | 744c2af | 2014-12-16 12:00:40 +1300 | [diff] [blame] | 385 | if [[ "$HEAT_STANDALONE" != "True" ]]; then |
Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 386 | |
Steve Baker | 744c2af | 2014-12-16 12:00:40 +1300 | [diff] [blame] | 387 | create_service_user "heat" "admin" |
Sean Dague | 985e958 | 2016-02-10 07:25:24 -0500 | [diff] [blame] | 388 | get_or_create_service "heat" "orchestration" "Heat Orchestration Service" |
Matt Riedemann | ae4578b | 2016-04-23 01:45:40 +0000 | [diff] [blame] | 389 | get_or_create_endpoint \ |
Sean Dague | 985e958 | 2016-02-10 07:25:24 -0500 | [diff] [blame] | 390 | "orchestration" \ |
| 391 | "$REGION_NAME" \ |
Sean Dague | cbdc5d9 | 2016-04-04 09:10:44 -0400 | [diff] [blame] | 392 | "$SERVICE_PROTOCOL://$HEAT_API_HOST:$HEAT_API_PORT/v1/\$(project_id)s" \ |
| 393 | "$SERVICE_PROTOCOL://$HEAT_API_HOST:$HEAT_API_PORT/v1/\$(project_id)s" \ |
| 394 | "$SERVICE_PROTOCOL://$HEAT_API_HOST:$HEAT_API_PORT/v1/\$(project_id)s" |
Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 395 | |
Sean Dague | 985e958 | 2016-02-10 07:25:24 -0500 | [diff] [blame] | 396 | get_or_create_service "heat-cfn" "cloudformation" "Heat CloudFormation Service" |
Matt Riedemann | ae4578b | 2016-04-23 01:45:40 +0000 | [diff] [blame] | 397 | get_or_create_endpoint \ |
Sean Dague | 985e958 | 2016-02-10 07:25:24 -0500 | [diff] [blame] | 398 | "cloudformation" \ |
| 399 | "$REGION_NAME" \ |
| 400 | "$SERVICE_PROTOCOL://$HEAT_API_CFN_HOST:$HEAT_API_CFN_PORT/v1" \ |
| 401 | "$SERVICE_PROTOCOL://$HEAT_API_CFN_HOST:$HEAT_API_CFN_PORT/v1" \ |
| 402 | "$SERVICE_PROTOCOL://$HEAT_API_CFN_HOST:$HEAT_API_CFN_PORT/v1" |
Steve Baker | 744c2af | 2014-12-16 12:00:40 +1300 | [diff] [blame] | 403 | |
| 404 | # heat_stack_user role is for users created by Heat |
| 405 | get_or_create_role "heat_stack_user" |
Steven Hardy | 57d478d | 2014-02-28 16:37:43 +0000 | [diff] [blame] | 406 | fi |
| 407 | |
Steve Baker | 16aca8a | 2014-03-11 14:01:57 +1300 | [diff] [blame] | 408 | if [[ "$HEAT_STACK_DOMAIN" == "True" ]]; then |
Steve Martinelli | 4ce859a | 2015-12-20 01:27:30 -0500 | [diff] [blame] | 409 | # domain -> heat and user -> heat_domain_admin |
| 410 | domain_id=$(get_or_create_domain heat 'Owns users and projects created by heat') |
| 411 | iniset $HEAT_CONF DEFAULT stack_user_domain_id ${domain_id} |
| 412 | get_or_create_user heat_domain_admin $SERVICE_PASSWORD heat |
| 413 | get_or_add_user_domain_role admin heat_domain_admin heat |
| 414 | iniset $HEAT_CONF DEFAULT stack_domain_admin heat_domain_admin |
| 415 | iniset $HEAT_CONF DEFAULT stack_domain_admin_password $SERVICE_PASSWORD |
Steve Baker | 16aca8a | 2014-03-11 14:01:57 +1300 | [diff] [blame] | 416 | fi |
Steven Hardy | 33d1f86 | 2014-02-13 15:00:33 +0000 | [diff] [blame] | 417 | } |
| 418 | |
Steve Baker | 249e36d | 2015-03-05 14:01:45 +1300 | [diff] [blame] | 419 | # build_heat_pip_mirror() - Build a pip mirror containing heat agent projects |
| 420 | function build_heat_pip_mirror { |
Monty Taylor | 201c01f | 2016-10-18 07:24:00 -0500 | [diff] [blame] | 421 | local project_dirs="$OCC_DIR $OAC_DIR $ORC_DIR $HEAT_CFNTOOLS_DIR" |
Steve Baker | 249e36d | 2015-03-05 14:01:45 +1300 | [diff] [blame] | 422 | local projpath proj package |
Steve Baker | 2a6009c | 2014-05-05 16:13:39 +1200 | [diff] [blame] | 423 | |
Steve Baker | 249e36d | 2015-03-05 14:01:45 +1300 | [diff] [blame] | 424 | rm -rf $HEAT_PIP_REPO |
| 425 | mkdir -p $HEAT_PIP_REPO |
Steve Baker | 2a6009c | 2014-05-05 16:13:39 +1200 | [diff] [blame] | 426 | |
Steve Baker | 249e36d | 2015-03-05 14:01:45 +1300 | [diff] [blame] | 427 | echo "<html><body>" > $HEAT_PIP_REPO/index.html |
| 428 | for projpath in $project_dirs; do |
| 429 | proj=$(basename $projpath) |
| 430 | mkdir -p $HEAT_PIP_REPO/$proj |
| 431 | pushd $projpath |
| 432 | rm -rf dist |
| 433 | python setup.py sdist |
| 434 | pushd dist |
| 435 | package=$(ls *) |
| 436 | mv $package $HEAT_PIP_REPO/$proj/$package |
| 437 | popd |
| 438 | |
| 439 | echo "<html><body><a href=\"$package\">$package</a></body></html>" > $HEAT_PIP_REPO/$proj/index.html |
| 440 | echo "<a href=\"$proj\">$proj</a><br/>" >> $HEAT_PIP_REPO/index.html |
| 441 | |
| 442 | popd |
| 443 | done |
| 444 | |
| 445 | echo "</body></html>" >> $HEAT_PIP_REPO/index.html |
| 446 | |
Ian Wienand | ada886d | 2015-10-07 14:06:26 +1100 | [diff] [blame] | 447 | local heat_pip_repo_apache_conf |
| 448 | heat_pip_repo_apache_conf=$(apache_site_config_for heat_pip_repo) |
Steve Baker | 249e36d | 2015-03-05 14:01:45 +1300 | [diff] [blame] | 449 | |
| 450 | sudo cp $FILES/apache-heat-pip-repo.template $heat_pip_repo_apache_conf |
| 451 | sudo sed -e " |
| 452 | s|%HEAT_PIP_REPO%|$HEAT_PIP_REPO|g; |
| 453 | s|%HEAT_PIP_REPO_PORT%|$HEAT_PIP_REPO_PORT|g; |
| 454 | s|%APACHE_NAME%|$APACHE_NAME|g; |
| 455 | " -i $heat_pip_repo_apache_conf |
| 456 | enable_apache_site heat_pip_repo |
| 457 | restart_apache_server |
Steve Baker | 11cf7b6 | 2015-03-27 09:08:53 +1300 | [diff] [blame] | 458 | sudo iptables -I INPUT -d $HOST_IP -p tcp --dport $HEAT_PIP_REPO_PORT -j ACCEPT || true |
Steve Baker | 2a6009c | 2014-05-05 16:13:39 +1200 | [diff] [blame] | 459 | } |
| 460 | |
Dean Troyer | 7903b79 | 2012-09-13 17:16:12 -0500 | [diff] [blame] | 461 | # Restore xtrace |
Ian Wienand | 523f488 | 2015-10-13 11:03:03 +1100 | [diff] [blame] | 462 | $_XTRACE_HEAT |
Sean Dague | 584d90e | 2013-03-29 14:34:53 -0400 | [diff] [blame] | 463 | |
Adam Spiers | 6a5aa7c | 2013-10-24 11:27:02 +0100 | [diff] [blame] | 464 | # Tell emacs to use shell-script-mode |
| 465 | ## Local variables: |
| 466 | ## mode: shell-script |
| 467 | ## End: |