VMware {code} Community
paul_xtravirt
Expert
Expert
Jump to solution

Accessing Host Networking Information

Hey All,

It is nice to see a vb.net example has finally made it on to the dev site Smiley Happy Thanks for that.

I have started to work with it, but am stuck and was hoping someone could help?

I have downloaded the sample code and it runs well, but how do I retrieve all of the vswitches for a specific host? How are where in the following code block would I do this? Thanks in advance.

'Sub gethostinformation()

' Dim OC() As VimApi.ObjectContent

' OC = find_objects(VCConnection, ConnectionDetails.RootFolder, "HostSystem", New String() {"name", "summary"})

' For l As Integer = 0 To OC.Length - 1

' Dim Objects As Array

' Objects = OC(l).propSet

' Dim hostname As String = ""

' Dim Vmotion As Boolean = False

' Dim maxvcpu As Integer = 0

' For i As Integer = 0 To Objects.Length - 1

' Dim DP As New VimApi.DynamicProperty

' DP = Objects(i)

' If DP.name = "name" Then ' here the dynamic property is just a string, so we will retrieve the value of it.

' hostname = DP.val

' End If

' If DP.name = "capability" Then ' here the dynamic property is of the type HostCapability (see SDK reference guide).

' Dim cp As New VimApi.HostCapability

' cp = DP.val

' Vmotion = cp.vmotionSupported

' maxvcpu = cp.maxSupportedVcpus

' End If

' Next

' MsgBox("Host : " + hostname)

' MsgBox(" Vmotion supported : " + Vmotion.ToString)

' MsgBox(" maxSupportedVcpus : " + maxvcpu.ToString)

' Next

'End Sub

If you found this helpful, please consider awarding points

If you found this helpful, please consider awarding some points
0 Kudos
1 Solution

Accepted Solutions
storm27
Enthusiast
Enthusiast
Jump to solution

Hi,

To retrieve all the vswitches for a specific host, you need to drill down to the HostVirtualSwitch property.

The path which leads to the above property is HostSystem->config->network->vswtich.

(Access the config property of the HostSystem managed object in the same way as your code is accessing HostCapability property)

I hope this information is helpful.

Thanks.

Angela

View solution in original post

0 Kudos
1 Reply
storm27
Enthusiast
Enthusiast
Jump to solution

Hi,

To retrieve all the vswitches for a specific host, you need to drill down to the HostVirtualSwitch property.

The path which leads to the above property is HostSystem->config->network->vswtich.

(Access the config property of the HostSystem managed object in the same way as your code is accessing HostCapability property)

I hope this information is helpful.

Thanks.

Angela

0 Kudos