From 310ecaaaee25a913b02a14dee5085fbf650d654b Mon Sep 17 00:00:00 2001 From: wanghuaz Date: Thu, 14 May 2009 11:03:32 +0000 Subject: [PATCH] retry chsysstat if it failed git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@3380 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/sbin/lpar_netboot.expect | 81 +++++++++++++++++++++------- 1 file changed, 63 insertions(+), 18 deletions(-) diff --git a/xCAT-server/sbin/lpar_netboot.expect b/xCAT-server/sbin/lpar_netboot.expect index b6340e7c2..56b528b42 100644 --- a/xCAT-server/sbin/lpar_netboot.expect +++ b/xCAT-server/sbin/lpar_netboot.expect @@ -2180,32 +2180,77 @@ if { ([string compare "$msg" "Off"] == 0) || ([string compare "$msg" "Not Activa } } +set done 0 +set retry_count 0 if { $set_boot_order > 1 } { send_user "$PROGRAM Status: Power on $NODENAME to SMS.\n" set timeout 120 - send -i $ssh_spawn_id "chsysstate -r lpar -o on -b sms -m \"$manage\" -n \"$node\" -f \"$profile\"\r" + while { ! $done } { + send -i $ssh_spawn_id "chsysstate -r lpar -o on -b sms -m \"$manage\" -n \"$node\" -f \"$profile\"; echo Rc=\$\?\r" + + expect { + -i $ssh_spawn_id \ + -re "\r\n(.*)\r\n\r\nRc=(\[0-9]*)\r\n(.*)" { + set rc $expect_out(2,string) + set msg $expect_out(1,string) + set done 1 + } + -re "\r\nRc=(\[0-9])\r\n(.*)" { + set rc $expect_out(1,string) + set done 1 + } + timeout { + if { $retry_count == 2 } { + send_user "$PROGRAM: Timeout waiting for command prompt\n" + exit 1 + } + sleep 1 + incr retry_count + } + eof { + if { $retry_count == 2 } { + send_user "$PROGRAM: ssh connection to terminated unexpectedly\n" + exit 1 + } + sleep 1 + incr retry_count + } + } + } } else { send_user "# Power on $NODENAME to Open Firmware.\n" set timeout 120 - send -i $ssh_spawn_id "chsysstate -r lpar -o on -b of -m \"$manage\" -n \"$node\" -f \"$profile\"; echo Rc=\$\?\r" + while { ! $done } { + send -i $ssh_spawn_id "chsysstate -r lpar -o on -b of -m \"$manage\" -n \"$node\" -f \"$profile\"; echo Rc=\$\?\r" - expect { - -i $ssh_spawn_id \ - -re "\r\n(.*)\r\n\r\nRc=(\[0-9]*)\r\n(.*)" { - set rc $expect_out(2,string) - set msg $expect_out(1,string) + expect { + -i $ssh_spawn_id \ + -re "\r\n(.*)\r\n\r\nRc=(\[0-9]*)\r\n(.*)" { + set rc $expect_out(2,string) + set msg $expect_out(1,string) + set done 1 + } + -re "\r\nRc=(\[0-9])\r\n(.*)" { + set rc $expect_out(1,string) + set done 1 + } + timeout { + if { $retry_count == 1 } { + send_user "$PROGRAM: Timeout waiting for command prompt\n" + exit 1 + } + sleep 1 + incr retry_count + } + eof { + if { $retry_count == 1 } { + send_user "$PROGRAM: ssh connection to terminated unexpectedly\n" + exit 1 + } + sleep 1 + incr retry_count + } } - -re "\r\nRc=(\[0-9])\r\n(.*)" { - set rc $expect_out(1,string) - } - timeout { - send_user "$PROGRAM: Timeout waiting for command prompt\n" - exit 1 - } - eof { - send_user "$PROGRAM: ssh connection to terminated unexpectedly\n" - exit 1 - } } }