-
Notifications
You must be signed in to change notification settings - Fork 8
/
find_os.pl
executable file
·59 lines (37 loc) · 1.02 KB
/
find_os.pl
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
#!/usr/bin/perl
=head1 NAME
find_os.pl
=head1 SYNOPSIS
./find_os.pl --username admin --password foo --host virtualcenter
=head1 ARGUMENTS
=over
=item --help
Show the arguments for this program.
=back
=head1 DESCRIPTION
Reports the OSs of all the VMs managed by B<virtualcenter>. Requires installation of VMware tools on each host to be accurate.
=head1 SEE ALSO
L<VMware Perl SDK|http://www.vmware.com/support/developer>
=head1 AUTHOR
Jonathan Barber - <[email protected]>
=cut
use strict;
use warnings;
use VMware::VIRuntime;
$Util::script_version = "1.0";
# read/validate options and connect to the server
Opts::parse();
Opts::validate();
Util::connect();
# Get all VMs
my $vms = Vim::find_entity_views(
view_type => 'VirtualMachine',
);
# Iterate over the VMs, printing their info
foreach my $vm (@{ $vms }) {
print join(",",
map { defined $_ ? $_ : "" }
$vm->name, $vm->guest->guestState, $vm->guest->guestFamily, $vm->guest->guestFullName
), "\n";
}
Util::disconnect();