Forum Discussion

Aled_2623's avatar
Aled_2623
Icon for Nimbostratus rankNimbostratus
Sep 18, 2013

Bigsuds - How to enable / disable certain pool members?

Hello all, this is my first post here, to quickly introduce myself - I'm Aled, I work in London (GB) for an online gaming company. I'm currently getting an automated deployment system in place for Continuous Intergration and the part I'm struggling with is automating the BigIP loadbalancer pools which brings me to my question:

 

Here's what I'm trying to achieve, for an automated web deployment I need to disable half the pool members for a given Loadbalanced Pool, and then re-enable them post deployment. Then disable the other half of the pool members and re-enable them post deployment too.

 

So I need a way to disable pool members and to specify which pool members to disable and vice versa.

 

Ive been reading a lot about Bigsuds and I'm very impressed by this and the whole iControl system. I've played around with this within python and can access the BigIP appliance and display pools etc., but I cant figure out the code I need to do the above.

 

I was hoping it would be something like this...

 

b.LocalLB.PoolMember.set_session_enabled_state(pool_names = ['poolnamehere'], members = ['10.10.10.10:80', '10.10.10.11:80'], session_states = ['STATE_ENABLED'], [1])

This doesnt work, Ive got the syntax wrong and its probably not as simple as that.

 

Can anyone help please? Let me know if you need more info etc..

 

Thanks Aled

 

  • A couple syntax issues, and you need to change both the session and monitor states:

    >>import bigsuds
    >>b = bigsuds.BIGIP('192.168.6.5')
    >>pl = b.LocalLB.Pool
    
    >>> pl.get_member_session_status(['/Common/testpool_alt'],  [[{'address': '192.168.101.22', 'port': 80}]])
    [['SESSION_STATUS_ENABLED']]
    >>> pl.get_member_monitor_status(['/Common/testpool_alt'],  [[{'address': '192.168.101.22', 'port': 80}]])
    [['MONITOR_STATUS_UP']]
    
    
    >>> pl.set_member_monitor_state(['/Common/testpool_alt'], [[{'address': '192.168.101.22', 'port': 80}]], [['STATE_DISABLED']])
    >>> pl.get_member_session_status(['/Common/testpool_alt'],  [[{'address': '192.168.101.22', 'port': 80}]])
    [['SESSION_STATUS_ENABLED']]
    >>> pl.get_member_monitor_status(['/Common/testpool_alt'],  [[{'address': '192.168.101.22', 'port': 80}]])
    [['MONITOR_STATUS_FORCED_DOWN']]
    
    
    >>> pl.set_member_session_enabled_state(['/Common/testpool_alt'], [[{'address': '192.168.101.22', 'port': 80}]], [['STATE_DISABLED']])
    >>> pl.get_member_session_status(['/Common/testpool_alt'],  [[{'address': '192.168.101.22', 'port': 80}]])
    [['SESSION_STATUS_FORCED_DISABLED']]
    >>> pl.get_member_monitor_status(['/Common/testpool_alt'],  [[{'address': '192.168.101.22', 'port': 80}]])
    [['MONITOR_STATUS_FORCED_DOWN']]
    
  • ah, so if you're on an older version, you'll need to use the PoolMember interface. You might need to play with the syntax a little, I don't have an older box at my disposal currently to test. It should look similar to this:

    b.LocalLB.PoolMember.set_monitor_state(['Common/testpool_alt'],[[{'address': '192.168.101.22', 'port': 80}], ['STATE_DISABLED']])
    b.LocalLB.PoolMember.set_session_enabled_state(['Common/testpool_alt'],[[{'address': '192.168.101.22', 'port': 80}], ['STATE_DISABLED']])
    
  • Try this:

    b.LocalLB.PoolMember.set_monitor_state(['GCUat'], [[{'member': {'address': '10.10.10.10', 'port': 80}, 'monitor_state': 'STATE_DISABLED'}]])
    b.LocalLB.PoolMember.set_session_enabled_state(['GCUat'], [[{'member': {'address': '10.10.10.10', 'port': 80}, 'session_state': 'STATE_DISABLED'}]])
    
  • Brent_West_7733's avatar
    Brent_West_7733
    Historic F5 Account

    You only need to disable the monitor states also if you want to "Force offline" instead of "Disable"

     

    I think you need to set the state in the array for each member, i.e array1 = member1, member2, member3 array2 = member1_state, member2_state, member3_state

     

    This is how iControl works in other languages, less familiar with bigsuds/python.

     

    • JRahm's avatar
      JRahm
      Icon for Admin rankAdmin
      true, I assumed force offline was the goal, but it wasn't explicitly stated.
    • Aled_2623's avatar
      Aled_2623
      Icon for Nimbostratus rankNimbostratus
      Thanks for the additional info Brent, for what I'm trying to achieve right now, I would be just disabling the pool members and allowing some time for the connections to drain. But in the near future I will probably need to force some pool members offline, so its good to know how to do this too. I'll have to look into setting up a python array for the pool members, but right now I can proceed with a command for each pool member, these arent large pools, so not really an issue at the moment. Thanks, Aled