Mate Lakat | 45ea081 | 2013-09-25 10:00:29 +0100 | [diff] [blame] | 1 | # lib/heat |
Dean Troyer | 6d04fd7 | 2012-12-21 11:03:37 -0600 | [diff] [blame] | 2 | # Install and start **Heat** service |
| 3 | |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 4 | # To enable, add the following to localrc |
Adam Spiers | 6a5aa7c | 2013-10-24 11:27:02 +0100 | [diff] [blame] | 5 | # |
| 6 | # 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] | 7 | |
| 8 | # Dependencies: |
Adam Spiers | 6a5aa7c | 2013-10-24 11:27:02 +0100 | [diff] [blame] | 9 | # |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 10 | # - functions |
| 11 | |
| 12 | # stack.sh |
| 13 | # --------- |
Adam Spiers | 6a5aa7c | 2013-10-24 11:27:02 +0100 | [diff] [blame] | 14 | # - install_heatclient |
| 15 | # - install_heat |
| 16 | # - configure_heatclient |
| 17 | # - configure_heat |
| 18 | # - init_heat |
| 19 | # - start_heat |
| 20 | # - stop_heat |
| 21 | # - cleanup_heat |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 22 | |
Dean Troyer | 7903b79 | 2012-09-13 17:16:12 -0500 | [diff] [blame] | 23 | # Save trace setting |
| 24 | XTRACE=$(set +o | grep xtrace) |
| 25 | set +o xtrace |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 26 | |
| 27 | |
| 28 | # Defaults |
| 29 | # -------- |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 30 | |
| 31 | # set up default directories |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 32 | HEAT_DIR=$DEST/heat |
Steve Baker | 32761a4 | 2012-11-05 09:57:57 +1300 | [diff] [blame] | 33 | HEATCLIENT_DIR=$DEST/python-heatclient |
Steve Baker | c324908 | 2013-04-09 13:41:47 +1200 | [diff] [blame] | 34 | HEAT_AUTH_CACHE_DIR=${HEAT_AUTH_CACHE_DIR:-/var/cache/heat} |
Steve Baker | 389b3a0 | 2013-08-01 10:44:09 +1200 | [diff] [blame] | 35 | HEAT_STANDALONE=`trueorfalse False $HEAT_STANDALONE` |
Angus Salkeld | f645a85 | 2013-08-26 10:13:36 +1000 | [diff] [blame] | 36 | HEAT_CONF_DIR=/etc/heat |
Angus Salkeld | a213e2c | 2013-08-30 10:48:46 +1000 | [diff] [blame] | 37 | HEAT_CONF=$HEAT_CONF_DIR/heat.conf |
Angus Salkeld | f645a85 | 2013-08-26 10:13:36 +1000 | [diff] [blame] | 38 | HEAT_ENV_DIR=$HEAT_CONF_DIR/environment.d |
Angus Salkeld | fb71a27 | 2013-08-26 10:15:38 +1000 | [diff] [blame] | 39 | HEAT_TEMPLATES_DIR=$HEAT_CONF_DIR/templates |
Steve Baker | 16aca8a | 2014-03-11 14:01:57 +1300 | [diff] [blame] | 40 | HEAT_STACK_DOMAIN=`trueorfalse True $HEAT_STACK_DOMAIN` |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 41 | |
Steven Hardy | f83cf93 | 2014-03-12 16:54:01 +0000 | [diff] [blame] | 42 | # other default options |
| 43 | HEAT_DEFERRED_AUTH=${HEAT_DEFERRED_AUTH:-trusts} |
| 44 | |
Dean Troyer | 4237f59 | 2014-01-29 16:22:11 -0600 | [diff] [blame] | 45 | # Tell Tempest this project is present |
| 46 | TEMPEST_SERVICES+=,heat |
| 47 | |
| 48 | |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 49 | # Functions |
| 50 | # --------- |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 51 | |
Sean Dague | 29870cc | 2014-03-14 14:32:01 -0400 | [diff] [blame] | 52 | # Test if any Heat services are enabled |
| 53 | # is_heat_enabled |
| 54 | function is_heat_enabled { |
| 55 | [[ ,${ENABLED_SERVICES} =~ ,"h-" ]] && return 0 |
| 56 | return 1 |
| 57 | } |
| 58 | |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 59 | # cleanup_heat() - Remove residual data files, anything left over from previous |
| 60 | # runs that a clean run would need to clean up |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 61 | function cleanup_heat { |
Steve Baker | c324908 | 2013-04-09 13:41:47 +1200 | [diff] [blame] | 62 | sudo rm -rf $HEAT_AUTH_CACHE_DIR |
Angus Salkeld | f645a85 | 2013-08-26 10:13:36 +1000 | [diff] [blame] | 63 | sudo rm -rf $HEAT_ENV_DIR |
Angus Salkeld | fb71a27 | 2013-08-26 10:15:38 +1000 | [diff] [blame] | 64 | sudo rm -rf $HEAT_TEMPLATES_DIR |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | # configure_heat() - Set config files, create data dirs, etc |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 68 | function configure_heat { |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 69 | setup_develop $HEAT_DIR |
| 70 | |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 71 | if [[ ! -d $HEAT_CONF_DIR ]]; then |
| 72 | sudo mkdir -p $HEAT_CONF_DIR |
| 73 | fi |
Attila Fazekas | 91b8d13 | 2013-01-06 22:40:09 +0100 | [diff] [blame] | 74 | sudo chown $STACK_USER $HEAT_CONF_DIR |
Angus Salkeld | a213e2c | 2013-08-30 10:48:46 +1000 | [diff] [blame] | 75 | # remove old config files |
| 76 | rm -f $HEAT_CONF_DIR/heat-*.conf |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 77 | |
Steve Baker | e61bc61 | 2014-01-27 15:21:29 +1300 | [diff] [blame] | 78 | HEAT_API_CFN_HOST=${HEAT_API_CFN_HOST:-$HOST_IP} |
Angus Salkeld | e279021 | 2012-09-11 11:24:09 +1000 | [diff] [blame] | 79 | HEAT_API_CFN_PORT=${HEAT_API_CFN_PORT:-8000} |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 80 | HEAT_ENGINE_HOST=${HEAT_ENGINE_HOST:-$SERVICE_HOST} |
| 81 | HEAT_ENGINE_PORT=${HEAT_ENGINE_PORT:-8001} |
Steve Baker | e61bc61 | 2014-01-27 15:21:29 +1300 | [diff] [blame] | 82 | HEAT_API_CW_HOST=${HEAT_API_CW_HOST:-$HOST_IP} |
Angus Salkeld | e279021 | 2012-09-11 11:24:09 +1000 | [diff] [blame] | 83 | HEAT_API_CW_PORT=${HEAT_API_CW_PORT:-8003} |
Steve Baker | e61bc61 | 2014-01-27 15:21:29 +1300 | [diff] [blame] | 84 | HEAT_API_HOST=${HEAT_API_HOST:-$HOST_IP} |
Steve Baker | bb421be | 2012-10-10 13:19:10 +1300 | [diff] [blame] | 85 | HEAT_API_PORT=${HEAT_API_PORT:-8004} |
Steve Baker | d5cd79b | 2013-04-13 11:14:41 -0700 | [diff] [blame] | 86 | HEAT_API_PASTE_FILE=$HEAT_CONF_DIR/api-paste.ini |
| 87 | HEAT_POLICY_FILE=$HEAT_CONF_DIR/policy.json |
| 88 | |
| 89 | cp $HEAT_DIR/etc/heat/api-paste.ini $HEAT_API_PASTE_FILE |
| 90 | cp $HEAT_DIR/etc/heat/policy.json $HEAT_POLICY_FILE |
Angus Salkeld | a213e2c | 2013-08-30 10:48:46 +1000 | [diff] [blame] | 91 | cp $HEAT_DIR/etc/heat/heat.conf.sample $HEAT_CONF |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 92 | |
Angus Salkeld | a213e2c | 2013-08-30 10:48:46 +1000 | [diff] [blame] | 93 | # common options |
| 94 | iniset_rpc_backend heat $HEAT_CONF DEFAULT |
| 95 | iniset $HEAT_CONF DEFAULT heat_metadata_server_url http://$HEAT_API_CFN_HOST:$HEAT_API_CFN_PORT |
| 96 | iniset $HEAT_CONF DEFAULT heat_waitcondition_server_url http://$HEAT_API_CFN_HOST:$HEAT_API_CFN_PORT/v1/waitcondition |
| 97 | 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] | 98 | iniset $HEAT_CONF database connection `database_connection_url heat` |
Attila Fazekas | 499315f | 2014-03-25 10:42:14 +0100 | [diff] [blame] | 99 | iniset $HEAT_CONF DEFAULT auth_encryption_key `hexdump -n 16 -v -e '/1 "%02x"' /dev/urandom` |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 100 | |
Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame^] | 101 | iniset $HEAT_CONF DEFAULT region_name_for_services "$REGION_NAME" |
| 102 | |
Angus Salkeld | a213e2c | 2013-08-30 10:48:46 +1000 | [diff] [blame] | 103 | # logging |
| 104 | iniset $HEAT_CONF DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL |
| 105 | iniset $HEAT_CONF DEFAULT use_syslog $SYSLOG |
Steve Baker | 556ffe4 | 2013-08-06 16:42:38 +1200 | [diff] [blame] | 106 | if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then |
| 107 | # Add color to logging output |
Arata Notsu | 4897ff5 | 2013-10-09 18:49:32 +0900 | [diff] [blame] | 108 | setup_colorized_logging $HEAT_CONF DEFAULT tenant user |
Steve Baker | 556ffe4 | 2013-08-06 16:42:38 +1200 | [diff] [blame] | 109 | fi |
| 110 | |
Angus Salkeld | a213e2c | 2013-08-30 10:48:46 +1000 | [diff] [blame] | 111 | # keystone authtoken |
Jamie Lennox | 3561d7f | 2014-05-21 17:18:43 +1000 | [diff] [blame] | 112 | iniset $HEAT_CONF keystone_authtoken identity_uri $KEYSTONE_AUTH_URI |
Vincent Hou | 21fe4e7 | 2013-11-21 03:10:27 -0500 | [diff] [blame] | 113 | configure_API_version $HEAT_CONF $IDENTITY_API_VERSION |
Jamie Lennox | bd24a8d | 2013-09-20 16:26:42 +1000 | [diff] [blame] | 114 | iniset $HEAT_CONF keystone_authtoken cafile $KEYSTONE_SSL_CA |
Angus Salkeld | a213e2c | 2013-08-30 10:48:46 +1000 | [diff] [blame] | 115 | iniset $HEAT_CONF keystone_authtoken admin_tenant_name $SERVICE_TENANT_NAME |
| 116 | iniset $HEAT_CONF keystone_authtoken admin_user heat |
| 117 | iniset $HEAT_CONF keystone_authtoken admin_password $SERVICE_PASSWORD |
Angus Salkeld | e118655 | 2013-09-06 13:35:09 +1000 | [diff] [blame] | 118 | iniset $HEAT_CONF keystone_authtoken signing_dir $HEAT_AUTH_CACHE_DIR |
Angus Salkeld | e279021 | 2012-09-11 11:24:09 +1000 | [diff] [blame] | 119 | |
Rob Crittenden | fefd64b | 2014-05-27 22:27:15 -0400 | [diff] [blame] | 120 | if is_ssl_enabled_service "key"; then |
| 121 | iniset $HEAT_CONF clients_keystone ca_file $KEYSTONE_SSL_CA |
| 122 | fi |
| 123 | |
Angus Salkeld | a213e2c | 2013-08-30 10:48:46 +1000 | [diff] [blame] | 124 | # ec2authtoken |
Jamie Lennox | 3561d7f | 2014-05-21 17:18:43 +1000 | [diff] [blame] | 125 | iniset $HEAT_CONF ec2authtoken auth_uri $KEYSTONE_SERVICE_URI/v2.0 |
Angus Salkeld | a213e2c | 2013-08-30 10:48:46 +1000 | [diff] [blame] | 126 | |
| 127 | # paste_deploy |
| 128 | [[ "$HEAT_STANDALONE" = "True" ]] && iniset $HEAT_CONF paste_deploy flavor standalone |
| 129 | |
| 130 | # OpenStack API |
Angus Salkeld | a213e2c | 2013-08-30 10:48:46 +1000 | [diff] [blame] | 131 | iniset $HEAT_CONF heat_api bind_port $HEAT_API_PORT |
| 132 | |
| 133 | # Cloudformation API |
Angus Salkeld | a213e2c | 2013-08-30 10:48:46 +1000 | [diff] [blame] | 134 | iniset $HEAT_CONF heat_api_cfn bind_port $HEAT_API_CFN_PORT |
| 135 | |
| 136 | # Cloudwatch API |
Angus Salkeld | a213e2c | 2013-08-30 10:48:46 +1000 | [diff] [blame] | 137 | iniset $HEAT_CONF heat_api_cloudwatch bind_port $HEAT_API_CW_PORT |
Angus Salkeld | e279021 | 2012-09-11 11:24:09 +1000 | [diff] [blame] | 138 | |
Angus Salkeld | f645a85 | 2013-08-26 10:13:36 +1000 | [diff] [blame] | 139 | # heat environment |
| 140 | sudo mkdir -p $HEAT_ENV_DIR |
| 141 | sudo chown $STACK_USER $HEAT_ENV_DIR |
| 142 | # copy the default environment |
| 143 | cp $HEAT_DIR/etc/heat/environment.d/* $HEAT_ENV_DIR/ |
| 144 | |
Angus Salkeld | fb71a27 | 2013-08-26 10:15:38 +1000 | [diff] [blame] | 145 | # heat template resources. |
| 146 | sudo mkdir -p $HEAT_TEMPLATES_DIR |
| 147 | sudo chown $STACK_USER $HEAT_TEMPLATES_DIR |
| 148 | # copy the default templates |
| 149 | cp $HEAT_DIR/etc/heat/templates/* $HEAT_TEMPLATES_DIR/ |
| 150 | |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 151 | } |
| 152 | |
| 153 | # init_heat() - Initialize database |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 154 | function init_heat { |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 155 | |
| 156 | # (re)create heat database |
Terry Wilson | 428af5a | 2012-11-01 16:12:39 -0400 | [diff] [blame] | 157 | recreate_database heat utf8 |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 158 | |
Steve Baker | e311132 | 2013-06-19 13:57:31 +1200 | [diff] [blame] | 159 | $HEAT_DIR/bin/heat-manage db_sync |
Steve Baker | c324908 | 2013-04-09 13:41:47 +1200 | [diff] [blame] | 160 | create_heat_cache_dir |
| 161 | } |
| 162 | |
| 163 | # create_heat_cache_dir() - Part of the init_heat() process |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 164 | function create_heat_cache_dir { |
Steve Baker | c324908 | 2013-04-09 13:41:47 +1200 | [diff] [blame] | 165 | # Create cache dirs |
Angus Salkeld | e118655 | 2013-09-06 13:35:09 +1000 | [diff] [blame] | 166 | sudo mkdir -p $HEAT_AUTH_CACHE_DIR |
| 167 | sudo chown $STACK_USER $HEAT_AUTH_CACHE_DIR |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 168 | } |
| 169 | |
Steve Baker | 32761a4 | 2012-11-05 09:57:57 +1300 | [diff] [blame] | 170 | # install_heatclient() - Collect source and prepare |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 171 | function install_heatclient { |
Steve Baker | 32761a4 | 2012-11-05 09:57:57 +1300 | [diff] [blame] | 172 | git_clone $HEATCLIENT_REPO $HEATCLIENT_DIR $HEATCLIENT_BRANCH |
Sean Dague | d644e23 | 2013-07-25 15:34:48 -0400 | [diff] [blame] | 173 | setup_develop $HEATCLIENT_DIR |
Attila Fazekas | 8664ca5 | 2014-02-02 10:07:39 +0100 | [diff] [blame] | 174 | sudo install -D -m 0644 -o $STACK_USER {$HEATCLIENT_DIR/tools/,/etc/bash_completion.d/}heat.bash_completion |
Steve Baker | 32761a4 | 2012-11-05 09:57:57 +1300 | [diff] [blame] | 175 | } |
| 176 | |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 177 | # install_heat() - Collect source and prepare |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 178 | function install_heat { |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 179 | git_clone $HEAT_REPO $HEAT_DIR $HEAT_BRANCH |
| 180 | } |
| 181 | |
| 182 | # start_heat() - Start running processes, including screen |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 183 | function start_heat { |
Angus Salkeld | a213e2c | 2013-08-30 10:48:46 +1000 | [diff] [blame] | 184 | screen_it h-eng "cd $HEAT_DIR; bin/heat-engine --config-file=$HEAT_CONF" |
| 185 | screen_it h-api "cd $HEAT_DIR; bin/heat-api --config-file=$HEAT_CONF" |
| 186 | screen_it h-api-cfn "cd $HEAT_DIR; bin/heat-api-cfn --config-file=$HEAT_CONF" |
| 187 | screen_it h-api-cw "cd $HEAT_DIR; bin/heat-api-cloudwatch --config-file=$HEAT_CONF" |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 188 | } |
| 189 | |
Dean Troyer | 699a29f | 2012-09-10 14:10:27 -0500 | [diff] [blame] | 190 | # stop_heat() - Stop running processes |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 191 | function stop_heat { |
Kieran Spear | 7033829 | 2013-05-28 11:31:31 +1000 | [diff] [blame] | 192 | # Kill the screen windows |
| 193 | for serv in h-eng h-api h-api-cfn h-api-cw; do |
Dean Troyer | 9fc8792 | 2013-05-22 17:19:06 -0500 | [diff] [blame] | 194 | screen_stop $serv |
Dean Troyer | 699a29f | 2012-09-10 14:10:27 -0500 | [diff] [blame] | 195 | done |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 196 | } |
Dean Troyer | 7903b79 | 2012-09-13 17:16:12 -0500 | [diff] [blame] | 197 | |
Steve Baker | d5cccad | 2013-07-19 10:34:24 +1200 | [diff] [blame] | 198 | function disk_image_create { |
| 199 | local elements_path=$1 |
| 200 | local elements=$2 |
| 201 | local arch=$3 |
| 202 | local output=$TOP_DIR/files/$4 |
Sean Dague | 16dd8b3 | 2014-02-03 09:10:54 +0900 | [diff] [blame] | 203 | if [[ -f "$output.qcow2" ]]; then |
Steve Baker | d5cccad | 2013-07-19 10:34:24 +1200 | [diff] [blame] | 204 | echo "Image file already exists: $output_file" |
| 205 | else |
| 206 | ELEMENTS_PATH=$elements_path disk-image-create \ |
| 207 | $elements -a $arch -o $output |
| 208 | fi |
| 209 | # upload with fake URL so that image in $TOP_DIR/files is used |
| 210 | upload_image "http://localhost/$output.qcow2" $TOKEN |
| 211 | } |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 212 | |
Steven Hardy | 33d1f86 | 2014-02-13 15:00:33 +0000 | [diff] [blame] | 213 | # create_heat_accounts() - Set up common required heat accounts |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 214 | function create_heat_accounts { |
Steven Hardy | 57d478d | 2014-02-28 16:37:43 +0000 | [diff] [blame] | 215 | # migrated from files/keystone_data.sh |
| 216 | SERVICE_TENANT=$(openstack project list | awk "/ $SERVICE_TENANT_NAME / { print \$2 }") |
| 217 | ADMIN_ROLE=$(openstack role list | awk "/ admin / { print \$2 }") |
| 218 | |
Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame^] | 219 | HEAT_USER=$(get_or_create_user "heat" \ |
| 220 | "$SERVICE_PASSWORD" $SERVICE_TENANT "heat@example.com") |
| 221 | get_or_add_user_role $ADMIN_ROLE $HEAT_USER $SERVICE_TENANT |
| 222 | |
Steven Hardy | 57d478d | 2014-02-28 16:37:43 +0000 | [diff] [blame] | 223 | if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then |
Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame^] | 224 | |
| 225 | HEAT_SERVICE=$(get_or_create_service "heat" \ |
| 226 | "orchestration" "Heat Orchestration Service") |
| 227 | get_or_create_endpoint $HEAT_SERVICE \ |
| 228 | "$REGION_NAME" \ |
| 229 | "$SERVICE_PROTOCOL://$HEAT_API_HOST:$HEAT_API_PORT/v1/\$(tenant_id)s" \ |
| 230 | "$SERVICE_PROTOCOL://$HEAT_API_HOST:$HEAT_API_PORT/v1/\$(tenant_id)s" \ |
| 231 | "$SERVICE_PROTOCOL://$HEAT_API_HOST:$HEAT_API_PORT/v1/\$(tenant_id)s" |
| 232 | |
| 233 | HEAT_CFN_SERVICE=$(get_or_create_service "heat-cfn" \ |
| 234 | "cloudformation" "Heat CloudFormation Service") |
| 235 | get_or_create_endpoint $HEAT_CFN_SERVICE \ |
| 236 | "$REGION_NAME" \ |
| 237 | "$SERVICE_PROTOCOL://$HEAT_API_CFN_HOST:$HEAT_API_CFN_PORT/v1" \ |
| 238 | "$SERVICE_PROTOCOL://$HEAT_API_CFN_HOST:$HEAT_API_CFN_PORT/v1" \ |
| 239 | "$SERVICE_PROTOCOL://$HEAT_API_CFN_HOST:$HEAT_API_CFN_PORT/v1" |
Steven Hardy | 57d478d | 2014-02-28 16:37:43 +0000 | [diff] [blame] | 240 | fi |
| 241 | |
| 242 | # heat_stack_user role is for users created by Heat |
Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame^] | 243 | get_or_create_role "heat_stack_user" |
Steven Hardy | 57d478d | 2014-02-28 16:37:43 +0000 | [diff] [blame] | 244 | |
Steven Hardy | f83cf93 | 2014-03-12 16:54:01 +0000 | [diff] [blame] | 245 | if [[ $HEAT_DEFERRED_AUTH == trusts ]]; then |
Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame^] | 246 | |
Steven Hardy | f83cf93 | 2014-03-12 16:54:01 +0000 | [diff] [blame] | 247 | # heat_stack_owner role is given to users who create Heat stacks, |
| 248 | # it's the default role used by heat to delegate to the heat service |
| 249 | # user (for performing deferred operations via trusts), see heat.conf |
Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame^] | 250 | HEAT_OWNER_ROLE=$(get_or_create_role "heat_stack_owner") |
Steven Hardy | 2ca3bf1 | 2014-03-03 18:07:33 +0000 | [diff] [blame] | 251 | |
Steven Hardy | f83cf93 | 2014-03-12 16:54:01 +0000 | [diff] [blame] | 252 | # Give the role to the demo and admin users so they can create stacks |
| 253 | # in either of the projects created by devstack |
Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame^] | 254 | get_or_add_user_role $HEAT_OWNER_ROLE demo demo |
| 255 | get_or_add_user_role $HEAT_OWNER_ROLE admin demo |
| 256 | get_or_add_user_role $HEAT_OWNER_ROLE admin admin |
Steven Hardy | f83cf93 | 2014-03-12 16:54:01 +0000 | [diff] [blame] | 257 | iniset $HEAT_CONF DEFAULT deferred_auth_method trusts |
| 258 | fi |
Steven Hardy | 2ca3bf1 | 2014-03-03 18:07:33 +0000 | [diff] [blame] | 259 | |
Steve Baker | 16aca8a | 2014-03-11 14:01:57 +1300 | [diff] [blame] | 260 | if [[ "$HEAT_STACK_DOMAIN" == "True" ]]; then |
| 261 | # Note we have to pass token/endpoint here because the current endpoint and |
| 262 | # version negotiation in OSC means just --os-identity-api-version=3 won't work |
Jamie Lennox | 3561d7f | 2014-05-21 17:18:43 +1000 | [diff] [blame] | 263 | KS_ENDPOINT_V3="$KEYSTONE_SERVICE_URI/v3" |
Steven Hardy | dd029da | 2014-02-24 18:09:10 +0000 | [diff] [blame] | 264 | |
Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame^] | 265 | D_ID=$(openstack --os-token $OS_TOKEN --os-url=$KS_ENDPOINT_V3 \ |
| 266 | --os-identity-api-version=3 domain list | grep ' heat ' | get_field 1) |
| 267 | |
| 268 | if [[ -z "$D_ID" ]]; then |
| 269 | D_ID=$(openstack --os-token $OS_TOKEN --os-url=$KS_ENDPOINT_V3 \ |
| 270 | --os-identity-api-version=3 domain create heat \ |
| 271 | --description "Owns users and projects created by heat" \ |
| 272 | | grep ' id ' | get_field 2) |
| 273 | iniset $HEAT_CONF DEFAULT stack_user_domain ${D_ID} |
| 274 | |
| 275 | openstack --os-token $OS_TOKEN --os-url=$KS_ENDPOINT_V3 \ |
| 276 | --os-identity-api-version=3 user create --password $SERVICE_PASSWORD \ |
| 277 | --domain $D_ID heat_domain_admin \ |
| 278 | --description "Manages users and projects created by heat" |
| 279 | openstack --os-token $OS_TOKEN --os-url=$KS_ENDPOINT_V3 \ |
| 280 | --os-identity-api-version=3 role add \ |
| 281 | --user heat_domain_admin --domain ${D_ID} admin |
| 282 | iniset $HEAT_CONF DEFAULT stack_domain_admin heat_domain_admin |
| 283 | iniset $HEAT_CONF DEFAULT stack_domain_admin_password $SERVICE_PASSWORD |
| 284 | fi |
Steve Baker | 16aca8a | 2014-03-11 14:01:57 +1300 | [diff] [blame] | 285 | fi |
Steven Hardy | 33d1f86 | 2014-02-13 15:00:33 +0000 | [diff] [blame] | 286 | } |
| 287 | |
Dean Troyer | 7903b79 | 2012-09-13 17:16:12 -0500 | [diff] [blame] | 288 | # Restore xtrace |
| 289 | $XTRACE |
Sean Dague | 584d90e | 2013-03-29 14:34:53 -0400 | [diff] [blame] | 290 | |
Adam Spiers | 6a5aa7c | 2013-10-24 11:27:02 +0100 | [diff] [blame] | 291 | # Tell emacs to use shell-script-mode |
| 292 | ## Local variables: |
| 293 | ## mode: shell-script |
| 294 | ## End: |