0

I try to enumerate all hosts, vm's and storage-adapters in my vCenter-infrastructure by using the vmware.vim-library in vb.net.

But I cannot find a way to get the WWN from the HBA...in powershell there is a property called 'portworldwidename' but this is not available using .net.

foreach($hba in $esx.Config.StorageDevice.HostBusAdapter){
  if($hba.GetType().Name -eq "HostFibreChannelHba"){
    $wwn = $hba.PortWorldWideName
    $wwnhex = "{0:x}" -f $wwn
    Write-Host $wwnhex
    }
}

This is what I have in vb.net:

Dim c As New VimClient
c.Connect("https://myvcenter/sdk")
c.Login("username", "password")

Dim vmsHosts = c.FindEntityViews(GetType(HostSystem), Nothing, Nothing, Nothing)

For Each evbHostSystem In vmsHosts
    Dim hs = CType(evbHostSystem, HostSystem)

    Console.WriteLine(hs.Name)

    Dim hbas = hs.Config.StorageDevice.HostBusAdapter

    For Each hba In hbas
        Console.WriteLine(hba.Model)

        'hba.portworldwidename is not available...
    Next
Next

Thanks for any help!

Regards, Jan

4

1 回答 1

0

找到了:

您需要获取返回的 HBA 对象的类型。如果是“HostFibreChannelHba”,则需要将其转换为“HostFibreChannelHba”。然后,所有属性都可用。

需要更深入地了解 VI API-Guide :)

Dim hbas = hs.Config.StorageDevice.HostBusAdapter

    For Each hba In hbas
        Console.WriteLine(hba.Model)

        If hba.GetType.Name.Equals("HostFibreChannelHba") Then
            Dim fibreHBA = CType(hba, HostFibreChannelHba)

            Console.WriteLine(String.Format("{0:x}", fibreHBA.PortWorldWideName))
        End If

    Next

问候,扬

于 2013-11-11T11:36:54.860 回答