| 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 | 
|  | 19 | # - init_heat | 
|  | 20 | # - start_heat | 
|  | 21 | # - stop_heat | 
|  | 22 | # - cleanup_heat | 
| Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 23 |  | 
| Dean Troyer | 7903b79 | 2012-09-13 17:16:12 -0500 | [diff] [blame] | 24 | # Save trace setting | 
|  | 25 | XTRACE=$(set +o | grep xtrace) | 
|  | 26 | set +o xtrace | 
| Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 27 |  | 
|  | 28 |  | 
|  | 29 | # Defaults | 
|  | 30 | # -------- | 
| Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 31 |  | 
|  | 32 | # set up default directories | 
| Sean Dague | e08ab10 | 2014-11-13 17:09:28 -0500 | [diff] [blame] | 33 | GITDIR["python-heatclient"]=$DEST/python-heatclient | 
| Sean Dague | 5cb1906 | 2014-11-01 01:37:45 +0100 | [diff] [blame] | 34 |  | 
| Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 35 | HEAT_DIR=$DEST/heat | 
| Steve Baker | 315971d | 2014-05-27 12:24:18 +1200 | [diff] [blame] | 36 | HEAT_CFNTOOLS_DIR=$DEST/heat-cfntools | 
|  | 37 | HEAT_TEMPLATES_REPO_DIR=$DEST/heat-templates | 
| Steve Baker | 249e36d | 2015-03-05 14:01:45 +1300 | [diff] [blame] | 38 | OCC_DIR=$DEST/os-collect-config | 
| Steve Baker | 1681995 | 2015-03-18 13:45:40 +1300 | [diff] [blame] | 39 | DIB_UTILS_DIR=$DEST/dib-utils | 
| Steve Baker | 249e36d | 2015-03-05 14:01:45 +1300 | [diff] [blame] | 40 | ORC_DIR=$DEST/os-refresh-config | 
|  | 41 | OAC_DIR=$DEST/os-apply-config | 
|  | 42 |  | 
|  | 43 | HEAT_PIP_REPO=$DATA_DIR/heat-pip-repo | 
|  | 44 | HEAT_PIP_REPO_PORT=${HEAT_PIP_REPO_PORT:-8899} | 
|  | 45 |  | 
| Steve Baker | c324908 | 2013-04-09 13:41:47 +1200 | [diff] [blame] | 46 | HEAT_AUTH_CACHE_DIR=${HEAT_AUTH_CACHE_DIR:-/var/cache/heat} | 
| Sean Dague | 5375329 | 2014-12-04 19:38:15 -0500 | [diff] [blame] | 47 | HEAT_STANDALONE=$(trueorfalse False HEAT_STANDALONE) | 
|  | 48 | HEAT_ENABLE_ADOPT_ABANDON=$(trueorfalse False HEAT_ENABLE_ADOPT_ABANDON) | 
| Angus Salkeld | f645a85 | 2013-08-26 10:13:36 +1000 | [diff] [blame] | 49 | HEAT_CONF_DIR=/etc/heat | 
| Angus Salkeld | a213e2c | 2013-08-30 10:48:46 +1000 | [diff] [blame] | 50 | HEAT_CONF=$HEAT_CONF_DIR/heat.conf | 
| Angus Salkeld | f645a85 | 2013-08-26 10:13:36 +1000 | [diff] [blame] | 51 | HEAT_ENV_DIR=$HEAT_CONF_DIR/environment.d | 
| Angus Salkeld | fb71a27 | 2013-08-26 10:15:38 +1000 | [diff] [blame] | 52 | HEAT_TEMPLATES_DIR=$HEAT_CONF_DIR/templates | 
| Steve Baker | e389aed | 2014-09-23 17:10:39 +1200 | [diff] [blame] | 53 | HEAT_API_HOST=${HEAT_API_HOST:-$HOST_IP} | 
|  | 54 | HEAT_API_PORT=${HEAT_API_PORT:-8004} | 
| Steven Hardy | 3163c17 | 2015-01-23 13:26:29 +0000 | [diff] [blame] | 55 |  | 
| Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 56 |  | 
| Steven Hardy | f83cf93 | 2014-03-12 16:54:01 +0000 | [diff] [blame] | 57 | # other default options | 
| Steve Baker | 744c2af | 2014-12-16 12:00:40 +1300 | [diff] [blame] | 58 | if [[ "$HEAT_STANDALONE" = "True" ]]; then | 
|  | 59 | # for standalone, use defaults which require no service user | 
|  | 60 | HEAT_STACK_DOMAIN=`trueorfalse False $HEAT_STACK_DOMAIN` | 
|  | 61 | HEAT_DEFERRED_AUTH=${HEAT_DEFERRED_AUTH:-password} | 
|  | 62 | else | 
|  | 63 | HEAT_STACK_DOMAIN=`trueorfalse True $HEAT_STACK_DOMAIN` | 
|  | 64 | HEAT_DEFERRED_AUTH=${HEAT_DEFERRED_AUTH:-trusts} | 
|  | 65 | fi | 
| Steven Hardy | f83cf93 | 2014-03-12 16:54:01 +0000 | [diff] [blame] | 66 |  | 
| Dean Troyer | 4237f59 | 2014-01-29 16:22:11 -0600 | [diff] [blame] | 67 | # Tell Tempest this project is present | 
|  | 68 | TEMPEST_SERVICES+=,heat | 
|  | 69 |  | 
|  | 70 |  | 
| Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 71 | # Functions | 
|  | 72 | # --------- | 
| Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 73 |  | 
| Sean Dague | 29870cc | 2014-03-14 14:32:01 -0400 | [diff] [blame] | 74 | # Test if any Heat services are enabled | 
|  | 75 | # is_heat_enabled | 
|  | 76 | function is_heat_enabled { | 
|  | 77 | [[ ,${ENABLED_SERVICES} =~ ,"h-" ]] && return 0 | 
|  | 78 | return 1 | 
|  | 79 | } | 
|  | 80 |  | 
| Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 81 | # cleanup_heat() - Remove residual data files, anything left over from previous | 
|  | 82 | # runs that a clean run would need to clean up | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 83 | function cleanup_heat { | 
| Steve Baker | c324908 | 2013-04-09 13:41:47 +1200 | [diff] [blame] | 84 | sudo rm -rf $HEAT_AUTH_CACHE_DIR | 
| Angus Salkeld | f645a85 | 2013-08-26 10:13:36 +1000 | [diff] [blame] | 85 | sudo rm -rf $HEAT_ENV_DIR | 
| Angus Salkeld | fb71a27 | 2013-08-26 10:15:38 +1000 | [diff] [blame] | 86 | sudo rm -rf $HEAT_TEMPLATES_DIR | 
| Steve Baker | 744c2af | 2014-12-16 12:00:40 +1300 | [diff] [blame] | 87 | sudo rm -rf $HEAT_CONF_DIR | 
| Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 88 | } | 
|  | 89 |  | 
|  | 90 | # configure_heat() - Set config files, create data dirs, etc | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 91 | function configure_heat { | 
| Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 92 |  | 
| Dean Troyer | 8421c2b | 2015-03-16 13:52:19 -0500 | [diff] [blame] | 93 | sudo install -d -o $STACK_USER $HEAT_CONF_DIR | 
| Angus Salkeld | a213e2c | 2013-08-30 10:48:46 +1000 | [diff] [blame] | 94 | # remove old config files | 
|  | 95 | rm -f $HEAT_CONF_DIR/heat-*.conf | 
| Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 96 |  | 
| Steve Baker | e61bc61 | 2014-01-27 15:21:29 +1300 | [diff] [blame] | 97 | HEAT_API_CFN_HOST=${HEAT_API_CFN_HOST:-$HOST_IP} | 
| Angus Salkeld | e279021 | 2012-09-11 11:24:09 +1000 | [diff] [blame] | 98 | HEAT_API_CFN_PORT=${HEAT_API_CFN_PORT:-8000} | 
| Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 99 | HEAT_ENGINE_HOST=${HEAT_ENGINE_HOST:-$SERVICE_HOST} | 
|  | 100 | HEAT_ENGINE_PORT=${HEAT_ENGINE_PORT:-8001} | 
| Steve Baker | e61bc61 | 2014-01-27 15:21:29 +1300 | [diff] [blame] | 101 | HEAT_API_CW_HOST=${HEAT_API_CW_HOST:-$HOST_IP} | 
| Angus Salkeld | e279021 | 2012-09-11 11:24:09 +1000 | [diff] [blame] | 102 | HEAT_API_CW_PORT=${HEAT_API_CW_PORT:-8003} | 
| Steve Baker | d5cd79b | 2013-04-13 11:14:41 -0700 | [diff] [blame] | 103 | HEAT_API_PASTE_FILE=$HEAT_CONF_DIR/api-paste.ini | 
|  | 104 | HEAT_POLICY_FILE=$HEAT_CONF_DIR/policy.json | 
|  | 105 |  | 
|  | 106 | cp $HEAT_DIR/etc/heat/api-paste.ini $HEAT_API_PASTE_FILE | 
|  | 107 | cp $HEAT_DIR/etc/heat/policy.json $HEAT_POLICY_FILE | 
| Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 108 |  | 
| Angus Salkeld | a213e2c | 2013-08-30 10:48:46 +1000 | [diff] [blame] | 109 | # common options | 
| Brant Knudson | 2dd110c | 2015-03-14 12:39:14 -0500 | [diff] [blame] | 110 | iniset_rpc_backend heat $HEAT_CONF | 
| Angus Salkeld | a213e2c | 2013-08-30 10:48:46 +1000 | [diff] [blame] | 111 | iniset $HEAT_CONF DEFAULT heat_metadata_server_url http://$HEAT_API_CFN_HOST:$HEAT_API_CFN_PORT | 
|  | 112 | iniset $HEAT_CONF DEFAULT heat_waitcondition_server_url http://$HEAT_API_CFN_HOST:$HEAT_API_CFN_PORT/v1/waitcondition | 
|  | 113 | 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] | 114 | iniset $HEAT_CONF database connection `database_connection_url heat` | 
| Attila Fazekas | f71b500 | 2014-05-28 09:52:22 +0200 | [diff] [blame] | 115 | iniset $HEAT_CONF DEFAULT auth_encryption_key $(generate_hex_string 16) | 
| Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 116 |  | 
| Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 117 | iniset $HEAT_CONF DEFAULT region_name_for_services "$REGION_NAME" | 
|  | 118 |  | 
| Angus Salkeld | a213e2c | 2013-08-30 10:48:46 +1000 | [diff] [blame] | 119 | # logging | 
|  | 120 | iniset $HEAT_CONF DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL | 
|  | 121 | iniset $HEAT_CONF DEFAULT use_syslog $SYSLOG | 
| Steve Baker | 556ffe4 | 2013-08-06 16:42:38 +1200 | [diff] [blame] | 122 | if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then | 
|  | 123 | # Add color to logging output | 
| Arata Notsu | 4897ff5 | 2013-10-09 18:49:32 +0900 | [diff] [blame] | 124 | setup_colorized_logging $HEAT_CONF DEFAULT tenant user | 
| Steve Baker | 556ffe4 | 2013-08-06 16:42:38 +1200 | [diff] [blame] | 125 | fi | 
|  | 126 |  | 
| Jamie Lennox | 78b7726 | 2014-12-19 12:56:01 +1000 | [diff] [blame] | 127 | # NOTE(jamielennox): heat re-uses specific values from the | 
|  | 128 | # keystone_authtoken middleware group and so currently fails when using the | 
|  | 129 | # auth plugin setup. This should be fixed in heat.  Heat is also the only | 
|  | 130 | # service that requires the auth_uri to include a /v2.0. Remove this custom | 
|  | 131 | # setup when bug #1300246 is resolved. | 
| Jamie Lennox | 78b7726 | 2014-12-19 12:56:01 +1000 | [diff] [blame] | 132 | iniset $HEAT_CONF keystone_authtoken auth_uri $KEYSTONE_SERVICE_URI/v2.0 | 
| Steve Baker | 744c2af | 2014-12-16 12:00:40 +1300 | [diff] [blame] | 133 | if [[ "$HEAT_STANDALONE" = "True" ]]; then | 
|  | 134 | iniset $HEAT_CONF paste_deploy flavor standalone | 
|  | 135 | iniset $HEAT_CONF clients_heat url "http://$HEAT_API_HOST:$HEAT_API_PORT/v1/%(tenant_id)s" | 
|  | 136 | else | 
|  | 137 | iniset $HEAT_CONF keystone_authtoken identity_uri $KEYSTONE_AUTH_URI | 
|  | 138 | iniset $HEAT_CONF keystone_authtoken admin_user heat | 
|  | 139 | iniset $HEAT_CONF keystone_authtoken admin_password $SERVICE_PASSWORD | 
|  | 140 | iniset $HEAT_CONF keystone_authtoken admin_tenant_name $SERVICE_TENANT_NAME | 
|  | 141 | iniset $HEAT_CONF keystone_authtoken cafile $SSL_BUNDLE_FILE | 
|  | 142 | iniset $HEAT_CONF keystone_authtoken signing_dir $HEAT_AUTH_CACHE_DIR | 
|  | 143 | fi | 
| Angus Salkeld | e279021 | 2012-09-11 11:24:09 +1000 | [diff] [blame] | 144 |  | 
| Angus Salkeld | a213e2c | 2013-08-30 10:48:46 +1000 | [diff] [blame] | 145 | # ec2authtoken | 
| Jamie Lennox | 3561d7f | 2014-05-21 17:18:43 +1000 | [diff] [blame] | 146 | iniset $HEAT_CONF ec2authtoken auth_uri $KEYSTONE_SERVICE_URI/v2.0 | 
| Angus Salkeld | a213e2c | 2013-08-30 10:48:46 +1000 | [diff] [blame] | 147 |  | 
| Angus Salkeld | a213e2c | 2013-08-30 10:48:46 +1000 | [diff] [blame] | 148 | # OpenStack API | 
| Angus Salkeld | a213e2c | 2013-08-30 10:48:46 +1000 | [diff] [blame] | 149 | iniset $HEAT_CONF heat_api bind_port $HEAT_API_PORT | 
| Davanum Srinivas | 905275e | 2015-01-24 19:21:34 -0500 | [diff] [blame] | 150 | iniset $HEAT_CONF heat_api workers "$API_WORKERS" | 
| Angus Salkeld | a213e2c | 2013-08-30 10:48:46 +1000 | [diff] [blame] | 151 |  | 
|  | 152 | # Cloudformation API | 
| Angus Salkeld | a213e2c | 2013-08-30 10:48:46 +1000 | [diff] [blame] | 153 | iniset $HEAT_CONF heat_api_cfn bind_port $HEAT_API_CFN_PORT | 
|  | 154 |  | 
|  | 155 | # Cloudwatch API | 
| Angus Salkeld | a213e2c | 2013-08-30 10:48:46 +1000 | [diff] [blame] | 156 | iniset $HEAT_CONF heat_api_cloudwatch bind_port $HEAT_API_CW_PORT | 
| Angus Salkeld | e279021 | 2012-09-11 11:24:09 +1000 | [diff] [blame] | 157 |  | 
| Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 158 | 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 Salkeld | 826e450 | 2015-01-07 17:52:05 +1000 | [diff] [blame] | 170 | 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 |  | 
| Dean Troyer | 8421c2b | 2015-03-16 13:52:19 -0500 | [diff] [blame] | 175 | sudo install -d -o $STACK_USER $HEAT_ENV_DIR $HEAT_TEMPLATES_DIR | 
|  | 176 |  | 
| Angus Salkeld | f645a85 | 2013-08-26 10:13:36 +1000 | [diff] [blame] | 177 | # copy the default environment | 
|  | 178 | cp $HEAT_DIR/etc/heat/environment.d/* $HEAT_ENV_DIR/ | 
|  | 179 |  | 
| Angus Salkeld | fb71a27 | 2013-08-26 10:15:38 +1000 | [diff] [blame] | 180 | # copy the default templates | 
|  | 181 | cp $HEAT_DIR/etc/heat/templates/* $HEAT_TEMPLATES_DIR/ | 
|  | 182 |  | 
| Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 183 | } | 
|  | 184 |  | 
|  | 185 | # init_heat() - Initialize database | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 186 | function init_heat { | 
| Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 187 |  | 
|  | 188 | # (re)create heat database | 
| Ihar Hrachyshka | 157c84b | 2014-10-06 13:29:39 +0200 | [diff] [blame] | 189 | recreate_database heat | 
| Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 190 |  | 
| Steve Baker | e311132 | 2013-06-19 13:57:31 +1200 | [diff] [blame] | 191 | $HEAT_DIR/bin/heat-manage db_sync | 
| Steve Baker | c324908 | 2013-04-09 13:41:47 +1200 | [diff] [blame] | 192 | create_heat_cache_dir | 
|  | 193 | } | 
|  | 194 |  | 
|  | 195 | # create_heat_cache_dir() - Part of the init_heat() process | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 196 | function create_heat_cache_dir { | 
| Steve Baker | c324908 | 2013-04-09 13:41:47 +1200 | [diff] [blame] | 197 | # Create cache dirs | 
| Dean Troyer | 8421c2b | 2015-03-16 13:52:19 -0500 | [diff] [blame] | 198 | sudo install -d -o $STACK_USER $HEAT_AUTH_CACHE_DIR | 
| Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 199 | } | 
|  | 200 |  | 
| Steve Baker | 32761a4 | 2012-11-05 09:57:57 +1300 | [diff] [blame] | 201 | # install_heatclient() - Collect source and prepare | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 202 | function install_heatclient { | 
| Sean Dague | e08ab10 | 2014-11-13 17:09:28 -0500 | [diff] [blame] | 203 | if use_library_from_git "python-heatclient"; then | 
|  | 204 | git_clone_by_name "python-heatclient" | 
|  | 205 | setup_dev_lib "python-heatclient" | 
|  | 206 | 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] | 207 | fi | 
| Steve Baker | 32761a4 | 2012-11-05 09:57:57 +1300 | [diff] [blame] | 208 | } | 
|  | 209 |  | 
| Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 210 | # install_heat() - Collect source and prepare | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 211 | function install_heat { | 
| Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 212 | git_clone $HEAT_REPO $HEAT_DIR $HEAT_BRANCH | 
| Sergey Kraynev | a38bc5b | 2014-12-16 04:25:11 -0500 | [diff] [blame] | 213 | setup_develop $HEAT_DIR | 
| Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 214 | } | 
|  | 215 |  | 
| Steve Baker | 315971d | 2014-05-27 12:24:18 +1200 | [diff] [blame] | 216 | # install_heat_other() - Collect source and prepare | 
|  | 217 | function install_heat_other { | 
|  | 218 | git_clone $HEAT_CFNTOOLS_REPO $HEAT_CFNTOOLS_DIR $HEAT_CFNTOOLS_BRANCH | 
|  | 219 | git_clone $HEAT_TEMPLATES_REPO $HEAT_TEMPLATES_REPO_DIR $HEAT_TEMPLATES_BRANCH | 
| Steve Baker | 1681995 | 2015-03-18 13:45:40 +1300 | [diff] [blame] | 220 | git_clone $OAC_REPO $OAC_DIR $OAC_BRANCH | 
|  | 221 | git_clone $OCC_REPO $OCC_DIR $OCC_BRANCH | 
|  | 222 | git_clone $ORC_REPO $ORC_DIR $ORC_BRANCH | 
|  | 223 | git_clone $DIB_UTILS_REPO $DIB_UTILS_DIR $DIB_UTILS_BRANCH | 
| Steve Baker | 315971d | 2014-05-27 12:24:18 +1200 | [diff] [blame] | 224 | } | 
|  | 225 |  | 
| Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 226 | # start_heat() - Start running processes, including screen | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 227 | function start_heat { | 
| Chris Dent | 2f27a0e | 2014-09-09 13:46:02 +0100 | [diff] [blame] | 228 | run_process h-eng "$HEAT_DIR/bin/heat-engine --config-file=$HEAT_CONF" | 
|  | 229 | run_process h-api "$HEAT_DIR/bin/heat-api --config-file=$HEAT_CONF" | 
|  | 230 | run_process h-api-cfn "$HEAT_DIR/bin/heat-api-cfn --config-file=$HEAT_CONF" | 
|  | 231 | run_process h-api-cw "$HEAT_DIR/bin/heat-api-cloudwatch --config-file=$HEAT_CONF" | 
| Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 232 | } | 
|  | 233 |  | 
| Dean Troyer | 699a29f | 2012-09-10 14:10:27 -0500 | [diff] [blame] | 234 | # stop_heat() - Stop running processes | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 235 | function stop_heat { | 
| Kieran Spear | 7033829 | 2013-05-28 11:31:31 +1000 | [diff] [blame] | 236 | # Kill the screen windows | 
| Dean Troyer | 7d31bdc | 2014-07-25 12:50:05 -0500 | [diff] [blame] | 237 | local serv | 
| Kieran Spear | 7033829 | 2013-05-28 11:31:31 +1000 | [diff] [blame] | 238 | for serv in h-eng h-api h-api-cfn h-api-cw; do | 
| Chris Dent | 2f27a0e | 2014-09-09 13:46:02 +0100 | [diff] [blame] | 239 | stop_process $serv | 
| Dean Troyer | 699a29f | 2012-09-10 14:10:27 -0500 | [diff] [blame] | 240 | done | 
| Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 241 | } | 
| Dean Troyer | 7903b79 | 2012-09-13 17:16:12 -0500 | [diff] [blame] | 242 |  | 
| Steven Hardy | 33d1f86 | 2014-02-13 15:00:33 +0000 | [diff] [blame] | 243 | # create_heat_accounts() - Set up common required heat accounts | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 244 | function create_heat_accounts { | 
| Steve Baker | 744c2af | 2014-12-16 12:00:40 +1300 | [diff] [blame] | 245 | if [[ "$HEAT_STANDALONE" != "True" ]]; then | 
| Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 246 |  | 
| Steve Baker | 744c2af | 2014-12-16 12:00:40 +1300 | [diff] [blame] | 247 | create_service_user "heat" "admin" | 
| Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 248 |  | 
| Steve Baker | 744c2af | 2014-12-16 12:00:40 +1300 | [diff] [blame] | 249 | if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then | 
| Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 250 |  | 
| Steve Baker | 744c2af | 2014-12-16 12:00:40 +1300 | [diff] [blame] | 251 | local heat_service=$(get_or_create_service "heat" \ | 
|  | 252 | "orchestration" "Heat Orchestration Service") | 
|  | 253 | get_or_create_endpoint $heat_service \ | 
|  | 254 | "$REGION_NAME" \ | 
|  | 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 | "$SERVICE_PROTOCOL://$HEAT_API_HOST:$HEAT_API_PORT/v1/\$(tenant_id)s" | 
|  | 258 |  | 
|  | 259 | local heat_cfn_service=$(get_or_create_service "heat-cfn" \ | 
|  | 260 | "cloudformation" "Heat CloudFormation Service") | 
|  | 261 | get_or_create_endpoint $heat_cfn_service \ | 
|  | 262 | "$REGION_NAME" \ | 
|  | 263 | "$SERVICE_PROTOCOL://$HEAT_API_CFN_HOST:$HEAT_API_CFN_PORT/v1" \ | 
|  | 264 | "$SERVICE_PROTOCOL://$HEAT_API_CFN_HOST:$HEAT_API_CFN_PORT/v1" \ | 
|  | 265 | "$SERVICE_PROTOCOL://$HEAT_API_CFN_HOST:$HEAT_API_CFN_PORT/v1" | 
|  | 266 | fi | 
|  | 267 |  | 
|  | 268 | # heat_stack_user role is for users created by Heat | 
|  | 269 | get_or_create_role "heat_stack_user" | 
| Steven Hardy | 57d478d | 2014-02-28 16:37:43 +0000 | [diff] [blame] | 270 | fi | 
|  | 271 |  | 
| Steven Hardy | f83cf93 | 2014-03-12 16:54:01 +0000 | [diff] [blame] | 272 | if [[ $HEAT_DEFERRED_AUTH == trusts ]]; then | 
| Steven Hardy | f83cf93 | 2014-03-12 16:54:01 +0000 | [diff] [blame] | 273 | iniset $HEAT_CONF DEFAULT deferred_auth_method trusts | 
|  | 274 | fi | 
| Steven Hardy | 2ca3bf1 | 2014-03-03 18:07:33 +0000 | [diff] [blame] | 275 |  | 
| Steve Baker | 16aca8a | 2014-03-11 14:01:57 +1300 | [diff] [blame] | 276 | if [[ "$HEAT_STACK_DOMAIN" == "True" ]]; then | 
|  | 277 | # Note we have to pass token/endpoint here because the current endpoint and | 
|  | 278 | # version negotiation in OSC means just --os-identity-api-version=3 won't work | 
| Steve Martinelli | b74e01c | 2014-12-18 01:35:35 -0500 | [diff] [blame] | 279 | D_ID=$(openstack --os-token $OS_TOKEN --os-url=$KEYSTONE_SERVICE_URI_V3 \ | 
| Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 280 | --os-identity-api-version=3 domain list | grep ' heat ' | get_field 1) | 
|  | 281 |  | 
|  | 282 | if [[ -z "$D_ID" ]]; then | 
| Steve Martinelli | b74e01c | 2014-12-18 01:35:35 -0500 | [diff] [blame] | 283 | D_ID=$(openstack --os-token $OS_TOKEN --os-url=$KEYSTONE_SERVICE_URI_V3 \ | 
| Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 284 | --os-identity-api-version=3 domain create heat \ | 
|  | 285 | --description "Owns users and projects created by heat" \ | 
|  | 286 | | grep ' id ' | get_field 2) | 
| Sirushti Murugesan | 2f92c8d | 2014-10-09 14:35:38 +0530 | [diff] [blame] | 287 | iniset $HEAT_CONF DEFAULT stack_user_domain_id ${D_ID} | 
| Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 288 |  | 
| Steve Martinelli | b74e01c | 2014-12-18 01:35:35 -0500 | [diff] [blame] | 289 | openstack --os-token $OS_TOKEN --os-url=$KEYSTONE_SERVICE_URI_V3 \ | 
| Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 290 | --os-identity-api-version=3 user create --password $SERVICE_PASSWORD \ | 
|  | 291 | --domain $D_ID heat_domain_admin \ | 
|  | 292 | --description "Manages users and projects created by heat" | 
| Steve Martinelli | b74e01c | 2014-12-18 01:35:35 -0500 | [diff] [blame] | 293 | openstack --os-token $OS_TOKEN --os-url=$KEYSTONE_SERVICE_URI_V3 \ | 
| Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 294 | --os-identity-api-version=3 role add \ | 
|  | 295 | --user heat_domain_admin --domain ${D_ID} admin | 
|  | 296 | iniset $HEAT_CONF DEFAULT stack_domain_admin heat_domain_admin | 
|  | 297 | iniset $HEAT_CONF DEFAULT stack_domain_admin_password $SERVICE_PASSWORD | 
|  | 298 | fi | 
| Steve Baker | 16aca8a | 2014-03-11 14:01:57 +1300 | [diff] [blame] | 299 | fi | 
| Steven Hardy | 33d1f86 | 2014-02-13 15:00:33 +0000 | [diff] [blame] | 300 | } | 
|  | 301 |  | 
| Steve Baker | 249e36d | 2015-03-05 14:01:45 +1300 | [diff] [blame] | 302 | # build_heat_pip_mirror() - Build a pip mirror containing heat agent projects | 
|  | 303 | function build_heat_pip_mirror { | 
| Steve Baker | 1681995 | 2015-03-18 13:45:40 +1300 | [diff] [blame] | 304 | local project_dirs="$OCC_DIR $OAC_DIR $ORC_DIR $HEAT_CFNTOOLS_DIR $DIB_UTILS_DIR" | 
| Steve Baker | 249e36d | 2015-03-05 14:01:45 +1300 | [diff] [blame] | 305 | local projpath proj package | 
| Steve Baker | 2a6009c | 2014-05-05 16:13:39 +1200 | [diff] [blame] | 306 |  | 
| Steve Baker | 249e36d | 2015-03-05 14:01:45 +1300 | [diff] [blame] | 307 | rm -rf $HEAT_PIP_REPO | 
|  | 308 | mkdir -p $HEAT_PIP_REPO | 
| Steve Baker | 2a6009c | 2014-05-05 16:13:39 +1200 | [diff] [blame] | 309 |  | 
| Steve Baker | 249e36d | 2015-03-05 14:01:45 +1300 | [diff] [blame] | 310 | echo "<html><body>" > $HEAT_PIP_REPO/index.html | 
|  | 311 | for projpath in $project_dirs; do | 
|  | 312 | proj=$(basename $projpath) | 
|  | 313 | mkdir -p $HEAT_PIP_REPO/$proj | 
|  | 314 | pushd $projpath | 
|  | 315 | rm -rf dist | 
|  | 316 | python setup.py sdist | 
|  | 317 | pushd dist | 
|  | 318 | package=$(ls *) | 
|  | 319 | mv $package $HEAT_PIP_REPO/$proj/$package | 
|  | 320 | popd | 
|  | 321 |  | 
|  | 322 | echo "<html><body><a href=\"$package\">$package</a></body></html>" > $HEAT_PIP_REPO/$proj/index.html | 
|  | 323 | echo "<a href=\"$proj\">$proj</a><br/>" >> $HEAT_PIP_REPO/index.html | 
|  | 324 |  | 
|  | 325 | popd | 
|  | 326 | done | 
|  | 327 |  | 
|  | 328 | echo "</body></html>" >> $HEAT_PIP_REPO/index.html | 
|  | 329 |  | 
|  | 330 | local heat_pip_repo_apache_conf=$(apache_site_config_for heat_pip_repo) | 
|  | 331 |  | 
|  | 332 | sudo cp $FILES/apache-heat-pip-repo.template $heat_pip_repo_apache_conf | 
|  | 333 | sudo sed -e " | 
|  | 334 | s|%HEAT_PIP_REPO%|$HEAT_PIP_REPO|g; | 
|  | 335 | s|%HEAT_PIP_REPO_PORT%|$HEAT_PIP_REPO_PORT|g; | 
|  | 336 | s|%APACHE_NAME%|$APACHE_NAME|g; | 
|  | 337 | " -i $heat_pip_repo_apache_conf | 
|  | 338 | enable_apache_site heat_pip_repo | 
|  | 339 | restart_apache_server | 
| Steve Baker | 2a6009c | 2014-05-05 16:13:39 +1200 | [diff] [blame] | 340 | } | 
|  | 341 |  | 
| Dean Troyer | 7903b79 | 2012-09-13 17:16:12 -0500 | [diff] [blame] | 342 | # Restore xtrace | 
|  | 343 | $XTRACE | 
| Sean Dague | 584d90e | 2013-03-29 14:34:53 -0400 | [diff] [blame] | 344 |  | 
| Adam Spiers | 6a5aa7c | 2013-10-24 11:27:02 +0100 | [diff] [blame] | 345 | # Tell emacs to use shell-script-mode | 
|  | 346 | ## Local variables: | 
|  | 347 | ## mode: shell-script | 
|  | 348 | ## End: |