Browse code

Allow heat standalone to work devstack stack

For functional testing of heat-standalone it is desirable for
heat to orchestrate on the rest of the cloud which is brought up
by devstack. This change makes the following changes to enable
this when HEAT_STANDALONE=True:

- Don't register the orchestration endpoint or create any dedicated
heat accounts
- Install and configure the heat keystone V2 auth plugin instead of
the default v3
- set heat.conf [clients_heat] url so that heat can call its own
API when no orchestration endpoint is registered
- Modify create_userrc.sh to set the required heat client env
variables to work with the standalone heat

Change-Id: Idae33bf1a9d550e2575e6390d2d7c8d3b94c401d

Steve Baker authored on 2014/09/23 14:10:39
Showing 3 changed files
... ...
@@ -40,6 +40,8 @@ HEAT_CONF=$HEAT_CONF_DIR/heat.conf
40 40
 HEAT_ENV_DIR=$HEAT_CONF_DIR/environment.d
41 41
 HEAT_TEMPLATES_DIR=$HEAT_CONF_DIR/templates
42 42
 HEAT_STACK_DOMAIN=`trueorfalse True $HEAT_STACK_DOMAIN`
43
+HEAT_API_HOST=${HEAT_API_HOST:-$HOST_IP}
44
+HEAT_API_PORT=${HEAT_API_PORT:-8004}
43 45
 
44 46
 # other default options
45 47
 HEAT_DEFERRED_AUTH=${HEAT_DEFERRED_AUTH:-trusts}
... ...
@@ -69,6 +71,9 @@ function cleanup_heat {
69 69
 # configure_heat() - Set config files, create data dirs, etc
70 70
 function configure_heat {
71 71
     setup_develop $HEAT_DIR
72
+    if [[ "$HEAT_STANDALONE" = "True" ]]; then
73
+        setup_develop $HEAT_DIR/contrib/heat_keystoneclient_v2
74
+    fi
72 75
 
73 76
     if [[ ! -d $HEAT_CONF_DIR ]]; then
74 77
         sudo mkdir -p $HEAT_CONF_DIR
... ...
@@ -83,8 +88,6 @@ function configure_heat {
83 83
     HEAT_ENGINE_PORT=${HEAT_ENGINE_PORT:-8001}
84 84
     HEAT_API_CW_HOST=${HEAT_API_CW_HOST:-$HOST_IP}
85 85
     HEAT_API_CW_PORT=${HEAT_API_CW_PORT:-8003}
86
-    HEAT_API_HOST=${HEAT_API_HOST:-$HOST_IP}
87
-    HEAT_API_PORT=${HEAT_API_PORT:-8004}
88 86
     HEAT_API_PASTE_FILE=$HEAT_CONF_DIR/api-paste.ini
89 87
     HEAT_POLICY_FILE=$HEAT_CONF_DIR/policy.json
90 88
 
... ...
@@ -127,7 +130,11 @@ function configure_heat {
127 127
     iniset $HEAT_CONF ec2authtoken auth_uri $KEYSTONE_SERVICE_URI/v2.0
128 128
 
129 129
     # paste_deploy
130
-    [[ "$HEAT_STANDALONE" = "True" ]] && iniset $HEAT_CONF paste_deploy flavor standalone
130
+    if [[ "$HEAT_STANDALONE" = "True" ]]; then
131
+        iniset $HEAT_CONF paste_deploy flavor standalone
132
+        iniset $HEAT_CONF DEFAULT keystone_backend heat_keystoneclient_v2.client.KeystoneClientV2
133
+        iniset $HEAT_CONF clients_heat url "http://$HEAT_API_HOST:$HEAT_API_PORT/v1/%(tenant_id)s"
134
+    fi
131 135
 
132 136
     # OpenStack API
133 137
     iniset $HEAT_CONF heat_api bind_port $HEAT_API_PORT
... ...
@@ -988,7 +988,7 @@ if is_service_enabled key; then
988 988
         create_swift_accounts
989 989
     fi
990 990
 
991
-    if is_service_enabled heat; then
991
+    if is_service_enabled heat && [[ "$HEAT_STANDALONE" != "True" ]]; then
992 992
         create_heat_accounts
993 993
     fi
994 994
 
... ...
@@ -1289,6 +1289,10 @@ if is_service_enabled nova && is_service_enabled key; then
1289 1289
         USERRC_PARAMS="$USERRC_PARAMS --os-cacert $SSL_BUNDLE_FILE"
1290 1290
     fi
1291 1291
 
1292
+    if [[ "$HEAT_STANDALONE" = "True" ]]; then
1293
+        USERRC_PARAMS="$USERRC_PARAMS --heat-url http://$HEAT_API_HOST:$HEAT_API_PORT/v1"
1294
+    fi
1295
+
1292 1296
     $TOP_DIR/tools/create_userrc.sh $USERRC_PARAMS
1293 1297
 fi
1294 1298
 
... ...
@@ -37,6 +37,7 @@ Optional Arguments
37 37
 -C <tenant_name> create user and tenant, the specifid tenant will be the user's tenant
38 38
 -r <name> when combined with -C and the (-u) user exists it will be the user's tenant role in the (-C)tenant (default: Member)
39 39
 -p <userpass> password for the user
40
+--heat-url <heat_url>
40 41
 --os-username <username>
41 42
 --os-password <admin password>
42 43
 --os-tenant-name <tenant_name>
... ...
@@ -53,12 +54,13 @@ $0 -P -C mytenant -u myuser -p mypass
53 53
 EOF
54 54
 }
55 55
 
56
-if ! options=$(getopt -o hPAp:u:r:C: -l os-username:,os-password:,os-tenant-name:,os-tenant-id:,os-auth-url:,target-dir:,skip-tenant:,os-cacert:,help,debug -- "$@"); then
56
+if ! options=$(getopt -o hPAp:u:r:C: -l os-username:,os-password:,os-tenant-name:,os-tenant-id:,os-auth-url:,target-dir:,heat-url:,skip-tenant:,os-cacert:,help,debug -- "$@"); then
57 57
     display_help
58 58
     exit 1
59 59
 fi
60 60
 eval set -- $options
61 61
 ADDPASS=""
62
+HEAT_URL=""
62 63
 
63 64
 # The services users usually in the service tenant.
64 65
 # rc files for service users, is out of scope.
... ...
@@ -79,6 +81,7 @@ while [ $# -gt 0 ]; do
79 79
     --os-auth-url) export OS_AUTH_URL=$2; shift ;;
80 80
     --os-cacert) export OS_CACERT=$2; shift ;;
81 81
     --target-dir) ACCOUNT_DIR=$2; shift ;;
82
+    --heat-url) HEAT_URL=$2; shift ;;
82 83
     --debug) set -o xtrace ;;
83 84
     -u) MODE=${MODE:-one};  USER_NAME=$2; shift ;;
84 85
     -p) USER_PASS=$2; shift ;;
... ...
@@ -209,6 +212,10 @@ EOF
209 209
     if [ -n "$ADDPASS" ]; then
210 210
         echo "export OS_PASSWORD=\"$user_passwd\"" >>"$rcfile"
211 211
     fi
212
+    if [ -n "$HEAT_URL" ]; then
213
+        echo "export HEAT_URL=\"$HEAT_URL/$tenant_id\"" >>"$rcfile"
214
+        echo "export OS_NO_CLIENT_AUTH=True" >>"$rcfile"
215
+    fi
212 216
 }
213 217
 
214 218
 #admin users expected