Merge "move network id to local jenkins configuration managed files"
[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 stack create --timeout $OS_TIMEOUT -t {stack-template} -e $WORKSPACE/opendaylight-infra-environment.yaml --parameter "job_name=$VM_NAME" --parameter "silo=$SILO" $STACK_NAME
17 echo "Waiting for $OS_TIMEOUT minutes to create $STACK_NAME."
18 for i in `seq $OS_TIMEOUT`; do
19     sleep 60
20     OS_STATUS=`openstack --os-cloud rackspace stack show -f json -c stack_status $STACK_NAME | jq -r '.stack_status'`
21     if [ "$OS_STATUS" == "CREATE_COMPLETE" ]; then
22         echo "Stack initialized on infrastructure successful."
23         break
24     elif [ "$OS_STATUS" == "CREATE_FAILED" ]; then
25         echo "ERROR: Failed to initialize infrastructure. Quitting..."
26         exit 1
27     elif [ "$OS_STATUS" == "CREATE_IN_PROGRESS" ]; then
28         echo "Waiting to initialize infrastructure."
29         continue
30     else
31         echo "Unexpected status: $OS_STATUS"
32     fi
33 done