3 # A perl script to connect to a VMware server and get the IP address of a VM.
4 # Copyright Brad Henry <brad@samba.org> 2006
5 # Released under the GNU GPL version 3 or later.
11 my $custom_err_str = "";
12 ($vm, $custom_err_str) = @_;
14 my ($err_code, $err_str) = $vm->error;
17 die $custom_err_str . "Returned $err_code: $err_str.\n";
21 # Read in parameters from environment.
22 my $vm_cfg_path = $ENV{"$ARGV[0]"};
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'};
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 my $guest_ip = $vm->get_guest_ip();
42 check_error
($vm, "Error in \$vm->get_guest_ip().\n");