#!/usr/bin/perl my %esxrz; my %storagerz; my %vmhostds; read_csv ("esx-rz.csv", \%esxrz); read_csv ("storage-rz.csv", \%storagerz); read_csv2 ("VMsHostsDatastores.csv", \%vmhostds, \%esxrz, \%storagerz); foreach ( sort keys %vmhostds) { if ($vmhostds{$_}->{esx}->{dc} ne $vmhostds{$_}->{ds}->{dc}) { next if ($vmhostds{$_}->{ds}->{datastore} eq "images" ); next if ($vmhostds{$_}->{ds}->{datastore} eq "tso_install" ); printf "%-25s %-25s (%-3s) %-20s (%-3s)\n", $_, $vmhostds{$_}->{esx}->{hostname}, $vmhostds{$_}->{esx}->{dc}, $vmhostds{$_}->{ds}->{datastore}, $vmhostds{$_}->{ds}->{dc}; } } sub read_csv { my ($file, $ref_hash) = @_; open FILE, "$file" or die $!; my $key; my $val; while (my $line = ) { chomp($line); ($key, $val) = split /,/, $line; $ref_hash->{$key} = $val; } close FILE; } sub read_csv2 { my ($file, $ref_hash, $ref_esx, $ref_ds) = @_; open FILE, "$file" or die $!; my $key; my $esx; my $ds; while (my $line = ) { chomp($line); $line =~ s/"//g; $line =~ s/\r//g; ($key, $esx, $ds) = split /,/, $line; $ref_hash->{$key}->{esx}->{hostname} = $esx; $ref_hash->{$key}->{esx}->{dc} = $ref_esx->{$esx}; $ref_hash->{$key}->{ds}->{datastore} = $ds; $ref_hash->{$key}->{ds}->{dc} = $ref_ds->{$ds}; } close FILE; }