VMware Cloud Community
jessem
Enthusiast
Enthusiast

HBA Driver Information

Hello all,

I'm trying to get a script that I could run on a cluster of my choosing that will output the current HBA driver info for all the hosts within that cluster on a .csv file.

Reply
0 Kudos
7 Replies
julienvarela
Commander
Commander

Hi,

In my knowledge you cannot determine the current HBA driver version using powercli according to this KB : http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=100241...

Note: You can determine the firmware of HBAs only using Direct Console access or SSH and not via RCLI or vMA.


Regards,

Julien

Regards, J.Varela http://vthink.fr
Reply
0 Kudos
MKguy
Virtuoso
Virtuoso

Take a look at this script:

Re: HBA Information: PowerCLI

Re: ESXi 5.0 U1 HBA Details: Power CLI

It reads the info that is available in the HBA procnode but requires plink.exe and having SSH enabled on the hosts though.

Or use something this snippet to query just the installed HBA driver version:

Get-Cluster MyCluster | Sort | Get-VMHost | % {

  $hbadriver = $_ | Get-VMHostHba  -Type FibreChannel | Select -Expand Driver | Get-Unique

  $esxcli = Get-EsxCli -VMHost $_

  $_ | Select @{N="Hostname"; E={$_.Name}},

   @{N="Driver"; E={$hbadriver}},

   @{N="DriverVersion";E={$esxcli.software.vib.list() | ? {$_.Name -match ".*$hbadriver.*"} | Select -Expand Version}}

}

Sample output:

Hostname                                                    Driver                                                     DriverVersion
--------                                                    ------                                                     -------------
host01.local                                    qla2xxx                                                    901.k1.1-14vmw.500.0.0.469512
host02.local                                    qla2xxx                                                    901.k1.1-14vmw.500.0.0.469512

-- http://alpacapowered.wordpress.com
Reply
0 Kudos
jessem
Enthusiast
Enthusiast

I will try to test this but where in that script is the output portion?....  c:\output.csv

Reply
0 Kudos
MKguy
Virtuoso
Virtuoso

This just prints to the console, generating CSV-output is as simple as adding "Export-Csv C:\output.csv" to the end of the loop:

Get-Cluster MyCluster | Sort | Get-VMHost | % {

  $hbadriver = $_ | Get-VMHostHba  -Type FibreChannel | Select -Expand Driver | Get-Unique

  $esxcli = Get-EsxCli -VMHost $_

  $_ | Select @{N="Hostname"; E={$_.Name}},

   @{N="Driver"; E={$hbadriver}},

   @{N="DriverVersion";E={$esxcli.software.vib.list() | ? {$_.Name -match ".*$hbadriver.*"} | Select -Expand Version}}

} | Export-Csv C:\output.csv

-- http://alpacapowered.wordpress.com
Reply
0 Kudos
snoopj
Enthusiast
Enthusiast

Alternatively, you can go with some Powershell commands to talk to the CIM service on the host and return information similar to how the Hardware Status tab works in the C# vSphere client.  I do this to return back driver version info for my NICs, along with returning back the ILO IP so I can get a trusted serial number for the host (cursed HP servers).

It was rather complicated in Powershell 2 to do it, but new cmdlets in PS3 give you the ability to query this without too much trouble.  I don't have my scripts in front of me, but I'll post more when I have some time.

Reply
0 Kudos
gotts
Enthusiast
Enthusiast

I have a script that will get most of the HBA information but I am unable to obtain the Firmware version. The only way I have identified to get that information is to invoke plink.exe and I am struggling to make that work. I will post the code here lines 47 to 54 are the problem section at this time.

The invoke-ssh function, called in line 48 resides in lines 11-24 of the script.

Please feel free to use this as you like and if anyone can help me with clearing this last hurdle I would be very grateful!!!

#### SCRIPT TO  Gather HBAInformation #####

Add-PSSnapin VMware.VimAutomation.Core

$Server = read-host "Enter the vCenter Name or IP Address you wish to access. (The vCenter name is preferred.)"

$username = read-host -prompt "Please enter local user account for host access"

read-host -prompt "Please enter password for host account" -assecurestring | convertfrom-securestring | out-file cred.txt

$password = get-content cred.txt | convertto-securestring

$credentials = new-object -typename System.Management.Automation.PSCredential -argumentlist $username,$password

Connect-VIServer -Server $Server

Write-Host ""

### Start Function Invoke-SSH ###

Function Invoke-SSH {

Param($Hostname,$Username,$Password, $CommandArray, $PlinkAndPath)

$Hostname = $esx.Name

$Username = 'Root'

$Password = 'password'

$CommandArray += $remotecommand

$CommandArray += "exit"

$PlinkAndPath = "C:\Test\plink.exe"

$Target = $Username + '@' + $esx.Name

$Plinkssh = ($Plinkandpath+" -ssh "+$Username+"@"+$Hostname+" -pw "+$Password)

### NOTE The WRITE-HOST COMMAND shown next passes the proper path to launch PLINK.exe on a host assuming the ID and PW are good. ###

#Write-Host ($Plinkandpath+" -ssh "+$Username+"@"+$Hostname+" -pw "+$Password)

}

### End Function Invoke-SSH  ###

$ErrorActionPreference = "silentlycontinue"

$CSVPath = 'c:\Test\results.csv'

$report = @()

$hostsview = Get-View -ViewType HostSystem -Property ("runtime", "name", "config", "hardware")

$progressCount = 1

foreach ($esx in $hostsview | ?{$_.runtime.PowerState -match "poweredOn"} | Sort Name) {

                Write-Progress -Id 1 -Activity "Getting ESX HBA information" -Status ("[$progressCount/"+($hostsview | ?{$_.runtime.PowerState

                -match "poweredOn"}).count+"] "+$esx.Name) -PercentComplete (($progressCount*100)/(($hostsview | ?{$_.runtime.PowerState

                -match "poweredOn"}).count))

                if ( ($Username.Length -eq 0) -And ($Password -eq 0) ) {break} #Username and password empty

                foreach ($hba in $esx.Config.StorageDevice.HostBusAdapter | ?{$_.GetType().Name -eq "HostFibreChannelHba"}) {

                                $line = "" | Select HostName,HostProduct,HbaDevice,HbaWWN,HbaDriver,HbaModel,HbaFirmwareVersion,HWModel

                                $line.HostName = $esx.name

                                $line.HostProduct = $esx.config.product.fullName

                                $line.HbaDevice = $hba.device

                                $line.HbaWWN = ([regex]::matches("{0:x}" -f $hba.PortWorldWideName, '.{2}') | %{$_.value}) -join ':'

                                $line.HbaDriver = $hba.driver

                                $line.HbaModel = $hba.model

                                if ($hba.driver -match "lpfc820" ) {

                                Invoke-SSH $Plinkssh

                                $remotecommand =(cat /proc/scsi/lpfc820/* | grep -i 'firmware version' | sed 's/Firmware Version:\{0,1\} \(.*\)/\1/' | %{$_.value})

                                $msg = Invoke-Expression -command $remotecommand

                                $line.HbaFirmWareVersion = $msg

                                # Testing Results for HbaFirmWareVersion

                                write-host 'Host= '$esx.Name', FWV= '$line.HbaFirmWareVersion

}                              

                                $line.HWModel = $esx.hardware.systemInfo.model

                                $report += $line

               

                $progressCount++

}

}

$remotecommand = "exit"

if ($CSVPath) {

                # CSV file export sample usage

                $report | Export-CSV -NoTypeInformation -Delimiter ";" -Encoding ASCII -Path $CSVPath

} else {

                # Displaying result

                $report

}

$VC = Disconnect-VIServer -Confirm:$False

Reply
0 Kudos
admin
Immortal
Immortal

Managed object hostKernelModuleSystem has method queryModules. This method returns data object KernelModuleInfo which in turn has the option version.

ATTACHMENT BELOW is part from a bigger script which could be used as an example ON how to get and parse the version string returned by this property.

Please note, the script was not tested with ESXi 5.5

hth

=Seva

Reply
0 Kudos