Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | # |
| 3 | # build_ci_config.sh - Build a config.ini for openstack-integration-tests |
| 4 | # (https://github.com/openstack/openstack-integration-tests) |
| 5 | |
| 6 | function usage { |
| 7 | echo "$0 - Build config.ini for openstack-integration-tests" |
| 8 | echo "" |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame^] | 9 | echo "Usage: $0 configdir" |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 10 | exit 1 |
| 11 | } |
| 12 | |
| 13 | if [ ! "$#" -eq "1" ]; then |
| 14 | usage |
| 15 | fi |
| 16 | |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame^] | 17 | CONFIG_DIR=$1 |
| 18 | CONFIG_CONF=$CONFIG_DIR/storm.conf |
| 19 | CONFIG_INI=$CONFIG_DIR/config.ini |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 20 | |
| 21 | # Clean up any resources that may be in use |
| 22 | cleanup() { |
| 23 | set +o errexit |
| 24 | |
| 25 | # Mop up temporary files |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame^] | 26 | if [ -n "$CONFIG_CONF_TMP" -a -e "$CONFIG_CONF_TMP" ]; then |
| 27 | rm -f $CONFIG_CONF_TMP |
| 28 | fi |
| 29 | if [ -n "$CONFIG_INI_TMP" -a -e "$CONFIG_INI_TMP" ]; then |
| 30 | rm -f $CONFIG_INI_TMP |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 31 | fi |
| 32 | |
| 33 | # Kill ourselves to signal any calling process |
| 34 | trap 2; kill -2 $$ |
| 35 | } |
| 36 | |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame^] | 37 | trap cleanup SIGHUP SIGINT SIGTERM SIGQUIT EXIT |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 38 | |
| 39 | # Keep track of the current directory |
| 40 | TOOLS_DIR=$(cd $(dirname "$0") && pwd) |
| 41 | TOP_DIR=`cd $TOOLS_DIR/..; pwd` |
| 42 | |
| 43 | # Abort if localrc is not set |
| 44 | if [ ! -e $TOP_DIR/localrc ]; then |
| 45 | echo "You must have a localrc with ALL necessary passwords and configuration defined before proceeding." |
| 46 | echo "See stack.sh for required passwords." |
| 47 | exit 1 |
| 48 | fi |
| 49 | |
| 50 | # Source params |
| 51 | source ./stackrc |
| 52 | |
| 53 | # Where Openstack code lives |
| 54 | DEST=${DEST:-/opt/stack} |
| 55 | |
Dean Troyer | 39c2efc | 2011-11-07 16:40:35 -0600 | [diff] [blame] | 56 | DIST_NAME=${DIST_NAME:-oneiric} |
Dean Troyer | b0e57cf | 2011-11-04 12:13:43 -0500 | [diff] [blame] | 57 | |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame^] | 58 | if [ ! -f $DEST/.ramdisk ]; then |
| 59 | # Process network configuration vars |
| 60 | GUEST_NETWORK=${GUEST_NETWORK:-1} |
| 61 | GUEST_RECREATE_NET=${GUEST_RECREATE_NET:-yes} |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 62 | |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame^] | 63 | GUEST_IP=${GUEST_IP:-192.168.$GUEST_NETWORK.50} |
| 64 | GUEST_CIDR=${GUEST_CIDR:-$GUEST_IP/24} |
| 65 | GUEST_NETMASK=${GUEST_NETMASK:-255.255.255.0} |
| 66 | GUEST_GATEWAY=${GUEST_GATEWAY:-192.168.$GUEST_NETWORK.1} |
| 67 | GUEST_MAC=${GUEST_MAC:-"02:16:3e:07:69:`printf '%02X' $GUEST_NETWORK`"} |
| 68 | GUEST_RAM=${GUEST_RAM:-1524288} |
| 69 | GUEST_CORES=${GUEST_CORES:-1} |
| 70 | fi |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 71 | |
| 72 | # Use the GUEST_IP unless an explicit IP is set by ``HOST_IP`` |
| 73 | HOST_IP=${HOST_IP:-$GUEST_IP} |
| 74 | # Use the first IP if HOST_IP still is not set |
| 75 | if [ ! -n "$HOST_IP" ]; then |
| 76 | HOST_IP=`LC_ALL=C /sbin/ifconfig | grep -m 1 'inet addr:'| cut -d: -f2 | awk '{print $1}'` |
| 77 | fi |
| 78 | |
| 79 | RABBIT_HOST=${RABBIT_HOST:-localhost} |
| 80 | |
| 81 | # Glance connection info. Note the port must be specified. |
| 82 | GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-$HOST_IP:9292} |
| 83 | set `echo $GLANCE_HOSTPORT | tr ':' ' '` |
| 84 | GLANCE_HOST=$1 |
| 85 | GLANCE_PORT=$2 |
| 86 | |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame^] | 87 | # Create storm.conf |
| 88 | |
| 89 | CONFIG_CONF_TMP=$(mktemp $CONFIG_CONF.XXXXXX) |
| 90 | cat >$CONFIG_CONF_TMP <<EOF |
| 91 | [nova] |
| 92 | auth_url=http://$HOST_IP:5000/v2.0/tokens |
| 93 | user=admin |
| 94 | api_key=$ADMIN_PASSWORD |
| 95 | tenant_name=admin |
| 96 | ssh_timeout=300 |
| 97 | build_interval=10 |
| 98 | build_timeout=600 |
| 99 | |
| 100 | [environment] |
| 101 | image_ref=3 |
| 102 | image_ref_alt=4 |
| 103 | flavor_ref=1 |
| 104 | flavor_ref_alt=2 |
| 105 | create_image_enabled=true |
| 106 | resize_available=true |
| 107 | authentication=keystone_v2 |
| 108 | EOF |
| 109 | mv $CONFIG_CONF_TMP $CONFIG_CONF |
| 110 | CONFIG_CONF_TMP="" |
| 111 | |
| 112 | # Create config.ini |
| 113 | |
| 114 | CONFIG_INI_TMP=$(mktemp $CONFIG_INI.XXXXXX) |
Dean Troyer | ff0ed1d | 2011-11-05 16:15:11 -0500 | [diff] [blame] | 115 | if [ "$UPLOAD_LEGACY_TTY" ]; then |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame^] | 116 | cat >$CONFIG_INI_TMP <<EOF |
Dean Troyer | ff0ed1d | 2011-11-05 16:15:11 -0500 | [diff] [blame] | 117 | [environment] |
| 118 | aki_location = $DEST/devstack/files/images/aki-tty/image |
| 119 | ari_location = $DEST/devstack/files/images/ari-tty/image |
| 120 | ami_location = $DEST/devstack/files/images/ami-tty/image |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame^] | 121 | image_ref = 3 |
| 122 | image_ref_alt = 3 |
Dean Troyer | ff0ed1d | 2011-11-05 16:15:11 -0500 | [diff] [blame] | 123 | flavor_ref = 1 |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame^] | 124 | flavor_ref_alt = 2 |
| 125 | |
| 126 | [glance] |
| 127 | host = $GLANCE_HOST |
| 128 | apiver = v1 |
| 129 | port = $GLANCE_PORT |
| 130 | image_id = 3 |
| 131 | image_id_alt = 3 |
| 132 | tenant_id = 1 |
Dean Troyer | ff0ed1d | 2011-11-05 16:15:11 -0500 | [diff] [blame] | 133 | EOF |
| 134 | else |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame^] | 135 | cat >$CONFIG_INI_TMP <<EOF |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 136 | [environment] |
Dean Troyer | b0e57cf | 2011-11-04 12:13:43 -0500 | [diff] [blame] | 137 | aki_location = $DEST/openstack-integration-tests/include/sample_vm/$DIST_NAME-server-cloudimg-amd64-vmlinuz-virtual |
| 138 | #ari_location = $DEST/openstack-integration-tests/include/sample_vm/$DIST_NAME-server-cloudimg-amd64-loader |
| 139 | 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^] | 140 | image_ref = 2 |
| 141 | image_ref_alt = 2 |
Dean Troyer | ff0ed1d | 2011-11-05 16:15:11 -0500 | [diff] [blame] | 142 | flavor_ref = 1 |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame^] | 143 | flavor_ref_alt = 2 |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 144 | |
| 145 | [glance] |
| 146 | host = $GLANCE_HOST |
Dean Troyer | a0e2948 | 2011-11-04 19:44:06 -0500 | [diff] [blame] | 147 | apiver = v1 |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 148 | port = $GLANCE_PORT |
| 149 | image_id = 1 |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame^] | 150 | image_id_alt = 1 |
Dean Troyer | a0e2948 | 2011-11-04 19:44:06 -0500 | [diff] [blame] | 151 | tenant_id = 1 |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame^] | 152 | EOF |
| 153 | fi |
| 154 | |
| 155 | cat >>$CONFIG_INI_TMP <<EOF |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 156 | |
| 157 | [keystone] |
| 158 | service_host = $HOST_IP |
| 159 | service_port = 5000 |
Dean Troyer | 5db287c | 2011-11-02 21:21:36 -0500 | [diff] [blame] | 160 | apiver = v2.0 |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 161 | user = admin |
| 162 | password = $ADMIN_PASSWORD |
| 163 | tenant_id = 1 |
| 164 | |
| 165 | [nova] |
| 166 | host = $HOST_IP |
| 167 | port = 8774 |
| 168 | apiver = v1.1 |
| 169 | project = admin |
| 170 | user = admin |
Dean Troyer | b0e57cf | 2011-11-04 12:13:43 -0500 | [diff] [blame] | 171 | key = $ADMIN_PASSWORD |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 172 | ssh_timeout = 300 |
| 173 | build_timeout = 300 |
| 174 | flavor_ref = 1 |
| 175 | flavor_ref_alt = 2 |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame^] | 176 | multi_node = no |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 177 | |
| 178 | [rabbitmq] |
| 179 | host = $RABBIT_HOST |
| 180 | user = guest |
| 181 | password = $RABBIT_PASSWORD |
| 182 | |
| 183 | [swift] |
| 184 | auth_host = $HOST_IP |
| 185 | auth_port = 443 |
| 186 | auth_prefix = /auth/ |
| 187 | auth_ssl = yes |
| 188 | account = system |
| 189 | username = root |
| 190 | password = password |
| 191 | |
| 192 | EOF |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame^] | 193 | mv $CONFIG_INI_TMP $CONFIG_INI |
| 194 | CONFIG_INI_TMP="" |
| 195 | |
| 196 | trap - SIGHUP SIGINT SIGTERM SIGQUIT EXIT |