7 Replies Latest reply on Jul 3, 2014 8:43 AM by VNed Ludd

    HBA Driver Information

    jessem Enthusiast

      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.

        • 1. Re: HBA Driver Information
          julienvarela Expert

          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=1002413

           

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


          Regards,

          Julien

          • 2. Re: HBA Driver Information
            MKguy 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

             

             

            • 3. Re: HBA Driver Information
              jessem Enthusiast

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

              • 4. Re: HBA Driver Information
                MKguy 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

                • 5. Re: HBA Driver Information
                  snoopj Enthusiast
                  vExpert

                  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.

                  • 6. Re: HBA Driver Information
                    gotts 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

                    • 7. Re: HBA Driver Information
                      Novice

                      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