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