Add build folder for ONAP Offline Build Jobs
[infra/cicd.git] / jjb / onap-offline / build_jobs / scripts / 1_build_stack_creation_3.sh
1 #!/bin/bash
2
3 set -x
4
5 # Delete the stack if exists
6 openstack stack show -c id ${openstack_build_stack_name} && openstack stack delete -y --wait ${openstack_build_stack_name}
7 sleep 1
8 # Create the stack
9 openstack stack create -f yaml -e ${heat_environment} -t ${heat_template} --wait ${openstack_build_stack_name}
10 sleep ${ssh_timeout}
11
12 #TODO: Check if need to remove reference to "om_ran" in line below [eronkeo: 10-10-2019] ** DONE **
13 # build_node_ip=$(openstack server list -c Name -c Networks -f value | egrep ${openstack_build_stack_name} | awk '{print $NF}' | sed 's/om_ran=//g')
14 build_node_ip=$(openstack server list -c Name -c Networks -f value | egrep ${openstack_build_stack_name} | awk '{print $NF}' | sed 's/.*=//g')
15
16 ### Checking if the VM is up, if not retry till it is and continue with the script ###
17 for n in $(seq 1 40); do
18   timeout 1 ping -c 1 "${build_node_ip}" > /dev/null 2>&1
19   RESULT=$?
20   if [ "$RESULT" -eq "0" ] ; then
21     echo "RESULT: $RESULT"
22     n=40
23     break
24   else
25     echo "Failed to connect to "${build_node_ip}". RESULT: $RESULT - Retrying in 10 seconds..."
26     sleep 10
27   fi
28 done
29
30 echo
31 echo "========================================"
32 echo "build node ip: ${build_node_ip}"
33 echo "========================================"
34 echo