4 LIBDIR="$(dirname "$(dirname "$(dirname "$PWD")")")"
8 source $LIBDIR/env/lib/common.sh
11 declare -i interval=60
13 function check_deprovisioned {
14 declare -i prev_host_state=0
16 echo "Baremetal state: 1 means deprovisioned & 0 means not yet deprovisioned"
17 while IFS=',' read -r name ipmi_username ipmi_password ipmi_address os_username os_password os_image_name; do
18 declare -i current_host_state=0
19 state=$(kubectl get baremetalhosts $name -n metal3 -o json | jq -r '.status.provisioning.state')
20 echo "Baremetal host metal3 state - "$name" : "$state
22 if [ $state == "ready" ];then
26 echo "Baremetal $name current_host_state : "$current_host_state
27 echo "Previous Baremetals prev_host_state : "$prev_host_state
30 prev_host_state=$current_host_state
35 if [ $current_host_state -eq 1 ] && [ $prev_host_state -eq 1 ]; then
41 echo "All Baremetal hosts aggregated state - prev_host_state:"$prev_host_state
44 return $prev_host_state
47 function warm_up_time {
48 echo "Wait for 240s for all baremetal hosts to reboot and network is up"
52 function wait_for_deprovisioned {
54 while ((timeout > 0)); do
55 echo "Try $k iteration : Wait for $interval seconds to check all bmh state"
57 if ! list_nodes | check_deprovisioned; then
58 echo "All the Baremetal hosts are deprovisioned - success"
69 function verify_bm_hosts_cleanup {
70 wait_for_deprovisioned
73 verify_bm_hosts_cleanup