Forum Discussion

stecino_87658's avatar
stecino_87658
Icon for Nimbostratus rankNimbostratus
Jan 29, 2016

Node to Pool to VIP referencing in IControl

Hello,

 

Want to know how I gather info where node will reference to pools it's in, and pools assignments to VIP(s) NodeAddressV2.get_metadata supposed to give me this info, but I am getting empty list.

 

Thanks in advance

 

3 Replies

  • Unless you're using metadata capable config (MCC) objects, you won't see that information. However, it's easy to build a reverse lookup using API.

    Here's an example using python (bigsuds). For simplicity, I'm storing the list of pools and their members locally and using a known node name, but this can easily be iterated.

    import bigsuds
    
      Node to search for
    node = '/Common/1.2.3.4'
    print "Pools using Node "+node
    
      Connect to BIG-IP
    b = bigsuds.BIGIP(hostname, username, password)
    
      Get list of pools and pool members
    pools = b.LocalLB.Pool.get_list()
    members = b.LocalLB.Pool.get_member_v2(pools)
    
      Iterate through pool member list (has a list of members per pool referenced) looking for node
    for i, pool in enumerate(pool_members):
        for member in pool:
            if member['address'] == node:
              print "\t"+pools[i]
    

    and here's the same for Pools to Virtual Servers:

    import bigsuds
    
      Pool to search for
    pool = '/Common/my_pool'
    print "Virtual Servers using Pool "+pool
    
      Connect to BIG-IP
    b = bigsuds.BIGIP(hostname, username, password)
    
      Get list of pools and pool members
    virtual_servers = b.LocalLB.VirtualServer.get_list()
    vs_pools = b.LocalLB.VirtualServer.get_default_pool_name(virtual_servers)
    
      Iterate through pool member list (has a list of members per pool referenced) looking for node
    for i, vs_pool in enumerate(vs_pools):
        if pool == vs_pool:
          print "\t"+virtual_servers[i]
    
    • stecino_87658's avatar
      stecino_87658
      Icon for Nimbostratus rankNimbostratus
      Thanks for the feedback, I was trying to avoid having to do that :) This will be pretty expensive query every time i run it. I may have to cache for some short period of time vip and pool list to make this faster
    • Theo_12742's avatar
      Theo_12742
      Icon for Cirrus rankCirrus
      I actually offload to a MySQL database and give each property a "cache for" value. Thus it pulls certain data less often. This is just the "magic sauce" behind the program. Happy coding!