From 97ce3ff5c76da12d4eda75cf9eca57e736529f26 Mon Sep 17 00:00:00 2001 From: bybai Date: Sun, 18 Oct 2015 22:58:33 -0400 Subject: [PATCH 1/2] fix delete raild failed with wait_for_ipr_device_status: command not found --- xCAT-genesis-scripts/bin/raidutils | 73 ++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/xCAT-genesis-scripts/bin/raidutils b/xCAT-genesis-scripts/bin/raidutils index 45aeb61ed..f4211f30b 100755 --- a/xCAT-genesis-scripts/bin/raidutils +++ b/xCAT-genesis-scripts/bin/raidutils @@ -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= tryInt= cmd=" +# +######################################################################################### +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 +} + ###################################################### # From ed6427da318b7f0fb7046e428e6e5f355415a67c Mon Sep 17 00:00:00 2001 From: bybai Date: Wed, 21 Oct 2015 02:47:21 -0400 Subject: [PATCH 2/2] fix xdsh p8euh configraid delete_raid=all hangs when delete raid 0 --- xCAT-genesis-scripts/bin/configraid | 2 +- xCAT-genesis-scripts/bin/raidutils | 31 ++++++++++++++++++++++++++--- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/xCAT-genesis-scripts/bin/configraid b/xCAT-genesis-scripts/bin/configraid index 90fc5015d..3e2342bf1 100755 --- a/xCAT-genesis-scripts/bin/configraid +++ b/xCAT-genesis-scripts/bin/configraid @@ -51,7 +51,7 @@ function usagesc { echo ' pci_slot_name is the specified PCI location. If specify pci_slot_name, this raid will be created using disks from this pci_slot;' echo ' disk_names is a list of advanced format disk names. If specify disk_names, this raid will be created using these disks;' echo ' Example 1, create 2 raid0 arrays, one is using 3 disks, the other is using 2 disks, the disks PCI_ID is 1014:034a:' - echo ' create_raid="rl#0|pci_id#1014:034a|disk_num#1 create_raid="rl#0|pci_id#1014:034a|disk_num#2' + echo ' create_raid="rl#0|pci_id#1014:034a|disk_num#1" create_raid="rl#0|pci_id#1014:034a|disk_num#2"' echo ' Example 2, pci_slot_name is 0001:08:00.0, create raid10 array, using 2 disks ' echo ' create_raid="rl#10|pci_slot_name#0001:08:00.0|disk_num#2"' echo ' Example 3, create 1 raid0 array using advanced format disk sg1' diff --git a/xCAT-genesis-scripts/bin/raidutils b/xCAT-genesis-scripts/bin/raidutils index f4211f30b..3c1381636 100755 --- a/xCAT-genesis-scripts/bin/raidutils +++ b/xCAT-genesis-scripts/bin/raidutils @@ -1319,12 +1319,12 @@ function sort_devices_by_resource_path { return 0 } -######################################################################################### +########################################################################################################################## # # wait to check ipr device status -# usage: wait_for_ipr_device_status "tryCnt= tryInt= cmd=" +# usage: wait_for_ipr_device_status tryCnt= tryInt= cmd="check_cmd_line" -- "sg0,sg1,...,sgn" # -######################################################################################### +######################################################################################################################### function wait_for_ipr_device_status { local tryCnt=1 local tryInt=10 @@ -1392,6 +1392,31 @@ function wait_for_ipr_device_status { return $rc } +############################################################## +# +# check status of ipr devices +# input : slocs list, for example, 0:0:0:0 0:0:1:0 +# usage : check_ipr_device_status ... +# +############################################################## +function check_ipr_device_status { + local sgs="$*" + local lines=`convert_sloc_to_sg $sgs` + + local item + for item in $sgs + do + declare sg=`echo "$lines" | $awk -F= -vkey=$item '$1 == key {print $2;}'` + declare _sg_status=`$iprconfig -c status $sg` + if [ "$_sg_status" = "Rebuilding" ]; then + declare _sg_status_alt=`cmd_alt_status $sg` + [ -n "$_sg_status_alt" ] && _sg_status="$_sg_status, $_sg_status_alt" + fi + echo "$item=$_sg_status" + done + return 0 +} + ###################################################### #