Hi,
I'm trying to write a little VB application to automate some things on my VM Infrastructure.
To accomplish this I need to generate a list of all ESX-servers found in virtual center.
As I read the SDK doc's and allready a lot of posts, I need to use/define a propertyCollector.
For now I'm able to connect to Virtual Center using my little VP application, (ignoring the Certificate not trusted error)
I'm able to get build number, version, ...
Also this code works :
Public Sub TestCode()
Dim pSpec As New PropertySpec
pSpec.type = "Folder"
pSpec.all = False
pSpec.allSpecified = True
pSpec.pathSet = New String() {"name"}
Dim oSpec As New ObjectSpec
oSpec.obj = _rootFolder
oSpec.skip = True
Dim _pfSpec As New PropertyFilterSpec
_pfSpec.objectSet = New ObjectSpec() _pfSpec.propSet = New PropertySpec() Dim oCary() As ObjectContent oCary = service.RetrieveProperties(propCol, New PropertyFilterSpec() ) RescanHBAs.ListBox1.Items.Add(oCary.Length) ---> this gives value 1 RescanHBAs.ListBox1.Items.Add(oCary(0).obj.type.ToString) ---> this gives value = Folder RescanHBAs.ListBox1.Items.Add(oCary(0).obj.Value) ---> this gives value = group-d1 RescanHBAs.ListBox1.Refresh() End Sub But when I want to add traversal and recursive things everything goes wrong --> SOAP exceptions ... The code I tried to use for this is ... : Public Sub TestCode() Dim pSpec As New PropertySpec pSpec.type = "Host" pSpec.all = False pSpec.allSpecified = True pSpec.pathSet = New String() {"name"} 'Navigate from ComputeResource to Host Dim cr2hTS As New TraversalSpec cr2hTS.type = "ComputeResource" cr2hTS.skip = False cr2hTS.path = "host" 'Navigate from ComputeResource to Datastore Dim cr2dsTS As New TraversalSpec cr2dsTS.type = "ComputeResource" cr2dsTS.skip = False cr2dsTS.path = "datastore" Dim ccr2hTS As New TraversalSpec ccr2hTS.type = "ClusterComputeResource" ccr2hTS.skip = False ccr2hTS.path = "host" 'Navigate from ClusterComputeResource to Datastore Dim ccr2crTS As New TraversalSpec ccr2crTS.type = "ClusterComputeResource" ccr2crTS.skip = False ccr2crTS.path = "datastore" 'Navigate from Datacenter to hostFolder Dim dc2hTS As New TraversalSpec dc2hTS.type = "Datacenter" dc2hTS.skip = False dc2hTS.path = "hostFolder" Dim SelectionSpec0 As New SelectionSpec SelectionSpec0.name = "traverseChild" dc2hTS.selectSet = New SelectionSpec() 'Navigate from Datacenter to vmFolder Dim dc2vmTS As New TraversalSpec dc2vmTS.type = "Datacenter" dc2vmTS.skip = False dc2vmTS.path = "vmFolder" Dim SelectionSpec1 As New SelectionSpec SelectionSpec1.name = "traverseChild" dc2vmTS.selectSet = New SelectionSpec() 'Navigate from Folder to childEntity Dim traverseChild As New TraversalSpec traverseChild.type = "Folder" traverseChild.skip = False traverseChild.path = "childEntity" traverseChild.name = "traverseChild" Dim SelectionSpec2() = New SelectionSpec() {dc2hTS, cr2hTS, cr2dsTS, ccr2hTS, ccr2crTS, dc2vmTS} traverseChild.selectSet = SelectionSpec2 traverseChild.selectSet(0).name = traverseChild.name Dim oSpec As New ObjectSpec oSpec.obj = _rootFolder oSpec.skip = True oSpec.selectSet = New TraversalSpec() Dim _pfSpec As New PropertyFilterSpec _pfSpec.objectSet = New ObjectSpec()
_pfSpec.propSet = New PropertySpec()
Dim oCary() As ObjectContent
oCary = service.RetrieveProperties(propCol, New PropertyFilterSpec() )
RescanHBAs.ListBox1.Items.Add(oCary.Length)
RescanHBAs.ListBox1.Items.Add(oCary(0).obj.type.ToString)
RescanHBAs.ListBox1.Items.Add(oCary(0).obj.Value)
RescanHBAs.ListBox1.Refresh()
End Sub
But that doesn't work ... and after a weekend trying and trying ...
I decided to post my problem ...
All the help is appriciated ...
Kind regards,
Koen
Don't know which thread you are monitoring. Same answer goes. Again in C#, but the VB.NET translation should be trivial.
Don't know which thread you are monitoring. Same answer goes. Again in C#, but the VB.NET translation should be trivial.