Forum Discussion

Nate_W_50838's avatar
Nate_W_50838
Historic F5 Account
Jan 29, 2009

Problem disabling pool member via pyControl

I'm trying to write a very basic python script to add a pool member to an existing pool, then disable it. My script is this:

 

 

!/usr/bin/env python

 

 

import pycontrol.pyControl as pc

 

from pycontrol.Utils import show_status

 

 

b = pc.BIGIP(hostname='172.24.42.13', username='admin', password='admin',wsdl_files=['LocalLB.PoolMember','LocalLB.Pool'])

 

mbr = b.LocalLB_PoolMember

 

pl = b.LocalLB_Pool

 

 

new_member = [[{'address':'10.10.10.111', 'port':80}]]

 

pl.add_member(pool_names=['mypool'], members=new_member)

 

pc.disable_member(pool=['mypool'], member=[{'address':'10.10.10.111', 'port':80}])

 

 

However when I run it, I get an error of:

 

 

Loading WSDL: LocalLB.PoolMember.wsdl

 

Loading WSDL: LocalLB.Pool.wsdl

 

Traceback (most recent call last):

 

File "C:\Python25\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 309, in RunScript

 

debugger.run(codeObject, __main__.__dict__, start_stepping=0)

 

File "C:\Python25\Lib\site-packages\pythonwin\pywin\debugger\__init__.py", line 60, in run

 

_GetCurrentDebugger().run(cmd, globals,locals, start_stepping)

 

File "C:\Python25\Lib\site-packages\pythonwin\pywin\debugger\debugger.py", line 624, in run

 

exec cmd in globals, locals

 

File "C:\scripts\test.py", line 12, in

 

pc.disable_member(pool=['mypool'], member=[{'address':'10.10.10.111', 'port':80}])

 

TypeError: disable_member() takes at least 1 non-keyword argument (0 given)

 

 

I'm pretty new to Python, but I can't figure out what non-keyword argument disable_member() is looking for. Help!
  • Nate_W_50838's avatar
    Nate_W_50838
    Historic F5 Account
    Ah nevermind, RTFM there is example code for this at http://devcentral.f5.com/wiki/default.aspx/iControl/pyControlTogglePoolMember.html
  • Glad you're working! This brings up a good point though, and it's worth explaining it a bit as it'll almost certainly affect future additions to the Utils module for pyControl. The utility functions that are added are convenience functions that will hopefully save some cycles for folks. Because of this, we try and keep them generic and flexible. The requirement is that you pass a valid "pool member" object to the function to disable the member. This allows us to pass in different objects that refer to different systems.

     

     

    A possible use case would be to create a pool member object for both the active and standby systems in a pair, and make a call to each system to disable the pool member in question(and you didn't want to do a config sync). That way if a failover were to occur you'd have two systems that were at parity with respect to the pool in question.

     

     

    Thanks for the post.

     

     

    -Matt