mirror of
https://github.com/xcat2/xcat-core.git
synced 2025-05-29 09:13:08 +00:00
fix delete raild failed with wait_for_ipr_device_status: command not found
This commit is contained in:
parent
206116f11e
commit
97ce3ff5c7
@ -1319,6 +1319,79 @@ function sort_devices_by_resource_path {
|
||||
return 0
|
||||
}
|
||||
|
||||
#########################################################################################
|
||||
#
|
||||
# wait to check ipr device status
|
||||
# usage: wait_for_ipr_device_status "tryCnt=<minitutes> tryInt=<seconds> cmd=<command_string>"
|
||||
#
|
||||
#########################################################################################
|
||||
function wait_for_ipr_device_status {
|
||||
local tryCnt=1
|
||||
local tryInt=10
|
||||
local cmd="true"
|
||||
|
||||
# parser input arguments
|
||||
while [ -n "$1" ];
|
||||
do
|
||||
local key=`echo "$1" | $cut -s -d= -f1`
|
||||
if [ "$key" = "tryCnt" ] || \
|
||||
[ "$key" = "tryInt" ] || \
|
||||
[ "$key" = "cmd" ]; then
|
||||
local val=`echo "$1" | $cut -s -d= -f2-`
|
||||
eval "$key=\"$val\""
|
||||
elif [ "$1" = "--" ]; then
|
||||
shift
|
||||
sgs="$*"
|
||||
break
|
||||
fi
|
||||
shift
|
||||
done
|
||||
sgs=`echo "$sgs" | $sed -e "s/,/ /g"`
|
||||
local cnt=0
|
||||
local lines
|
||||
while [ $cnt -lt $tryCnt -o $tryCnt -le 0 ];
|
||||
do
|
||||
# sleep for specific interval for next cycle
|
||||
[ $cnt -gt 0 ] && $sleep $tryInt
|
||||
|
||||
lines=`check_ipr_device_status $sgs`
|
||||
local status_lines=""
|
||||
local neg=0
|
||||
local sg
|
||||
for sg in $sgs
|
||||
do
|
||||
local _sg_status=`echo "$lines" | grep "^$sg=" | $cut -d= -f2- -s`
|
||||
echo "$_sg_status" | eval $cmd >&2
|
||||
if [ $? -ne 0 ]; then
|
||||
neg=1
|
||||
status_lines="${status_lines}${status_lines:+,}status[$sg]=\"$_sg_status\""
|
||||
fi
|
||||
done
|
||||
|
||||
# break out if NO negative matching
|
||||
# or, try next loop
|
||||
if [ $neg -eq 0 ]; then
|
||||
break
|
||||
else
|
||||
log_status "Wait for device status at time \""`date "+%Y-%m-%d %H:%M:%S"`"\": $status_lines, expect: \"$cmd\"."
|
||||
fi
|
||||
|
||||
((cnt+=1))
|
||||
done
|
||||
test $cnt -lt $tryCnt -o $tryCnt -le 0
|
||||
local rc=$?
|
||||
|
||||
# log for debug
|
||||
if [ $rc -eq 0 ]; then
|
||||
log_info "Wait for status on devices: \"$sgs\" succeed! (expected: \"$cmd\")"
|
||||
else
|
||||
log_warn "Wait for status on devices: \"$sgs\" failed! (expected: \"$cmd\")"
|
||||
echo "$lines" | $sed -e 's/^/last device status: >> /g' | log_lines debug
|
||||
fi
|
||||
|
||||
return $rc
|
||||
}
|
||||
|
||||
|
||||
######################################################
|
||||
#
|
||||
|
Loading…
x
Reference in New Issue
Block a user