s3:modules: s/struct timed_event/struct tevent_timer
[Samba/gebeck_regimport.git] / source4 / selftest / win / vm_load_snapshot.pl
blob35e80badce205ad0379b8b9b5ad5a665ca96c679
1 #!/usr/bin/perl -w
3 # A perl script to connect to a VMware server and revert a VM snapshot.
4 # Copyright Brad Henry <brad@samba.org> 2006
5 # Released under the GNU GPL version 3 or later.
7 use VMHost;
9 sub check_error {
10 my $vm = VMHost;
11 my $custom_err_str = "";
12 ($vm, $custom_err_str) = @_;
14 my ($err_code, $err_str) = $vm->error;
15 if ($err_code != 0) {
16 undef $vm;
17 die $custom_err_str . "Returned $err_code: $err_str.\n";
21 # Read in parameters from environment.
22 my $vm_cfg_path = $ENV{'VM_CFG_PATH'};
23 my $host_server_name = $ENV{'HOST_SERVER_NAME'};
24 my $host_server_port = $ENV{'HOST_SERVER_PORT'};
25 if (!defined($host_server_port)) {
26 $host_server_port = 902;
29 my $host_username = $ENV{'HOST_USERNAME'};
30 my $host_password = $ENV{'HOST_PASSWORD'};
31 my $guest_admin_username = $ENV{'GUEST_ADMIN_USERNAME'};
32 my $guest_admin_password = $ENV{'GUEST_ADMIN_PASSWORD'};
34 my $vm = VMHost;
36 $vm->host_connect($host_server_name, $host_server_port, $host_username,
37 $host_password, $vm_cfg_path, $guest_admin_username,
38 $guest_admin_password);
39 check_error($vm, "Error in \$vm->host_connect().\n");
41 $vm->revert_snapshot();
42 check_error($vm, "Error in \$vm->revert_snapshot().\n");
44 undef $vm;
46 exit 0;