For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

spirrello_22970's avatar
spirrello_22970
Icon for Nimbostratus rankNimbostratus
Nov 10, 2015

Create Empty Pool with iControl in Python

Hi,

 

I'm trying to build an empty pool before it's populated at a later date. When I try running the following code it keeps complaining about missing the members parameter. From what I've read, you have to include a list of server/port combinations but we won't have anything to add at this time. Is there anyway around this? I've been able to do this in LTM gui but no luck via python.

 

lb_obj = pc.BIGIP(hostname = lb_ip,username = 'neo',password = acct,fromurl = True,wsdls = ['LocalLB.Pool'])

 

lb_obj.LocalLB.Pool.create(pool_names = [pool_name], lb_methods = ['0'])

 

3 Replies

  • Hello Spirello,

     

    To create an empty pool you have to pass empty member list.

     

    members list is mandatory for the create function, so the following code should be ok:

     

    lb_obj.LocalLB.Pool.create(pool_names = [pool_name], 
                               lb_methods = ['LB_METHOD_ROUND_ROBIN'],
                               [[]])

    Best Regards,

     

    Guillaume

     

  • Thanks Guillaume. I've tried that but it didn't work.

     

    spirrello@ubuntu1:~/scripts$ python f5.py File "f5.py", line 244 lb_obj.LocalLB.Pool.create(pool_names = [pool_name], lb_methods = ['LB_METHOD_ROUND_ROBIN'],[[]]) SyntaxError: non-keyword arg after keyword arg

     

  • Hi,

     

    It's a python code issue, my bad.

     

    As you pass the first parameters with keywords args (pool_names= and lb_methods=) you have to pass the third with keywords args too, or the 3 parameters without keywords args.

     

    So the code below should work:

     

     lb_obj.LocalLB.Pool.create(pool_names = [pool_name], 
                                lb_methods = ['LB_METHOD_ROUND_ROBIN'],
                                members=[[]])

    or:

     

    lb_obj.LocalLB.Pool.create([pool_name], 
                               ['LB_METHOD_ROUND_ROBIN'],
                               [[]])

    Regards,

     

    Guillaume