Forum Discussion

williambb_9960's avatar
williambb_9960
Icon for Nimbostratus rankNimbostratus
Sep 28, 2009

Get Node Status in Visual Basic

I've been beating my head on sharp corners for a couple of days on this issue and am deferring to the experts. I'm fairly new to VB and very new to iControl. We're running LTM 9.3.1 and I need to get a list of nodes for an LTM and their enabled status. In my code below I'm getting an error on NodeName(0) passed to get_session_enabled_state of "Value of type 'string' cannot be converted to '1-dimensional array of String'."

 

 

Any help with this? (I have to use VB - we've adopted it as a standard for all development)

 

 

Module Module1

 

 

Sub Main()

 

Dim objLTM As New iControl.Interfaces()

 

objLTM.initialize(MyLTM, MyUID, MyPassword)

 

Dim arrNodes() As String = objLTM.LocalLBNodeAddress.get_list

 

Dim NodeName(0) As String

 

NodeName(0) = Node

 

Dim NodeState = New iControl.LocalLBEnabledStatus

 

NodeState = objLTM.LocalLBNodeAddress.get_session_enabled_state(NodeName(0))

 

Console.WriteLine(Node, " --> ", NodeState)

 

Next

 

End Sub

 

 

End Module

3 Replies

  • The error is correct. The get_session_enabled_state method looks like this:

     

     

     EnabledState [] get_session_enabled_state( 
       in String [] node_addresses 
     );

     

     

    It takes as input a string array of node_addresses you wish to query. You can just use the value returned from the LocalLB.NodeAddress.get_list() method. In your code you are passing in a single string, not the array. If you wish to query only a single object, then you'll need to create an array of size 1 and include the value you wish to query in there. Also, the value you are assigning the output to is of type iControl.LocalLBEnabledStatus while that should be an array as well to account for each of the objects passed in the node_addresses parameter.

     

     

    The reason we designed the API to take arrays instead of singular values was to help with large configurations. For systems with 1000's of node addresses, it's much easier to make one call than 1000+ of them. And since we have close to 3000 methods in the iControl API it was too much on our side to implement 2 sets of methods to handle both bulk and single method calls.

     

     

    Give this a shot:

     

     

     Dim node_list() As String = m_interfaces.LocalLBNodeAddress.get_list() 
     Dim node_statuses() As iControl.LocalLBEnabledStatus 
     node_statuses = m_interfaces.LocalLBNodeAddress.get_session_enabled_state(node_list) 
     For i As Integer = 0 To node_list.Length - 1 
       Console.WriteLine("Node " & node_list(i) & " -> " & node_statuses(i).ToString()) 
     Next

     

     

    In the future, for reference you can check out the iControl API reference wiki.

     

     

    http://devcentral.f5.com/wiki/default.aspx/iControl/APIReference.html

     

    Click here

     

     

     

    Hope this helps...

     

     

    -Joe
  • Beautiful. Thx much Joe. I've been digging through the SDK and code shares but wasn't able to follow the iControl object references. I'm getting there and so far the iControl has a pretty sweet feature set.
  • Great. Please don't be shy in asking questions. We'll do our best to help you out.

     

     

    One side note: move to C, it's much more intuitive (for me at least) B-)

     

     

    -Joe