-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_lists_of_vms.pl
executable file
·51 lines (36 loc) · 1.15 KB
/
get_lists_of_vms.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
#!/usr/bin/perl -w
#
# --server
#
use strict;
use warnings;
use VMware::VILib;
use VMware::VIRuntime;
# validate options, and connect to the server
Opts::parse();
Opts::validate();
Util::connect();
open (file,">>vm_list_clusters_power_on");
my $clusters = Vim::find_entity_views(view_type => 'ClusterComputeResource', properties => ['name']);
foreach(@$clusters) {
#print "\t" . $_->{'name'} . "\n";
my $cluster_name = $_->{'name'};
my $esxi = Vim::find_entity_views(view_type => 'VirtualMachine',
begin_entity => $_ ,
filter => { 'runtime.powerState' => 'poweredOn' },
properties => ['name']);
foreach (@$esxi) {
print "$cluster_name \t" . $_->{'name'} . "\n";
print file "$cluster_name \t" . $_->{'name'} . "\n";
}
}
close(file);
#my $vmhosts = Vim::find_entity_views(view_type => 'HostSystem', properties => ['name']);
#print "ESX(i) hosts residing on " . Opts::get_option('server') . "\n";
#open (hosts,">>esx_lists");
#foreach(@$vmhosts) {
# print "\t" . $_->{'name'} . "\n";
# print hosts "VMWARE.FTTB " . $_->{'name'} . "\n";
#}
#close(hosts);
Util::disconnect();