Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | # |
Dean Troyer | e62ba4d | 2012-06-27 22:07:34 -0500 | [diff] [blame] | 3 | # **configure_tempest.sh** |
| 4 | |
| 5 | # Build a tempest configuration file from devstack |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 6 | |
Jay Pipes | 678a188 | 2012-04-23 10:56:15 -0400 | [diff] [blame] | 7 | echo "**************************************************" |
| 8 | echo "Configuring Tempest" |
| 9 | echo "**************************************************" |
| 10 | |
| 11 | # This script exits on an error so that errors don't compound and you see |
| 12 | # only the first error that occured. |
| 13 | set -o errexit |
| 14 | |
| 15 | # Print the commands being run so that we can see the command that triggers |
| 16 | # an error. It is also useful for following allowing as the install occurs. |
| 17 | set -o xtrace |
| 18 | |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 19 | function usage { |
Dean Troyer | 608bb12 | 2012-01-10 14:43:17 -0600 | [diff] [blame] | 20 | echo "$0 - Build tempest.conf" |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 21 | echo "" |
Jay Pipes | 678a188 | 2012-04-23 10:56:15 -0400 | [diff] [blame] | 22 | echo "Usage: $0" |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 23 | exit 1 |
| 24 | } |
| 25 | |
Dean Troyer | 44d8f8f | 2011-11-23 23:21:06 -0600 | [diff] [blame] | 26 | if [ "$1" = "-h" ]; then |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 27 | usage |
| 28 | fi |
| 29 | |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 30 | # Keep track of the current directory |
| 31 | TOOLS_DIR=$(cd $(dirname "$0") && pwd) |
Dean Troyer | 7f9aa71 | 2012-01-31 12:11:56 -0600 | [diff] [blame] | 32 | TOP_DIR=$(cd $TOOLS_DIR/..; pwd) |
| 33 | |
| 34 | # Import common functions |
| 35 | . $TOP_DIR/functions |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 36 | |
| 37 | # Abort if localrc is not set |
| 38 | if [ ! -e $TOP_DIR/localrc ]; then |
Jay Pipes | 58d34ea | 2012-04-05 17:19:02 -0400 | [diff] [blame] | 39 | echo "You must have a localrc with necessary basic configuration defined before proceeding." |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 40 | exit 1 |
| 41 | fi |
| 42 | |
Jay Pipes | 58d34ea | 2012-04-05 17:19:02 -0400 | [diff] [blame] | 43 | # Abort if openrc is not set |
| 44 | if [ ! -e $TOP_DIR/openrc ]; then |
| 45 | echo "You must have an openrc with ALL necessary passwords and credentials defined before proceeding." |
| 46 | exit 1 |
| 47 | fi |
| 48 | |
Jay Pipes | 678a188 | 2012-04-23 10:56:15 -0400 | [diff] [blame] | 49 | # Source params |
Jay Pipes | 58d34ea | 2012-04-05 17:19:02 -0400 | [diff] [blame] | 50 | source $TOP_DIR/openrc |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 51 | |
| 52 | # Where Openstack code lives |
| 53 | DEST=${DEST:-/opt/stack} |
| 54 | |
Dean Troyer | 608bb12 | 2012-01-10 14:43:17 -0600 | [diff] [blame] | 55 | TEMPEST_DIR=$DEST/tempest |
Jay Pipes | 678a188 | 2012-04-23 10:56:15 -0400 | [diff] [blame] | 56 | CONFIG_DIR=$TEMPEST_DIR/etc |
Dean Troyer | 608bb12 | 2012-01-10 14:43:17 -0600 | [diff] [blame] | 57 | TEMPEST_CONF=$CONFIG_DIR/tempest.conf |
Dean Troyer | 44d8f8f | 2011-11-23 23:21:06 -0600 | [diff] [blame] | 58 | |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 59 | # Use the GUEST_IP unless an explicit IP is set by ``HOST_IP`` |
| 60 | HOST_IP=${HOST_IP:-$GUEST_IP} |
| 61 | # Use the first IP if HOST_IP still is not set |
| 62 | if [ ! -n "$HOST_IP" ]; then |
| 63 | HOST_IP=`LC_ALL=C /sbin/ifconfig | grep -m 1 'inet addr:'| cut -d: -f2 | awk '{print $1}'` |
| 64 | fi |
| 65 | |
Jay Pipes | 678a188 | 2012-04-23 10:56:15 -0400 | [diff] [blame] | 66 | # Glance should already contain images to be used in tempest |
| 67 | # testing. Here we simply look for images stored in Glance |
| 68 | # and set the appropriate variables for use in the tempest config |
| 69 | # We ignore ramdisk and kernel images and set the IMAGE_UUID to |
| 70 | # the first image returned and set IMAGE_UUID_ALT to the second, |
| 71 | # if there is more than one returned... |
Sean Dague | 0f5da00 | 2012-05-03 11:52:55 -0400 | [diff] [blame] | 72 | # ... Also ensure we only take active images, so we don't get snapshots in process |
Jay Pipes | a1c8738 | 2012-04-27 17:46:58 -0400 | [diff] [blame] | 73 | IMAGE_LINES=`glance image-list` |
Jay Pipes | 678a188 | 2012-04-23 10:56:15 -0400 | [diff] [blame] | 74 | IFS="$(echo -e "\n\r")" |
| 75 | IMAGES="" |
| 76 | for line in $IMAGE_LINES; do |
Sean Dague | 0f5da00 | 2012-05-03 11:52:55 -0400 | [diff] [blame] | 77 | IMAGES="$IMAGES `echo $line | grep -v "^\(ID\|+--\)" | grep -v "\(aki\|ari\)" | grep 'active' | cut -d' ' -f2`" |
Dean Troyer | 3320c55 | 2011-11-23 23:19:10 -0600 | [diff] [blame] | 78 | done |
Jay Pipes | 678a188 | 2012-04-23 10:56:15 -0400 | [diff] [blame] | 79 | # Create array of image UUIDs... |
| 80 | IFS=" " |
| 81 | IMAGES=($IMAGES) |
| 82 | NUM_IMAGES=${#IMAGES[*]} |
| 83 | echo "Found $NUM_IMAGES images" |
| 84 | if [[ $NUM_IMAGES -eq 0 ]]; then |
| 85 | echo "Found no valid images to use!" |
| 86 | exit 1 |
| 87 | fi |
| 88 | IMAGE_UUID=${IMAGES[0]} |
| 89 | IMAGE_UUID_ALT=$IMAGE_UUID |
| 90 | if [[ $NUM_IMAGES -gt 1 ]]; then |
| 91 | IMAGE_UUID_ALT=${IMAGES[1]} |
Dean Troyer | 608bb12 | 2012-01-10 14:43:17 -0600 | [diff] [blame] | 92 | fi |
Dean Troyer | 3320c55 | 2011-11-23 23:19:10 -0600 | [diff] [blame] | 93 | |
Jay Pipes | d01325f | 2012-04-04 16:21:33 -0400 | [diff] [blame] | 94 | # Create tempest.conf from tempest.conf.tpl |
Sean Dague | 0f5da00 | 2012-05-03 11:52:55 -0400 | [diff] [blame] | 95 | # copy every time, because the image UUIDS are going to change |
| 96 | cp $TEMPEST_CONF.tpl $TEMPEST_CONF |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame] | 97 | |
Jay Pipes | 3edd5b4 | 2012-07-08 21:04:12 -0400 | [diff] [blame] | 98 | COMPUTE_ADMIN_USERNAME=${ADMIN_USERNAME:-admin} |
| 99 | COMPUTE_ADMIN_PASSWORD=${ADMIN_PASSWORD:-secrete} |
| 100 | COMPUTE_ADMIN_TENANT_NAME=${ADMIN_TENANT:-admin} |
| 101 | |
| 102 | IDENTITY_ADMIN_USERNAME=${ADMIN_USERNAME:-admin} |
| 103 | IDENTITY_ADMIN_PASSWORD=${ADMIN_PASSWORD:-secrete} |
| 104 | IDENTITY_ADMIN_TENANT_NAME=${ADMIN_TENANT:-admin} |
Jay Pipes | b297d2d | 2012-05-10 11:21:22 -0400 | [diff] [blame] | 105 | |
Jay Pipes | d01325f | 2012-04-04 16:21:33 -0400 | [diff] [blame] | 106 | IDENTITY_USE_SSL=${IDENTITY_USE_SSL:-False} |
Jay Pipes | 678a188 | 2012-04-23 10:56:15 -0400 | [diff] [blame] | 107 | IDENTITY_HOST=${IDENTITY_HOST:-127.0.0.1} |
| 108 | IDENTITY_PORT=${IDENTITY_PORT:-5000} |
| 109 | IDENTITY_API_VERSION="v2.0" # Note: need v for now... |
Jay Pipes | d01325f | 2012-04-04 16:21:33 -0400 | [diff] [blame] | 110 | # TODO(jaypipes): This is dumb and needs to be removed |
| 111 | # from the Tempest configuration file entirely... |
| 112 | IDENTITY_PATH=${IDENTITY_PATH:-tokens} |
| 113 | IDENTITY_STRATEGY=${IDENTITY_STRATEGY:-keystone} |
Jay Pipes | 3edd5b4 | 2012-07-08 21:04:12 -0400 | [diff] [blame] | 114 | IDENTITY_CATALOG_TYPE=identity |
Jay Pipes | d01325f | 2012-04-04 16:21:33 -0400 | [diff] [blame] | 115 | |
| 116 | # We use regular, non-admin users in Tempest for the USERNAME |
| 117 | # substitutions and use ADMIN_USERNAME et al for the admin stuff. |
| 118 | # OS_USERNAME et all should be defined in openrc. |
| 119 | OS_USERNAME=${OS_USERNAME:-demo} |
| 120 | OS_TENANT_NAME=${OS_TENANT_NAME:-demo} |
Jay Pipes | b297d2d | 2012-05-10 11:21:22 -0400 | [diff] [blame] | 121 | OS_PASSWORD=${OS_PASSWORD:$ADMIN_PASSWORD} |
Jay Pipes | d01325f | 2012-04-04 16:21:33 -0400 | [diff] [blame] | 122 | |
Jay Pipes | b297d2d | 2012-05-10 11:21:22 -0400 | [diff] [blame] | 123 | # See files/keystone_data.sh where alt_demo user |
| 124 | # and tenant are set up... |
| 125 | ALT_USERNAME=${ALT_USERNAME:-alt_demo} |
| 126 | ALT_TENANT_NAME=${ALT_TENANT_NAME:-alt_demo} |
Jay Pipes | d01325f | 2012-04-04 16:21:33 -0400 | [diff] [blame] | 127 | ALT_PASSWORD=$OS_PASSWORD |
Jay Pipes | d01325f | 2012-04-04 16:21:33 -0400 | [diff] [blame] | 128 | |
Jay Pipes | d01325f | 2012-04-04 16:21:33 -0400 | [diff] [blame] | 129 | # TODO(jaypipes): Support configurable flavor refs here... |
| 130 | FLAVOR_REF=1 |
| 131 | FLAVOR_REF_ALT=2 |
| 132 | |
Jay Pipes | d01325f | 2012-04-04 16:21:33 -0400 | [diff] [blame] | 133 | # Do any of the following need to be configurable? |
| 134 | COMPUTE_CATALOG_TYPE=compute |
| 135 | COMPUTE_CREATE_IMAGE_ENABLED=True |
Jay Pipes | 3edd5b4 | 2012-07-08 21:04:12 -0400 | [diff] [blame] | 136 | COMPUTE_ALLOW_TENANT_ISOLATION=True |
Jay Pipes | 58d34ea | 2012-04-05 17:19:02 -0400 | [diff] [blame] | 137 | COMPUTE_RESIZE_AVAILABLE=False # not supported with QEMU... |
Jay Pipes | d01325f | 2012-04-04 16:21:33 -0400 | [diff] [blame] | 138 | COMPUTE_LOG_LEVEL=ERROR |
Jay Pipes | 3edd5b4 | 2012-07-08 21:04:12 -0400 | [diff] [blame] | 139 | BUILD_INTERVAL=3 |
| 140 | BUILD_TIMEOUT=400 |
| 141 | RUN_SSH=True |
| 142 | SSH_USER=$OS_USERNAME |
| 143 | NETWORK_FOR_SSH=private |
| 144 | IP_VERSION_FOR_SSH=4 |
| 145 | SSH_TIMEOUT=4 |
Jay Pipes | d01325f | 2012-04-04 16:21:33 -0400 | [diff] [blame] | 146 | |
Jay Pipes | c0e1ef5 | 2012-04-30 15:56:13 -0400 | [diff] [blame] | 147 | # Image test configuration options... |
| 148 | IMAGE_HOST=${IMAGE_HOST:-127.0.0.1} |
| 149 | IMAGE_PORT=${IMAGE_PORT:-9292} |
Jay Pipes | 3edd5b4 | 2012-07-08 21:04:12 -0400 | [diff] [blame] | 150 | IMAGE_API_VERSION=1 |
| 151 | IMAGE_CATALOG_TYPE=image |
| 152 | |
| 153 | # Network API test configuration |
| 154 | NETWORK_CATALOG_TYPE=network |
| 155 | NETWORK_API_VERSION=2.0 |
Jay Pipes | c0e1ef5 | 2012-04-30 15:56:13 -0400 | [diff] [blame] | 156 | |
Dean Troyer | 608bb12 | 2012-01-10 14:43:17 -0600 | [diff] [blame] | 157 | sed -e " |
Jay Pipes | d01325f | 2012-04-04 16:21:33 -0400 | [diff] [blame] | 158 | s,%IDENTITY_USE_SSL%,$IDENTITY_USE_SSL,g; |
Jay Pipes | 678a188 | 2012-04-23 10:56:15 -0400 | [diff] [blame] | 159 | s,%IDENTITY_HOST%,$IDENTITY_HOST,g; |
Jay Pipes | d01325f | 2012-04-04 16:21:33 -0400 | [diff] [blame] | 160 | s,%IDENTITY_PORT%,$IDENTITY_PORT,g; |
Jay Pipes | 678a188 | 2012-04-23 10:56:15 -0400 | [diff] [blame] | 161 | s,%IDENTITY_API_VERSION%,$IDENTITY_API_VERSION,g; |
Jay Pipes | d01325f | 2012-04-04 16:21:33 -0400 | [diff] [blame] | 162 | s,%IDENTITY_PATH%,$IDENTITY_PATH,g; |
| 163 | s,%IDENTITY_STRATEGY%,$IDENTITY_STRATEGY,g; |
Jay Pipes | 3edd5b4 | 2012-07-08 21:04:12 -0400 | [diff] [blame] | 164 | s,%IDENTITY_CATALOG_TYPE%,$IDENTITY_CATALOG_TYPE,g; |
Jay Pipes | d01325f | 2012-04-04 16:21:33 -0400 | [diff] [blame] | 165 | s,%USERNAME%,$OS_USERNAME,g; |
| 166 | s,%PASSWORD%,$OS_PASSWORD,g; |
| 167 | s,%TENANT_NAME%,$OS_TENANT_NAME,g; |
| 168 | s,%ALT_USERNAME%,$ALT_USERNAME,g; |
| 169 | s,%ALT_PASSWORD%,$ALT_PASSWORD,g; |
| 170 | s,%ALT_TENANT_NAME%,$ALT_TENANT_NAME,g; |
| 171 | s,%COMPUTE_CATALOG_TYPE%,$COMPUTE_CATALOG_TYPE,g; |
Jay Pipes | 3edd5b4 | 2012-07-08 21:04:12 -0400 | [diff] [blame] | 172 | s,%COMPUTE_ALLOW_TENANT_ISOLATION%,$COMPUTE_ALLOW_TENANT_ISOLATION,g; |
Jay Pipes | d01325f | 2012-04-04 16:21:33 -0400 | [diff] [blame] | 173 | s,%COMPUTE_CREATE_IMAGE_ENABLED%,$COMPUTE_CREATE_IMAGE_ENABLED,g; |
| 174 | s,%COMPUTE_RESIZE_AVAILABLE%,$COMPUTE_RESIZE_AVAILABLE,g; |
| 175 | s,%COMPUTE_LOG_LEVEL%,$COMPUTE_LOG_LEVEL,g; |
Jay Pipes | 58d34ea | 2012-04-05 17:19:02 -0400 | [diff] [blame] | 176 | s,%BUILD_INTERVAL%,$BUILD_INTERVAL,g; |
| 177 | s,%BUILD_TIMEOUT%,$BUILD_TIMEOUT,g; |
Jay Pipes | 3edd5b4 | 2012-07-08 21:04:12 -0400 | [diff] [blame] | 178 | s,%RUN_SSH%,$RUN_SSH,g; |
| 179 | s,%SSH_USER%,$SSH_USER,g; |
| 180 | s,%NETWORK_FOR_SSH%,$NETWORK_FOR_SSH,g; |
| 181 | s,%IP_VERSION_FOR_SSH%,$IP_VERSION_FOR_SSH,g; |
| 182 | s,%SSH_TIMEOUT%,$SSH_TIMEOUT,g; |
Jay Pipes | d01325f | 2012-04-04 16:21:33 -0400 | [diff] [blame] | 183 | s,%IMAGE_ID%,$IMAGE_UUID,g; |
| 184 | s,%IMAGE_ID_ALT%,$IMAGE_UUID_ALT,g; |
| 185 | s,%FLAVOR_REF%,$FLAVOR_REF,g; |
| 186 | s,%FLAVOR_REF_ALT%,$FLAVOR_REF_ALT,g; |
Jay Pipes | c0e1ef5 | 2012-04-30 15:56:13 -0400 | [diff] [blame] | 187 | s,%IMAGE_HOST%,$IMAGE_HOST,g; |
| 188 | s,%IMAGE_PORT%,$IMAGE_PORT,g; |
| 189 | s,%IMAGE_API_VERSION%,$IMAGE_API_VERSION,g; |
Jay Pipes | 3edd5b4 | 2012-07-08 21:04:12 -0400 | [diff] [blame] | 190 | s,%IMAGE_CATALOG_TYPE%,$IMAGE_CATALOG_TYPE,g; |
| 191 | s,%COMPUTE_ADMIN_USERNAME%,$COMPUTE_ADMIN_USERNAME,g; |
| 192 | s,%COMPUTE_ADMIN_PASSWORD%,$COMPUTE_ADMIN_PASSWORD,g; |
| 193 | s,%COMPUTE_ADMIN_TENANT_NAME%,$COMPUTE_ADMIN_TENANT_NAME,g; |
| 194 | s,%IDENTITY_ADMIN_USERNAME%,$IDENTITY_ADMIN_USERNAME,g; |
| 195 | s,%IDENTITY_ADMIN_PASSWORD%,$IDENTITY_ADMIN_PASSWORD,g; |
| 196 | s,%IDENTITY_ADMIN_TENANT_NAME%,$IDENTITY_ADMIN_TENANT_NAME,g; |
| 197 | s,%NETWORK_CATALOG_TYPE%,$NETWORK_CATALOG_TYPE,g; |
| 198 | s,%NETWORK_API_VERSION%,$NETWORK_API_VERSION,g; |
Dean Troyer | 608bb12 | 2012-01-10 14:43:17 -0600 | [diff] [blame] | 199 | " -i $TEMPEST_CONF |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame] | 200 | |
Jay Pipes | 58d34ea | 2012-04-05 17:19:02 -0400 | [diff] [blame] | 201 | echo "Created tempest configuration file:" |
| 202 | cat $TEMPEST_CONF |
Jay Pipes | 58d34ea | 2012-04-05 17:19:02 -0400 | [diff] [blame] | 203 | |
Jay Pipes | 678a188 | 2012-04-23 10:56:15 -0400 | [diff] [blame] | 204 | echo "\n" |
| 205 | echo "**************************************************" |
| 206 | echo "Finished Configuring Tempest" |
| 207 | echo "**************************************************" |