Forum Discussion

Derek_Murphy_38's avatar
Derek_Murphy_38
Icon for Nimbostratus rankNimbostratus
Aug 21, 2012

API doc for iControl?

Hi,

 

I was wondering if there was an API doc that explained top level down what was available to call etc. I just installed the icontrol gem for ruby and looked at some of the examples, but was wondering what else I can do and where the best place to start reading would be.

 

 

Specifically my goal is going to be to disable/enable pool members based on a few params passed - pool name and node IP address.

 

 

Any help is most appreciated!

 

 

 

  • I found what I'm looking for: https://devcentral.f5.com/wiki/iControl.LocalLB__Pool__get_member_session_status.ashx

     

     

    However struggling with the above - using version 11.0 for an ltm os.

     

     

    https://devcentral.f5.com/wiki/iControl.LocalLB__Pool__get_member_session_status.ashx for example - what kind of input is it expecting, and in what format (for ruby).

     

     

    I tried

     

    pools = "/Common/my_pool_name"

     

    pool_member_addresses = bigip['LocalLB.Pool'].get_member_session_status(pools, { 'address' => "10.0.20.151", 'port' => "8080"})

     

     

    but that didn't seem to do the trick.

     

     

    Can anyone provide a ruby example of how to disable a node from a pool given a pool name and an ip address?
  • I haven't checked the code to disable the member from the pool, but do have a snippet where i disable the node itself (after I add it).

     

     

    This is using 11.2 F5 iControl GEM.

     

     

    
     Create node if it doesn't already exist.
    unless bigip['LocalLB.NodeAddressV2'].get_list.include? '/Common/' + node_name
      bigip['LocalLB.NodeAddressV2'].create([ node_name ], [ node_address ], [0])
      puts '   Created node "' + node_name + '" with IP Address "' + node_address + '"...'
       After we add a member... let's disable the node state
      bigip['LocalLB.NodeAddressV2'].set_session_enabled_state([ node_name ], [ "STATE_DISABLED" ])
      puts '   Node "' + node_name + '"set to disabled..."'
    else
       puts '   Node "' + node_name + '" already exists! Not Added.'
    end
    

     

     

    Hope it helps.

     

     

  • Darrell,

     

    That's useful. Thanks. I was looking more to figure out syntax. I think if I get enough examples I can work with I can figure out what I need to do.

     

     

    One thing that I was struggling with is pool_member_addresses = bigip['LocalLB.Pool'].get_member_v2([pools])

     

     

    That returns an array of objects, and if I inspect that array, I get the addresses and ports and soap mapping objects, but I don't know how to actually just get the value of addresses.

     

     

    Disclaimer - I'm very new to ruby - so it might be something easy that I'm just overlooking. Any ideas there?
  • Here's a snippet of my updated f5-node-initiator (this was the one good example of pool/node manipulation using the Ruby iControl).

     

     

    collect list of existing pool member definitions

     

    pool_members = bigip['LocalLB.Pool'].get_member_v2([ pool_name ])[0].collect do |pool_member|

     

    pool_member['address'] + ':' + pool_member['port'].to_s

     

    end

     

     

    don't attempt to add member if it already exists

     

    unless pool_members.include?('/Common/' + node_name + ':' + node_port.to_s)

     

    bigip['LocalLB.Pool'].add_member_v2([ pool_name ], [[{ 'address' => node_name, 'port' => node_port.to_i }]])

     

    puts ' Node "' + node_name + ':' + node_port + '" added to "' + pool_name + '" pool...'

     

    else

     

    puts ' Node "' + node_name + ':' + node_port + '" already exists in "' + pool_name + '". Not added.'

     

    end

     

     

    Here's the link to the original: https://devcentral.f5.com/wiki/icontrol.NodeInitiator.ashx

     

     

    Hope it helps.

     

     

    --Darrell G.