1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- #!/usr/bin/perl -w
- use strict;
- use warnings;
- use VMware::VILib;
- use VMware::VIRuntime;
- use Data::Dumper;
- # validate options, and connect to the server
- Opts::parse();
- Opts::validate();
- Util::connect();
- my $hname = undef;
- if (scalar(@ARGV) == 1) {
- $hname = $ARGV[0];
- }
- my @iscsiHosts = ();
- if ($hname) {
- my $vmhost = Vim::find_entity_view(
- view_type => 'HostSystem',
- filter => {name => $hname}
- );
- if (!$vmhost) {
- print "Failed to find host $hname\n";
- exit(1);
- }
- push @iscsiHosts, $vmhost;
- } else {
- my $vmhosts = Vim::find_entity_views(view_type => 'HostSystem',);
- foreach (@$vmhosts) {
- push @iscsiHosts, $_;
- }
- }
- my $error = 0;
- foreach my $host (@iscsiHosts) {
- my $ss = Vim::get_view(mo_ref => $host->configManager->storageSystem,);
- my $hbas = $ss->storageDeviceInfo->hostBusAdapter;
- my $hba = undef;
- foreach my $h (@$hbas) {
- if ($h->isa('HostInternetScsiHba')) {
- $hba = $h;
- print $hba->device, "\n";
- last;
- }
- }
- if (!$hba) {
- print "Did not find HBA for $host->{'name'}\n";
- $error = 1;
- next;
- }
- }
- Util::disconnect();
- if ($error) {
- exit(1);
- }
|