blob: a982435f503fd17e2031ae7b02ee663e9d143eaa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
#!/usr/bin/expect
#
# utility script to start the guest and make sure that it started is up
# it has a default of 5 minutes to wait for the guest to start up.
#
if { $argc < 1 } {
send_user "Usage: $argv0 guestname <optional timeout value>"
exit 1
}
# stupid hack for when this is called from a script
if { $argc == 1 } {
set argv_tmp [lindex $argv 0]
set argv [split $argv_tmp]
}
if { [llength $argv] > 1 } {
set waittimeout [lindex $argv 1]
} else {
set waittimeout 300
}
set guest [lindex $argv 0]
set prompt "(%|#|\\\$) $"
log_user 0
spawn xm create $guest
set start_spawn $spawn_id
expect {
-i $start_spawn "Domain $guest started" { exp_continue; }
-i $start_spawn timeout {
send_user "timeout on xm start $guest\n";
exit 1;
}
-i $start_spawn eof { }
}
spawn xm console $guest
set con_spawn $spawn_id
set timeout $waittimeout
send -i $con_spawn "\r"
send -i $con_spawn "\r"
send -i $con_spawn "\r"
expect {
-i $con_spawn "login: " { send -i $con_spawn ; exit 0; }
-i $con_spawn -re "(P|p)assword:" { send -i $con_spawn ; exit 0; }
-i $con_spawn -re $prompt { send -i $con_spawn ; exit 0; }
-i $con_spawn timeout {
send_user "start timeout\n";
exit 1;
}
-i $con_spawn eof {
send_user "start EOF\n";
exit 1;
}
}
exit 1;
|