Forum Discussion

d2_21508's avatar
d2_21508
Icon for Nimbostratus rankNimbostratus
Jan 20, 2014

pyControl v2 - get pools and partitions assignments

Hello,

 

I am using F5 BIGIP v10.2.x with pyCotrol v2 and I'd like to ask how can I display all available pools and their assignment to partition. Output should be similar to the one I see from GUI (Partition:[All]) when I go to LocalTraffic->Pools. Is it possible with pyControl v2?

 

6 Replies

  • Can speak to v11, not v10.

     

    First, use this call to switch into "/":

     

    https://devcentral.f5.com/wiki/iControl.System__Session__set_active_folder.ashx

     

    Next, set the recursive state enabled:

     

    https://devcentral.f5.com/wiki/iControl.System__Session__set_recursive_query_state.ashx

     

    Then use this call to retrieve the list of pools:

     

    https://devcentral.f5.com/wiki/iControl.LocalLB__Pool__get_list.ashx

     

    The pool name will be prefaced by the partition/folder.

     

  • Thanks mhite. Unfortunately, call 'set_recursive_query_state' is not present on 10.2 and there seems to be no equivalent command (GlobalLB.Globals.set_use_recursion_bit_state is not the same). All others seems to be present: setting active folder -> Management.Partition.set_active_partition and getting pool list -> LocalLB.Pool.get_list.

     

    In the meantime I did following code:

     

            print '[*] available pools and partition assignments:'
            partitionlist=f5.Management.Partition.get_partition_list()
            poollist = f5.LocalLB.Pool.get_list()
            print "%6s %50s %20s" % ("id", "pool", "partition")
            for activepartition in partitionlist:
                f5.Management.Partition.set_active_partition(activepartition.partition_name)
                for pool in poollist:
                    try:
                        f5.LocalLB.Pool.get_object_status(pool_names = [pool])[0]
                        print "%6s %50s %20s" % (index, pool, activepartition.partition_name)
                        index=index+1
                    except:
                        continue

    but as you can imagine it is taking too much time to complete (up to 3minutes with 4 partitions and 300 total pools).

     

    Does anyone have better idea how to complete such assignment?

     

    PS. When I go to Local Traffic -> Pools, following call is being made:

     

    /tmui/Control/jspmap/tmui/locallb/pool/list.jsp?Filter=*

    So this must be possible from iControl v10.2.x too.

     

  • RE: Management.Partition.set_active_partition -- it sounds like if you set it to "[All]" it will automatically set recursive query enabled. See:

     

    https://devcentral.f5.com/wiki/iControl.Management__Partition__set_active_partition.ashx

     

    This method is deprecated; please use System::Session::set_active_folder instead. Sets the active partition for the current user. The active partition is the administrative partition where all configuration will take place until a new active partition is selected. Each user can only be in one active partition at any given time. By default, if not explicitly set, the active partition for a user will be "Common". Note: Please note that this method is deprecated. If you set the partition to "[All]", this maps to the System::Session interface method set_active_folder("/") and in this case this method automatically performs set_recursive_query_state(STATE_ENABLED) as well. The method uses set_active_folder, so if the partition you specify maps to no existing top-level folder it will tell you the folder doesn't exist and behave in all respects as set_active_folder does.

     

  • Basically when I do

    f5.Management.Partition.set_active_partition('[All]')
    poollist = f5.LocalLB.Pool.get_list()
    print poollist
    

    I am getting pool names without any extra attributes or strings.

    • JRahm's avatar
      JRahm
      Icon for Admin rankAdmin
      you will probably need to iterate through the known partitions and build your list that way. The UI combines methods to build the views that you need to do procedurally with iControl.