X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=blobdiff_plain;f=deploy%2Fmetal3%2Fscripts%2F03_verify_deprovisioning.sh;h=7ffcc0139dfeea16f26b9227bdb3f4df1867cb45;hb=80a8b4ad085dcbb16357185219ea29630bbeaf53;hp=97a8a2188985a22f2d734081d3158e0cbc7abb08;hpb=c3b53a32784bfcb07e6d5dbe84b1b365ff691a4a;p=icn.git diff --git a/deploy/metal3/scripts/03_verify_deprovisioning.sh b/deploy/metal3/scripts/03_verify_deprovisioning.sh index 97a8a21..7ffcc01 100755 --- a/deploy/metal3/scripts/03_verify_deprovisioning.sh +++ b/deploy/metal3/scripts/03_verify_deprovisioning.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#set -x +set -eu -o pipefail LIBDIR="$(dirname "$(dirname "$(dirname "$PWD")")")" @@ -14,19 +14,24 @@ function check_deprovisioned { declare -i prev_host_state=0 declare -i j=0 echo "Baremetal state: 1 means deprovisioned & 0 means not yet deprovisioned" - while read -r name username password address; do + while IFS=',' read -r name ipmi_username ipmi_password ipmi_address boot_mac os_username os_password os_image_name; do declare -i current_host_state=0 - state=$(kubectl get baremetalhosts $name -n metal3 -o json | jq -r '.status.provisioning.state') + if kubectl get baremetalhost $name -n metal3 &>/dev/null; then + state=$(kubectl get baremetalhosts $name -n metal3 -o json | jq -r '.status.provisioning.state') + else + # When the named BareMetalHost is not found, assume its deprovisioned + state="ready" + fi echo "Baremetal host metal3 state - "$name" : "$state - if [ $state == "ready" ];then + if [ "$state" == "ready" ];then current_host_state=1 fi echo "Baremetal $name current_host_state : "$current_host_state echo "Previous Baremetals prev_host_state : "$prev_host_state - if [ $j -eq 0 ]; then + if [ $j -eq 0 ]; then prev_host_state=$current_host_state ((j+=1)) continue @@ -50,14 +55,11 @@ function warm_up_time { } function wait_for_deprovisioned { - all_bmh_deprovisioned=1 declare -i k=1 while ((timeout > 0)); do echo "Try $k iteration : Wait for $interval seconds to check all bmh state" sleep $interval - list_nodes | check_deprovisioned - all_bmh_state=$? - if [[ $all_bmh_state -eq $all_bmh_deprovisioned ]]; then + if ! list_nodes | check_deprovisioned; then echo "All the Baremetal hosts are deprovisioned - success" warm_up_time exit 0