Forum Discussion

Antonio_Varni's avatar
Antonio_Varni
Icon for Nimbostratus rankNimbostratus
Jun 26, 2010

any way to set_active_partition 'all' or 'any' ?

I want to read all pool and virtual services into a mysql database. Now that I've started moving objects into their own partitions, I'm trying to find a way to get these objects 'all in 1 pass' instead of getting a list of all partitions, and fetching pool and virtual service objects for each one. My api user has access to 'all partitions'. Does the F5 native GUI's Partition 'All [Read Only]' have an easy iControl equiv? Or is it iterating through all partitions also, behind the scenes? thx

5 Replies

  • Unfortunately, iControl only works one partition at a time. If you have objects spread across multiple partitions, then you will have to work one partition at a time. You can switch with the Management.Partition.set_active_partition method.

     

     

    -Joe

     

  • ... UPDATE ...

    In playing around with the Python interface, and hoping to find a view similar to the web UI that shows information about all partitions, I found you can set the partition to "[All]".

    For example, the following will...

    1) print a list of partitions

    2) set active partition to "[All]"

    3) confirm active partition

    4) print a list of all virtual servers found under the "[All]" partition view (which is presumably read-only.

    
    
    import suds
    import pycontrol.pycontrol as pc
    
    print "Initialize LTM object..."
    ltm = pc.BIGIP(
    hostname = 'x.x.x.x',
    username = 'wintermute',
    password = 'ice',
    fromurl = True,
    wsdls = [
    'Management.Partition',
    'GlobalLB.VirtualServer',
    'LocalLB.VirtualServer',
    'GlobalLB.Pool',
    'LocalLB.Pool'
    ])
    
    print "Listing all partitions..."
    partitions = ltm.Management.Partition.get_partition_list()
    for partition in partitions:
     print "\t%s" % partition.partition_name
    
    partition = '[All]'
    print "Attempting to set active partition to '%s'" % partition
    try:
    ltm.Management.Partition.set_active_partition(partition)
    except:
    print "error"
    raise
    
    print "Current Partition: " + ltm.Management.Partition.get_active_partition()
    
    print "List of GlobalLB VirtualServer objects..."
    g_vservers = ltm.GlobalLB.VirtualServer.get_list()
    for server in g_vservers:
     print "\t%s" % server
    
    print "List of LocalLB VirtualServer objects..."
    l_vservers = ltm.LocalLB.VirtualServer.get_list()
    for server in l_vservers:
     print "\t%s" % server
    
    exit()
    
     
  • Ives beat me to it, though I have a caveat for that post: The Management::Partition interface is deprecated as of version 11.0.0 (see Management::Folder and System::Session as alternatives). Here is what I was going to demonstrate, as follows. Be aware that you may not want to do any create/write operations with "/" as your active folder.

     

     

    >>> b.LocalLB.Pool.get_list()

     

    ['/Common/p2', '/Common/p1']

     

    >>> b.System.Session.get_recursive_query_state()

     

    'STATE_DISABLED'

     

    >>> b.System.Session.set_recursive_query_state('STATE_ENABLED')

     

    >>> b.System.Session.get_recursive_query_state()

     

    'STATE_ENABLED'

     

    >>> b.System.Session.get_active_folder()

     

    '/Common'

     

    >>> b.System.Session.set_active_folder(folder='/')

     

    >>> b.System.Session.get_active_folder()

     

    '/'

     

    >>> b.LocalLB.Pool.get_list()

     

    ['/Common/C1114967.app/C1114967_pool', '/Common/p2', '/Common/p1', '/mypart/p3']

     

     

    So you can get all your information that way. BTW Partition "[All]" maps to "/" internally (and it sets recursive query -- but again, the Partition interface is deprecated).
  • This link helped me in solving the problem. Here is the snippet for java based implementation.

     

    String currentActivePartition = interfaces.getManagementPartition().get_active_partition(); interfaces.getManagementPartition().set_active_partition("[All]");

     

    /* other iControl calls */

     

    interfaces.getManagementPartition().set_active_partition(currentActivePartition);