Merge "Display API limit before stacking"
[releng/builder.git] / jjb / opendaylight-infra-stack.sh
1 #!/bin/bash
2 virtualenv $WORKSPACE/.venv-openstack
3 source $WORKSPACE/.venv-openstack/bin/activate
4 pip install --upgrade pip
5 pip install --upgrade python-openstackclient python-heatclient
6 pip freeze
7
8 cd /builder/openstack-hot
9
10 JOB_SUM=`echo $JOB_NAME | sum | awk '{{ print $1 }}'`
11 VM_NAME="$JOB_SUM-$BUILD_NUMBER"
12
13 # seq X refers to waiting for X minutes for OpenStack to return
14 # a status that is not CREATE_IN_PROGRESS before giving up.
15 OS_TIMEOUT=15  # Minutes to wait for OpenStack VM to come online
16 openstack --os-cloud rackspace limits show --rate
17 openstack --os-cloud rackspace stack create --timeout $OS_TIMEOUT -t {stack-template} -e $WORKSPACE/opendaylight-infra-environment.yaml --parameter "job_name=$VM_NAME" --parameter "silo=$SILO" $STACK_NAME
18 echo "Waiting for $OS_TIMEOUT minutes to create $STACK_NAME."
19 for i in `seq $OS_TIMEOUT`; do
20     sleep 60
21     OS_STATUS=`openstack --os-cloud rackspace stack show -f json -c stack_status $STACK_NAME | jq -r '.stack_status'`
22     if [ "$OS_STATUS" == "CREATE_COMPLETE" ]; then
23         echo "Stack initialized on infrastructure successful."
24         break
25     elif [ "$OS_STATUS" == "CREATE_FAILED" ]; then
26         echo "ERROR: Failed to initialize infrastructure. Quitting..."
27         exit 1
28     elif [ "$OS_STATUS" == "CREATE_IN_PROGRESS" ]; then
29         echo "Waiting to initialize infrastructure."
30         continue
31     else
32         echo "Unexpected status: $OS_STATUS"
33     fi
34 done