Signed-off-by: Zhang Dewan 513619464@qq.com --- jobs/reset-tbox.yaml | 10 +++++++++ tests/reset-tbox | 52 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 jobs/reset-tbox.yaml create mode 100755 tests/reset-tbox
diff --git a/jobs/reset-tbox.yaml b/jobs/reset-tbox.yaml new file mode 100644 index 00000000..52ea76b7 --- /dev/null +++ b/jobs/reset-tbox.yaml @@ -0,0 +1,10 @@ +suite: reset-tbox +category: functional + +testbox: dc-8g +os_mount: container +docker_image: reset-tbox:latest +queue: reset-tbox + +reset-tbox: +host_name: diff --git a/tests/reset-tbox b/tests/reset-tbox new file mode 100755 index 00000000..ae3cbe52 --- /dev/null +++ b/tests/reset-tbox @@ -0,0 +1,52 @@ +#!/bin/bash +# host_name + +account_file=/etc/lab/.account.info +hosts_file=/etc/lab/hosts_file +command_file=/usr/bin/ipmitool + +file_check() +{ + for i in $account_file $hosts_file $command_file + do + [ -f $i ] || { + echo "File not found: $i" + exit 0 + } + done + source $account_file +} + +tbox_check() +{ + ibmc_ip=$(grep -w $host_name $hosts_file | awk '{print $1}') + + [[ "$ibmc_ip" =~ ^[0-9]+.* ]] || { + echo "Testbox not found: $host_name" + exit 1 + } +} + +reset_tbox() +{ + echo "reboot the tesetbox..." + ipmitool -I lanplus -H $ibmc_ip -U $iBMC_user -P $iBMC_passwd power reset +} + +result_check() +{ + if [ $? -ne 0 ] ; then + echo "Failed to reboot the testbox: $host_name" + fi + echo "done." +} + +main() +{ + file_check + tbox_check + reset_tbox + result_check +} + +main