Forum Discussion
iControl + Python + add_member / remove_member
- Global variables, evil.
- remove_member is deprecated, use remove_member_v2 for V11 F5
- You pass global members into session_objects function parameter to delete_member... then you don't reference it. Why?
- You pass global 'members' to "remove_member" API call. It's the wrong type -- you are supposed to pass a sequence of IPPortDefinition.
I have a complete solution I've written for my current employer. Would love it if I could just post it but I don't have that freedom at this point. That being said, something like this works:
def f5_build_address_port_seq(b, addressport): addressportseq = b.LocalLB.Pool.typefactory.create('Common.AddressPortSequence') addressportseq.item = addressport return addressportseq def f5_build_address_port(b, address, port): addressport = b.LocalLB.Pool.typefactory.create('Common.AddressPort') addressport.address = address addressport.port = port return addressport def f5_remove_pool_member_v11(b, poolname, address, port): addressport = f5_build_address_port(b, address, port) addressportseq = f5_build_address_port_seq(b, addressport) b.LocalLB.Pool.remove_member_v2(pool_names=[poolname], members=[addressportseq])
Then you just run:
f5_remove_pool_member_v11(b, poolname, address, port)
As an aside, if I were doing this from scratch, I'd be using bigsuds and not pycontrol.
mhite,
Thanks for your insights with the code snippets. I was able to patch/cobble together the rest of the script required to do the necessary operations for the moment.
As I learn python more in-depth, I'm sure that I'll be able to craft much better code than that currently hacked upon; I don't like using other people's code for the reason that it inhibits my own learning, but deadlines are deadlines and I needed to get something out quick and most of the framework was there with the base script linked to above... just needed to bolt a few extra things on 😃
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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
