VMware {code} Community
DroppedAtBirth
Contributor
Contributor

FindEntityViews inconsistent results

I am having a problem with FindEntityViews giving inconsistent results. The code gets a datacenter then loops thru the host in the datacenter, the problem is one of the datacenters has 2 standalone host, sometimes the code returns only 1 of the host and sometimes it returns both. It seems to be the same datacenter everytime, but also noticed another issue. Both host have 3 vm's on them, but when only 1 host is returned it only sees 2 vm's on that host... Any ideas?

'Get DataCenter Info

Dim filter As NameValueCollection = New NameValueCollection()

filter.Add("name", DataCenterName)

Dim dc As Datacenter = DirectCast(vc.FindEntityView(GetType(Datacenter), Nothing, filter, Nothing), Datacenter)

'Get ComputeResources

Dim CRList As IList(Of EntityViewBase) = vc.FindEntityViews(GetType(VMware.Vim.ComputeResource), dc.MoRef, Nothing, Nothing)

For Each CR As ComputeResource In CRList

'Refresh the state of each view

CR.UpdateViewData()

'Get List of Host

Dim HostList As IList(Of EntityViewBase) = vc.FindEntityViews(GetType(HostSystem), CR.MoRef, Nothing, Nothing)

Next

Tags (1)
0 Kudos
0 Replies