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 boot_mac os_username os_password os_image_name; do
18 declare -i current_host_state=0
19 if kubectl get baremetalhost $name -n metal3 &>/dev/null; then
20 state=$(kubectl get baremetalhosts $name -n metal3 -o json | jq -r '.status.provisioning.state')
22 # When the named BareMetalHost is not found, assume its deprovisioned
25 echo "Baremetal host metal3 state - "$name" : "$state
27 if [ "$state" == "ready" ];then
31 echo "Baremetal $name current_host_state : "$current_host_state
32 echo "Previous Baremetals prev_host_state : "$prev_host_state
35 prev_host_state=$current_host_state
40 if [ $current_host_state -eq 1 ] && [ $prev_host_state -eq 1 ]; then
46 echo "All Baremetal hosts aggregated state - prev_host_state:"$prev_host_state
49 return $prev_host_state
52 function warm_up_time {
53 echo "Wait for 240s for all baremetal hosts to reboot and network is up"
57 function wait_for_deprovisioned {
59 while ((timeout > 0)); do
60 echo "Try $k iteration : Wait for $interval seconds to check all bmh state"
62 if ! list_nodes | check_deprovisioned; then
63 echo "All the Baremetal hosts are deprovisioned - success"
74 function verify_bm_hosts_cleanup {
75 wait_for_deprovisioned
78 verify_bm_hosts_cleanup