diff options
author | Bill Peck <bpeck@redhat.com> | 2014-06-18 10:58:23 -0400 |
---|---|---|
committer | Bill Peck <bpeck@redhat.com> | 2014-06-18 10:58:23 -0400 |
commit | b81acc58e24227379093000edd61818029441686 (patch) | |
tree | d339f267c74bc86bfedb93a83d20f4fb9506baec /distribution/virt/import/stopguest | |
parent | cb96f1c472f0bcfcddf38c108c24d385a59d2328 (diff) | |
download | tests-b81acc58e24227379093000edd61818029441686.tar.gz tests-b81acc58e24227379093000edd61818029441686.tar.xz tests-b81acc58e24227379093000edd61818029441686.zip |
new /virt/import test which will use pre-existing images
Diffstat (limited to 'distribution/virt/import/stopguest')
-rwxr-xr-x | distribution/virt/import/stopguest | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/distribution/virt/import/stopguest b/distribution/virt/import/stopguest new file mode 100755 index 0000000..b4d20f3 --- /dev/null +++ b/distribution/virt/import/stopguest @@ -0,0 +1,56 @@ +#!/usr/bin/expect +# +# utility script to stop the guest and make sure that it has shutdown +# it has a default of 5 minutes to wait for the guest to shut +# + +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 virsh shutdown $guest +set stop_spawn $spawn_id + +expect { + -i $stop_spawn "Domain $guest is being shutdown" { } + -i $stop_spawn timeout { + send_user "timeout on virsh shutdown $guest\n"; + exit 1; + } + -i $stop_spawn eof { + send_user "EOF on virsh shutdown $guest\n"; + exit 1; + } +} + +spawn virsh console $guest +set con_spawn $spawn_id +set timeout $waittimeout + +expect { + -i $con_spawn "System halted." { exit 0; } + -i $con_spawn timeout { + send_user "start timeout\n"; + exit 1; + } + -i $con_spawn eof { exit 0; } +} + +exit 1; |