Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | # |
Dean Troyer | f79cc42 | 2011-12-01 10:21:42 -0600 | [diff] [blame] | 3 | # build_ci_config.sh - Build a config.ini for tempest (openstack-integration-tests) |
| 4 | # (https://github.com/openstack/tempest.git) |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 5 | |
| 6 | function usage { |
Dean Troyer | f79cc42 | 2011-12-01 10:21:42 -0600 | [diff] [blame] | 7 | echo "$0 - Build config.ini for tempest" |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 8 | echo "" |
Dean Troyer | 44d8f8f | 2011-11-23 23:21:06 -0600 | [diff] [blame] | 9 | echo "Usage: $0 [configdir]" |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 10 | exit 1 |
| 11 | } |
| 12 | |
Dean Troyer | 44d8f8f | 2011-11-23 23:21:06 -0600 | [diff] [blame] | 13 | if [ "$1" = "-h" ]; then |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 14 | usage |
| 15 | fi |
| 16 | |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 17 | # Clean up any resources that may be in use |
| 18 | cleanup() { |
| 19 | set +o errexit |
| 20 | |
| 21 | # Mop up temporary files |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame] | 22 | if [ -n "$CONFIG_CONF_TMP" -a -e "$CONFIG_CONF_TMP" ]; then |
| 23 | rm -f $CONFIG_CONF_TMP |
| 24 | fi |
| 25 | if [ -n "$CONFIG_INI_TMP" -a -e "$CONFIG_INI_TMP" ]; then |
| 26 | rm -f $CONFIG_INI_TMP |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 27 | fi |
| 28 | |
| 29 | # Kill ourselves to signal any calling process |
| 30 | trap 2; kill -2 $$ |
| 31 | } |
| 32 | |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame] | 33 | trap cleanup SIGHUP SIGINT SIGTERM SIGQUIT EXIT |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 34 | |
| 35 | # Keep track of the current directory |
| 36 | TOOLS_DIR=$(cd $(dirname "$0") && pwd) |
| 37 | TOP_DIR=`cd $TOOLS_DIR/..; pwd` |
| 38 | |
| 39 | # Abort if localrc is not set |
| 40 | if [ ! -e $TOP_DIR/localrc ]; then |
| 41 | echo "You must have a localrc with ALL necessary passwords and configuration defined before proceeding." |
| 42 | echo "See stack.sh for required passwords." |
| 43 | exit 1 |
| 44 | fi |
| 45 | |
| 46 | # Source params |
| 47 | source ./stackrc |
| 48 | |
| 49 | # Where Openstack code lives |
| 50 | DEST=${DEST:-/opt/stack} |
| 51 | |
Dean Troyer | f79cc42 | 2011-12-01 10:21:42 -0600 | [diff] [blame] | 52 | CITEST_DIR=$DEST/tempest |
Dean Troyer | 44d8f8f | 2011-11-23 23:21:06 -0600 | [diff] [blame] | 53 | |
| 54 | CONFIG_DIR=${1:-$CITEST_DIR/etc} |
| 55 | CONFIG_CONF=$CONFIG_DIR/storm.conf |
| 56 | CONFIG_INI=$CONFIG_DIR/config.ini |
| 57 | |
Dean Troyer | 39c2efc | 2011-11-07 16:40:35 -0600 | [diff] [blame] | 58 | DIST_NAME=${DIST_NAME:-oneiric} |
Dean Troyer | b0e57cf | 2011-11-04 12:13:43 -0500 | [diff] [blame] | 59 | |
Dean Troyer | 44d8f8f | 2011-11-23 23:21:06 -0600 | [diff] [blame] | 60 | # git clone only if directory doesn't exist already. Since ``DEST`` might not |
| 61 | # be owned by the installation user, we create the directory and change the |
| 62 | # ownership to the proper user. |
| 63 | function git_clone { |
| 64 | |
| 65 | GIT_REMOTE=$1 |
| 66 | GIT_DEST=$2 |
| 67 | GIT_BRANCH=$3 |
| 68 | |
| 69 | # do a full clone only if the directory doesn't exist |
| 70 | if [ ! -d $GIT_DEST ]; then |
| 71 | git clone $GIT_REMOTE $GIT_DEST |
| 72 | cd $2 |
| 73 | # This checkout syntax works for both branches and tags |
| 74 | git checkout $GIT_BRANCH |
| 75 | elif [[ "$RECLONE" == "yes" ]]; then |
| 76 | # if it does exist then simulate what clone does if asked to RECLONE |
| 77 | cd $GIT_DEST |
| 78 | # set the url to pull from and fetch |
| 79 | git remote set-url origin $GIT_REMOTE |
| 80 | git fetch origin |
| 81 | # remove the existing ignored files (like pyc) as they cause breakage |
| 82 | # (due to the py files having older timestamps than our pyc, so python |
| 83 | # thinks the pyc files are correct using them) |
| 84 | find $GIT_DEST -name '*.pyc' -delete |
| 85 | git checkout -f origin/$GIT_BRANCH |
| 86 | # a local branch might not exist |
| 87 | git branch -D $GIT_BRANCH || true |
| 88 | git checkout -b $GIT_BRANCH |
| 89 | fi |
| 90 | } |
| 91 | |
| 92 | # Install tests and prerequisites |
Dean Troyer | f79cc42 | 2011-12-01 10:21:42 -0600 | [diff] [blame] | 93 | sudo PIP_DOWNLOAD_CACHE=/var/cache/pip pip install --use-mirrors `cat $TOP_DIR/files/pips/tempest` |
Dean Troyer | 44d8f8f | 2011-11-23 23:21:06 -0600 | [diff] [blame] | 94 | |
| 95 | git_clone $CITEST_REPO $CITEST_DIR $CITEST_BRANCH |
| 96 | |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame] | 97 | if [ ! -f $DEST/.ramdisk ]; then |
| 98 | # Process network configuration vars |
| 99 | GUEST_NETWORK=${GUEST_NETWORK:-1} |
| 100 | GUEST_RECREATE_NET=${GUEST_RECREATE_NET:-yes} |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 101 | |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame] | 102 | GUEST_IP=${GUEST_IP:-192.168.$GUEST_NETWORK.50} |
| 103 | GUEST_CIDR=${GUEST_CIDR:-$GUEST_IP/24} |
| 104 | GUEST_NETMASK=${GUEST_NETMASK:-255.255.255.0} |
| 105 | GUEST_GATEWAY=${GUEST_GATEWAY:-192.168.$GUEST_NETWORK.1} |
| 106 | GUEST_MAC=${GUEST_MAC:-"02:16:3e:07:69:`printf '%02X' $GUEST_NETWORK`"} |
| 107 | GUEST_RAM=${GUEST_RAM:-1524288} |
| 108 | GUEST_CORES=${GUEST_CORES:-1} |
| 109 | fi |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 110 | |
| 111 | # Use the GUEST_IP unless an explicit IP is set by ``HOST_IP`` |
| 112 | HOST_IP=${HOST_IP:-$GUEST_IP} |
| 113 | # Use the first IP if HOST_IP still is not set |
| 114 | if [ ! -n "$HOST_IP" ]; then |
| 115 | HOST_IP=`LC_ALL=C /sbin/ifconfig | grep -m 1 'inet addr:'| cut -d: -f2 | awk '{print $1}'` |
| 116 | fi |
| 117 | |
| 118 | RABBIT_HOST=${RABBIT_HOST:-localhost} |
| 119 | |
| 120 | # Glance connection info. Note the port must be specified. |
| 121 | GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-$HOST_IP:9292} |
| 122 | set `echo $GLANCE_HOSTPORT | tr ':' ' '` |
| 123 | GLANCE_HOST=$1 |
| 124 | GLANCE_PORT=$2 |
| 125 | |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame] | 126 | # Create storm.conf |
| 127 | |
| 128 | CONFIG_CONF_TMP=$(mktemp $CONFIG_CONF.XXXXXX) |
| 129 | cat >$CONFIG_CONF_TMP <<EOF |
| 130 | [nova] |
| 131 | auth_url=http://$HOST_IP:5000/v2.0/tokens |
| 132 | user=admin |
| 133 | api_key=$ADMIN_PASSWORD |
| 134 | tenant_name=admin |
| 135 | ssh_timeout=300 |
| 136 | build_interval=10 |
| 137 | build_timeout=600 |
| 138 | |
| 139 | [environment] |
| 140 | image_ref=3 |
| 141 | image_ref_alt=4 |
| 142 | flavor_ref=1 |
| 143 | flavor_ref_alt=2 |
| 144 | create_image_enabled=true |
| 145 | resize_available=true |
| 146 | authentication=keystone_v2 |
| 147 | EOF |
| 148 | mv $CONFIG_CONF_TMP $CONFIG_CONF |
| 149 | CONFIG_CONF_TMP="" |
| 150 | |
| 151 | # Create config.ini |
| 152 | |
| 153 | CONFIG_INI_TMP=$(mktemp $CONFIG_INI.XXXXXX) |
Dean Troyer | ff0ed1d | 2011-11-05 16:15:11 -0500 | [diff] [blame] | 154 | if [ "$UPLOAD_LEGACY_TTY" ]; then |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame] | 155 | cat >$CONFIG_INI_TMP <<EOF |
Dean Troyer | ff0ed1d | 2011-11-05 16:15:11 -0500 | [diff] [blame] | 156 | [environment] |
| 157 | aki_location = $DEST/devstack/files/images/aki-tty/image |
| 158 | ari_location = $DEST/devstack/files/images/ari-tty/image |
| 159 | ami_location = $DEST/devstack/files/images/ami-tty/image |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame] | 160 | image_ref = 3 |
| 161 | image_ref_alt = 3 |
Dean Troyer | ff0ed1d | 2011-11-05 16:15:11 -0500 | [diff] [blame] | 162 | flavor_ref = 1 |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame] | 163 | flavor_ref_alt = 2 |
| 164 | |
| 165 | [glance] |
| 166 | host = $GLANCE_HOST |
| 167 | apiver = v1 |
| 168 | port = $GLANCE_PORT |
| 169 | image_id = 3 |
| 170 | image_id_alt = 3 |
| 171 | tenant_id = 1 |
Dean Troyer | ff0ed1d | 2011-11-05 16:15:11 -0500 | [diff] [blame] | 172 | EOF |
| 173 | else |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame] | 174 | cat >$CONFIG_INI_TMP <<EOF |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 175 | [environment] |
Dean Troyer | b0e57cf | 2011-11-04 12:13:43 -0500 | [diff] [blame] | 176 | aki_location = $DEST/openstack-integration-tests/include/sample_vm/$DIST_NAME-server-cloudimg-amd64-vmlinuz-virtual |
| 177 | #ari_location = $DEST/openstack-integration-tests/include/sample_vm/$DIST_NAME-server-cloudimg-amd64-loader |
| 178 | ami_location = $DEST/openstack-integration-tests/include/sample_vm/$DIST_NAME-server-cloudimg-amd64.img |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame] | 179 | image_ref = 2 |
| 180 | image_ref_alt = 2 |
Dean Troyer | ff0ed1d | 2011-11-05 16:15:11 -0500 | [diff] [blame] | 181 | flavor_ref = 1 |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame] | 182 | flavor_ref_alt = 2 |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 183 | |
| 184 | [glance] |
| 185 | host = $GLANCE_HOST |
Dean Troyer | a0e2948 | 2011-11-04 19:44:06 -0500 | [diff] [blame] | 186 | apiver = v1 |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 187 | port = $GLANCE_PORT |
| 188 | image_id = 1 |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame] | 189 | image_id_alt = 1 |
Dean Troyer | a0e2948 | 2011-11-04 19:44:06 -0500 | [diff] [blame] | 190 | tenant_id = 1 |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame] | 191 | EOF |
| 192 | fi |
| 193 | |
| 194 | cat >>$CONFIG_INI_TMP <<EOF |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 195 | |
| 196 | [keystone] |
| 197 | service_host = $HOST_IP |
| 198 | service_port = 5000 |
Dean Troyer | 5db287c | 2011-11-02 21:21:36 -0500 | [diff] [blame] | 199 | apiver = v2.0 |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 200 | user = admin |
| 201 | password = $ADMIN_PASSWORD |
Dolph Mathews | 50e3229 | 2011-12-15 16:04:49 -0600 | [diff] [blame^] | 202 | tenant_name = admin |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 203 | |
| 204 | [nova] |
| 205 | host = $HOST_IP |
| 206 | port = 8774 |
| 207 | apiver = v1.1 |
| 208 | project = admin |
| 209 | user = admin |
Dean Troyer | b0e57cf | 2011-11-04 12:13:43 -0500 | [diff] [blame] | 210 | key = $ADMIN_PASSWORD |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 211 | ssh_timeout = 300 |
| 212 | build_timeout = 300 |
| 213 | flavor_ref = 1 |
| 214 | flavor_ref_alt = 2 |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame] | 215 | multi_node = no |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 216 | |
| 217 | [rabbitmq] |
| 218 | host = $RABBIT_HOST |
| 219 | user = guest |
| 220 | password = $RABBIT_PASSWORD |
| 221 | |
| 222 | [swift] |
| 223 | auth_host = $HOST_IP |
| 224 | auth_port = 443 |
| 225 | auth_prefix = /auth/ |
| 226 | auth_ssl = yes |
| 227 | account = system |
| 228 | username = root |
| 229 | password = password |
| 230 | |
| 231 | EOF |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame] | 232 | mv $CONFIG_INI_TMP $CONFIG_INI |
| 233 | CONFIG_INI_TMP="" |
| 234 | |
| 235 | trap - SIGHUP SIGINT SIGTERM SIGQUIT EXIT |