Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | # |
Dean Troyer | 608bb12 | 2012-01-10 14:43:17 -0600 | [diff] [blame] | 3 | # configure_tempest.sh - Build a tempest configuration file from devstack |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 4 | |
| 5 | function usage { |
Dean Troyer | 608bb12 | 2012-01-10 14:43:17 -0600 | [diff] [blame] | 6 | echo "$0 - Build tempest.conf" |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 7 | echo "" |
Dean Troyer | 44d8f8f | 2011-11-23 23:21:06 -0600 | [diff] [blame] | 8 | echo "Usage: $0 [configdir]" |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 9 | exit 1 |
| 10 | } |
| 11 | |
Dean Troyer | 44d8f8f | 2011-11-23 23:21:06 -0600 | [diff] [blame] | 12 | if [ "$1" = "-h" ]; then |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 13 | usage |
| 14 | fi |
| 15 | |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 16 | # Clean up any resources that may be in use |
| 17 | cleanup() { |
| 18 | set +o errexit |
| 19 | |
| 20 | # Mop up temporary files |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame] | 21 | if [ -n "$CONFIG_INI_TMP" -a -e "$CONFIG_INI_TMP" ]; then |
| 22 | rm -f $CONFIG_INI_TMP |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 23 | fi |
| 24 | |
| 25 | # Kill ourselves to signal any calling process |
| 26 | trap 2; kill -2 $$ |
| 27 | } |
| 28 | |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame] | 29 | trap cleanup SIGHUP SIGINT SIGTERM SIGQUIT EXIT |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 30 | |
| 31 | # Keep track of the current directory |
| 32 | TOOLS_DIR=$(cd $(dirname "$0") && pwd) |
Dean Troyer | 7f9aa71 | 2012-01-31 12:11:56 -0600 | [diff] [blame] | 33 | TOP_DIR=$(cd $TOOLS_DIR/..; pwd) |
| 34 | |
| 35 | # Import common functions |
| 36 | . $TOP_DIR/functions |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 37 | |
| 38 | # Abort if localrc is not set |
| 39 | if [ ! -e $TOP_DIR/localrc ]; then |
| 40 | echo "You must have a localrc with ALL necessary passwords and configuration defined before proceeding." |
| 41 | echo "See stack.sh for required passwords." |
| 42 | exit 1 |
| 43 | fi |
| 44 | |
| 45 | # Source params |
| 46 | source ./stackrc |
| 47 | |
Dean Troyer | 608bb12 | 2012-01-10 14:43:17 -0600 | [diff] [blame] | 48 | # Set defaults not configured by stackrc |
| 49 | TENANT=${TENANT:-admin} |
| 50 | USERNAME=${USERNAME:-admin} |
| 51 | IDENTITY_HOST=${IDENTITY_HOST:-$HOST_IP} |
| 52 | IDENTITY_PORT=${IDENTITY_PORT:-5000} |
| 53 | IDENTITY_API_VERSION=${IDENTITY_API_VERSION:-2.0} |
| 54 | |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 55 | # Where Openstack code lives |
| 56 | DEST=${DEST:-/opt/stack} |
| 57 | |
Dean Troyer | 608bb12 | 2012-01-10 14:43:17 -0600 | [diff] [blame] | 58 | TEMPEST_DIR=$DEST/tempest |
Dean Troyer | 44d8f8f | 2011-11-23 23:21:06 -0600 | [diff] [blame] | 59 | |
Dean Troyer | 608bb12 | 2012-01-10 14:43:17 -0600 | [diff] [blame] | 60 | CONFIG_DIR=${1:-$TEMPEST_DIR/etc} |
Dean Troyer | 44d8f8f | 2011-11-23 23:21:06 -0600 | [diff] [blame] | 61 | CONFIG_INI=$CONFIG_DIR/config.ini |
Dean Troyer | 608bb12 | 2012-01-10 14:43:17 -0600 | [diff] [blame] | 62 | TEMPEST_CONF=$CONFIG_DIR/tempest.conf |
Dean Troyer | 44d8f8f | 2011-11-23 23:21:06 -0600 | [diff] [blame] | 63 | |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame] | 64 | if [ ! -f $DEST/.ramdisk ]; then |
| 65 | # Process network configuration vars |
| 66 | GUEST_NETWORK=${GUEST_NETWORK:-1} |
| 67 | GUEST_RECREATE_NET=${GUEST_RECREATE_NET:-yes} |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 68 | |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame] | 69 | GUEST_IP=${GUEST_IP:-192.168.$GUEST_NETWORK.50} |
| 70 | GUEST_CIDR=${GUEST_CIDR:-$GUEST_IP/24} |
| 71 | GUEST_NETMASK=${GUEST_NETMASK:-255.255.255.0} |
| 72 | GUEST_GATEWAY=${GUEST_GATEWAY:-192.168.$GUEST_NETWORK.1} |
| 73 | GUEST_MAC=${GUEST_MAC:-"02:16:3e:07:69:`printf '%02X' $GUEST_NETWORK`"} |
| 74 | GUEST_RAM=${GUEST_RAM:-1524288} |
| 75 | GUEST_CORES=${GUEST_CORES:-1} |
| 76 | fi |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 77 | |
| 78 | # Use the GUEST_IP unless an explicit IP is set by ``HOST_IP`` |
| 79 | HOST_IP=${HOST_IP:-$GUEST_IP} |
| 80 | # Use the first IP if HOST_IP still is not set |
| 81 | if [ ! -n "$HOST_IP" ]; then |
| 82 | HOST_IP=`LC_ALL=C /sbin/ifconfig | grep -m 1 'inet addr:'| cut -d: -f2 | awk '{print $1}'` |
| 83 | fi |
| 84 | |
| 85 | RABBIT_HOST=${RABBIT_HOST:-localhost} |
| 86 | |
| 87 | # Glance connection info. Note the port must be specified. |
| 88 | GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-$HOST_IP:9292} |
| 89 | set `echo $GLANCE_HOSTPORT | tr ':' ' '` |
| 90 | GLANCE_HOST=$1 |
| 91 | GLANCE_PORT=$2 |
| 92 | |
Dean Troyer | 3320c55 | 2011-11-23 23:19:10 -0600 | [diff] [blame] | 93 | # Set up downloaded images |
| 94 | # Defaults to use first image |
| 95 | |
| 96 | IMAGE_DIR="" |
Dean Troyer | 608bb12 | 2012-01-10 14:43:17 -0600 | [diff] [blame] | 97 | IMAGE_NAME="" |
Dean Troyer | 3320c55 | 2011-11-23 23:19:10 -0600 | [diff] [blame] | 98 | for imagedir in $TOP_DIR/files/images/*; do |
| 99 | KERNEL="" |
| 100 | RAMDISK="" |
| 101 | IMAGE="" |
| 102 | IMAGE_RAMDISK="" |
| 103 | KERNEL=$(for f in "$imagedir/"*-vmlinuz*; do |
| 104 | [ -f "$f" ] && echo "$f" && break; done; true) |
| 105 | [ -n "$KERNEL" ] && ln -sf $KERNEL $imagedir/kernel |
| 106 | RAMDISK=$(for f in "$imagedir/"*-initrd*; do |
| 107 | [ -f "$f" ] && echo "$f" && break; done; true) |
| 108 | [ -n "$RAMDISK" ] && ln -sf $RAMDISK $imagedir/ramdisk && \ |
| 109 | IMAGE_RAMDISK="ari_location = $imagedir/ramdisk" |
| 110 | IMAGE=$(for f in "$imagedir/"*.img; do |
| 111 | [ -f "$f" ] && echo "$f" && break; done; true) |
| 112 | if [ -n "$IMAGE" ]; then |
| 113 | ln -sf $IMAGE $imagedir/disk |
| 114 | # Save the first image directory that contains a disk image link |
| 115 | if [ -z "$IMAGE_DIR" ]; then |
| 116 | IMAGE_DIR=$imagedir |
Dean Troyer | 608bb12 | 2012-01-10 14:43:17 -0600 | [diff] [blame] | 117 | IMAGE_NAME=$(basename ${IMAGE%.img}) |
Dean Troyer | 3320c55 | 2011-11-23 23:19:10 -0600 | [diff] [blame] | 118 | fi |
| 119 | fi |
| 120 | done |
Dean Troyer | 608bb12 | 2012-01-10 14:43:17 -0600 | [diff] [blame] | 121 | if [[ -n "$IMAGE_NAME" ]]; then |
| 122 | # Get the image UUID |
| 123 | IMAGE_UUID=$(nova image-list | grep " $IMAGE_NAME " | cut -d'|' -f2) |
| 124 | # Strip spaces off |
| 125 | IMAGE_UUID=$(echo $IMAGE_UUID) |
| 126 | fi |
Dean Troyer | 3320c55 | 2011-11-23 23:19:10 -0600 | [diff] [blame] | 127 | |
Jay Pipes | d01325f | 2012-04-04 16:21:33 -0400 | [diff] [blame^] | 128 | # Create tempest.conf from tempest.conf.tpl |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame] | 129 | |
Dean Troyer | 608bb12 | 2012-01-10 14:43:17 -0600 | [diff] [blame] | 130 | if [[ ! -r $TEMPEST_CONF ]]; then |
Jay Pipes | d01325f | 2012-04-04 16:21:33 -0400 | [diff] [blame^] | 131 | cp $TEMPEST_CONF.tpl $TEMPEST_CONF |
Dean Troyer | 608bb12 | 2012-01-10 14:43:17 -0600 | [diff] [blame] | 132 | fi |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame] | 133 | |
Jay Pipes | d01325f | 2012-04-04 16:21:33 -0400 | [diff] [blame^] | 134 | IDENTITY_USE_SSL=${IDENTITY_USE_SSL:-False} |
| 135 | IDENTITY_PORT=${IDENTITY_PORT:-5000} |
| 136 | IDENTITY_API_VERSION={$IDENTITY_API_VERSION:-v2.0} # Note: need v for now... |
| 137 | # TODO(jaypipes): This is dumb and needs to be removed |
| 138 | # from the Tempest configuration file entirely... |
| 139 | IDENTITY_PATH=${IDENTITY_PATH:-tokens} |
| 140 | IDENTITY_STRATEGY=${IDENTITY_STRATEGY:-keystone} |
| 141 | |
| 142 | # We use regular, non-admin users in Tempest for the USERNAME |
| 143 | # substitutions and use ADMIN_USERNAME et al for the admin stuff. |
| 144 | # OS_USERNAME et all should be defined in openrc. |
| 145 | OS_USERNAME=${OS_USERNAME:-demo} |
| 146 | OS_TENANT_NAME=${OS_TENANT_NAME:-demo} |
| 147 | OS_PASSWORD=${OS_PASSWORD:-secrete} |
| 148 | |
| 149 | # TODO(jaypipes): Support multiple regular user accounts instead |
| 150 | # of using the same regular user account for the alternate user... |
| 151 | ALT_USERNAME=$OS_USERNAME |
| 152 | ALT_PASSWORD=$OS_PASSWORD |
| 153 | ALT_TENANT_NAME=$OS_TENANT_NAME |
| 154 | |
| 155 | # TODO(jaypipes): Support multiple images instead of plopping |
| 156 | # the IMAGE_UUID into both the image_ref and image_ref_alt slots |
| 157 | IMAGE_UUID_ALT=$IMAGE_UUID |
| 158 | |
| 159 | # TODO(jaypipes): Support configurable flavor refs here... |
| 160 | FLAVOR_REF=1 |
| 161 | FLAVOR_REF_ALT=2 |
| 162 | |
| 163 | ADMIN_USERNAME={$ADMIN_USERNAME:-admin} |
| 164 | ADMIN_PASSWORD={$ADMIN_PASSWORD:-secrete} |
| 165 | ADMIN_TENANT_NAME={$ADMIN_TENANT:-admin} |
| 166 | |
| 167 | # Do any of the following need to be configurable? |
| 168 | COMPUTE_CATALOG_TYPE=compute |
| 169 | COMPUTE_CREATE_IMAGE_ENABLED=True |
| 170 | COMPUTE_RESIZE_AVAILABLE=True |
| 171 | COMPUTE_LOG_LEVEL=ERROR |
| 172 | |
Dean Troyer | 608bb12 | 2012-01-10 14:43:17 -0600 | [diff] [blame] | 173 | sed -e " |
Jay Pipes | d01325f | 2012-04-04 16:21:33 -0400 | [diff] [blame^] | 174 | s,%IDENTITY_USE_SSL%,$IDENTITY_USE_SSL,g; |
| 175 | s,%IDENTITY_HOST%,$HOST_IP,g; |
| 176 | s,%IDENTITY_PORT%,$IDENTITY_PORT,g; |
| 177 | s,%IDENTITY_API_VERSION%,$IDENTITY_API_VERSION,g; |
| 178 | s,%IDENTITY_PATH%,$IDENTITY_PATH,g; |
| 179 | s,%IDENTITY_STRATEGY%,$IDENTITY_STRATEGY,g; |
| 180 | s,%USERNAME%,$OS_USERNAME,g; |
| 181 | s,%PASSWORD%,$OS_PASSWORD,g; |
| 182 | s,%TENANT_NAME%,$OS_TENANT_NAME,g; |
| 183 | s,%ALT_USERNAME%,$ALT_USERNAME,g; |
| 184 | s,%ALT_PASSWORD%,$ALT_PASSWORD,g; |
| 185 | s,%ALT_TENANT_NAME%,$ALT_TENANT_NAME,g; |
| 186 | s,%COMPUTE_CATALOG_TYPE%,$COMPUTE_CATALOG_TYPE,g; |
| 187 | s,%COMPUTE_CREATE_IMAGE_ENABLED%,$COMPUTE_CREATE_IMAGE_ENABLED,g; |
| 188 | s,%COMPUTE_RESIZE_AVAILABLE%,$COMPUTE_RESIZE_AVAILABLE,g; |
| 189 | s,%COMPUTE_LOG_LEVEL%,$COMPUTE_LOG_LEVEL,g; |
| 190 | s,%IMAGE_ID%,$IMAGE_UUID,g; |
| 191 | s,%IMAGE_ID_ALT%,$IMAGE_UUID_ALT,g; |
| 192 | s,%FLAVOR_REF%,$FLAVOR_REF,g; |
| 193 | s,%FLAVOR_REF_ALT%,$FLAVOR_REF_ALT,g; |
| 194 | s,%ADMIN_USERNAME%,$ADMIN_USERNAME,g; |
| 195 | s,%ADMIN_PASSWORD%,$ADMIN_PASSWORD,g; |
| 196 | s,%ADMIN_TENANT_NAME%,$ADMIN_TENANT_NAME,g; |
Dean Troyer | 608bb12 | 2012-01-10 14:43:17 -0600 | [diff] [blame] | 197 | " -i $TEMPEST_CONF |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame] | 198 | |
| 199 | # Create config.ini |
| 200 | |
| 201 | CONFIG_INI_TMP=$(mktemp $CONFIG_INI.XXXXXX) |
Dean Troyer | ff0ed1d | 2011-11-05 16:15:11 -0500 | [diff] [blame] | 202 | if [ "$UPLOAD_LEGACY_TTY" ]; then |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame] | 203 | cat >$CONFIG_INI_TMP <<EOF |
Dean Troyer | ff0ed1d | 2011-11-05 16:15:11 -0500 | [diff] [blame] | 204 | [environment] |
Dean Troyer | 3320c55 | 2011-11-23 23:19:10 -0600 | [diff] [blame] | 205 | aki_location = $TOP_DIR/files/images/aki-tty/image |
| 206 | ari_location = $TOP_DIR/files/images/ari-tty/image |
| 207 | ami_location = $TOP_DIR/files/images/ami-tty/image |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame] | 208 | image_ref = 3 |
| 209 | image_ref_alt = 3 |
Dean Troyer | ff0ed1d | 2011-11-05 16:15:11 -0500 | [diff] [blame] | 210 | flavor_ref = 1 |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame] | 211 | flavor_ref_alt = 2 |
| 212 | |
| 213 | [glance] |
| 214 | host = $GLANCE_HOST |
| 215 | apiver = v1 |
| 216 | port = $GLANCE_PORT |
| 217 | image_id = 3 |
| 218 | image_id_alt = 3 |
| 219 | tenant_id = 1 |
Dean Troyer | ff0ed1d | 2011-11-05 16:15:11 -0500 | [diff] [blame] | 220 | EOF |
| 221 | else |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame] | 222 | cat >$CONFIG_INI_TMP <<EOF |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 223 | [environment] |
Dean Troyer | 3320c55 | 2011-11-23 23:19:10 -0600 | [diff] [blame] | 224 | aki_location = $IMAGE_DIR/kernel |
| 225 | ami_location = $IMAGE_DIR/disk |
| 226 | $IMAGE_RAMDISK |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame] | 227 | image_ref = 2 |
| 228 | image_ref_alt = 2 |
Dean Troyer | ff0ed1d | 2011-11-05 16:15:11 -0500 | [diff] [blame] | 229 | flavor_ref = 1 |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame] | 230 | flavor_ref_alt = 2 |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 231 | |
| 232 | [glance] |
| 233 | host = $GLANCE_HOST |
Dean Troyer | a0e2948 | 2011-11-04 19:44:06 -0500 | [diff] [blame] | 234 | apiver = v1 |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 235 | port = $GLANCE_PORT |
Dean Troyer | 3320c55 | 2011-11-23 23:19:10 -0600 | [diff] [blame] | 236 | image_id = 2 |
| 237 | image_id_alt = 2 |
Dean Troyer | a0e2948 | 2011-11-04 19:44:06 -0500 | [diff] [blame] | 238 | tenant_id = 1 |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame] | 239 | EOF |
| 240 | fi |
| 241 | |
| 242 | cat >>$CONFIG_INI_TMP <<EOF |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 243 | |
| 244 | [keystone] |
| 245 | service_host = $HOST_IP |
| 246 | service_port = 5000 |
Dean Troyer | 5db287c | 2011-11-02 21:21:36 -0500 | [diff] [blame] | 247 | apiver = v2.0 |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 248 | user = admin |
| 249 | password = $ADMIN_PASSWORD |
Dolph Mathews | 50e3229 | 2011-12-15 16:04:49 -0600 | [diff] [blame] | 250 | tenant_name = admin |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 251 | |
| 252 | [nova] |
| 253 | host = $HOST_IP |
| 254 | port = 8774 |
| 255 | apiver = v1.1 |
| 256 | project = admin |
| 257 | user = admin |
Dean Troyer | b0e57cf | 2011-11-04 12:13:43 -0500 | [diff] [blame] | 258 | key = $ADMIN_PASSWORD |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 259 | ssh_timeout = 300 |
| 260 | build_timeout = 300 |
| 261 | flavor_ref = 1 |
| 262 | flavor_ref_alt = 2 |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame] | 263 | multi_node = no |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 264 | |
| 265 | [rabbitmq] |
| 266 | host = $RABBIT_HOST |
| 267 | user = guest |
| 268 | password = $RABBIT_PASSWORD |
| 269 | |
| 270 | [swift] |
| 271 | auth_host = $HOST_IP |
| 272 | auth_port = 443 |
| 273 | auth_prefix = /auth/ |
| 274 | auth_ssl = yes |
| 275 | account = system |
| 276 | username = root |
| 277 | password = password |
| 278 | |
| 279 | EOF |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame] | 280 | mv $CONFIG_INI_TMP $CONFIG_INI |
| 281 | CONFIG_INI_TMP="" |
| 282 | |
| 283 | trap - SIGHUP SIGINT SIGTERM SIGQUIT EXIT |