Forum Discussion
andy_12_5042
Nimbostratus
Jul 19, 2011create a pool with members
For some reason I will hit these walls every once in a while as I have to keep wrapping my head around the best way to implement something with pycontrol.
I am trying to figure out the ...
L4L7_53191
Nimbostratus
Jul 22, 2011Andy: have a look here for a helper function that will hopefully be of some value.
http://devcentral-sea.f5.com/wiki/iControl.Pycontrol2DisablePoolMember.ashx
For the impatient, here it is 🙂
def member_factory(b, member):
'''
Produces a Common.IPPortDefinition object per member ip:port combination
object per member ip:port combination. Add these to Common.IPPortDefinitionSequence.
args: a pycontrol LocalLB.PoolMember object and an ip:port
combination that you'd like to add.
'''
ip,port = member.split(':')
pmem = b.LocalLB.PoolMember.typefactory.create('Common.IPPortDefinition')
pmem.address = ip
pmem.port = int(port)
return pmem
Note how the positional arguments are laid out: one is the BIGIP object, the other is ip:port combination you want to create the IPPortDefinition from. Fom here you could do something like (not tested, free form code below!):
members = ['10.10.10.20:80','10.10.10.30:80','10.10.10.40:80']
ipport_objects = [member_factory(b, x) for x in members]
Hope this helps!
-- Matt
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects