4 set method [lindex $argv 0]
5 set host [lindex $argv 1]
6 set user [lindex $argv 2]
7 set password [lindex $argv 3]
8 set dryrun [lindex $argv 4]
9 set model [lindex $argv 5]
13 set path [ file dirname [ file dirname $argv0 ] ]
15 if { "$method" == "https" } {
16 if { "$dryrun" == "True" } {
17 set file $path/hpilo/iloxml/Get_Network.xml
19 set file $path/hpilo/iloxml/Reset_Server.xml
20 #set file $path/hpilo/iloxml/Get_Network.xml
22 spawn "$path/hpilo/locfg.pl" -s $host -u $user -p $password -f $file
23 } elseif { "$method" == "ssh" } {
24 if { "$dryrun" == "True" } {
25 set reset_cmd "POWER\r"
26 set reset_msg "Test: No error"
28 #set reset_cmd "POWER\r"
29 set reset_cmd "reset\r"
30 set reset_msg "Reset: No error"
33 } elseif { "$method" == "proxy" } {
34 set url "http://www.cs.princeton.edu/~soltesz/pcuProxy.php"
35 set query "username=$user&password=$password&hostname=$host&model=$model&dryrun=$dryrun"
36 spawn curl -s "$url?$query"
39 if { "$method" == "proxy" || "$method" == "https" } {
40 # Check for any one of the following patterns, then print it and stop.
42 "MESSAGE='Server being reset.'" { send_user "Reset: No error" }
43 "MESSAGE='Host power is already ON.'" { send_user "$expect_out(0,string)"}
44 "MESSAGE='Host power is already OFF.'" { send_user "$expect_out(0,string)"}
45 "MESSAGE='Login credentials rejected.'" { send_user "$expect_out(0,string)"}
46 "MESSAGE='User login name was not found'" { send_user "$expect_out(0,string)"}
47 "<GET_NETWORK_SETTINGS>" { send_user "Test: No error"}
48 -re "ERROR:.*" { send_user "$expect_out(0,string)" }
49 eof { send_user "Reached EOF without status report: $expect_out(buffer)" }
51 } elseif { "$method" == "ssh" } {
54 "Are you sure you want to continue connecting (yes/no)? " { send "yes\n" ; exp_continue }
55 "password: " { send "$password\n" ; exp_continue }
56 "Permission denied" { send_user "HPiLO username/password: $expect_out(0,string)"; exit }
57 "Could not resolve hostname" { send_user "HPiLO hostname: $expect_out(0,string)"; exit }
58 "Connection timed out" { send_user "HPiLO ssh timeout: $expect_out(0,string)"; exit }
59 "</>hpiLO-> " { send "cd system1\r" }
60 eof { send_user "HPiLO early EOF\n"; exit }
63 expect "</system1>hpiLO-> " { send $reset_cmd }
64 expect "</system1>hpiLO-> " { send "exit\r" }
65 expect eof { send_user $reset_msg }