Forum Discussion

elastic_82555's avatar
elastic_82555
Icon for Nimbostratus rankNimbostratus
Sep 24, 2013
Solved

Retrieving VS, pool, and nodes from F5

Hi, Using Chef extensively internally, and now would like to take all the node ip's(hostnames) out of chef, then programatically(using RESTful) interface, query the F5, to retrieve the nodes, pool and untimately the VS ip address. This will allow me to dynamically build a page which can be updated in real-time to allow us a dynamic view of our current network, which will give front end VS(dns/ip's), back end nodes(dns/ip's), then we can populate this further with metadata from chef.

  For now I have been able to pull a list of all front end VS, and all node ip's.  But I am having serious problems trying to successfully get a mapping from node to VS.  Probably I need to iterate over all the pools, but I am unable to get a list of all the pools, for now only a subset....eg...
        curl -k -u admin:password -H "Content-Type: application/json" -X GET https://192.168.1.1/mgmt/tm/ltm/pool?\$expand=* |python -m json.tool</mypassword>
`


This only returns 6 items, basically only "objects"(sorry on terminology), that appear at the root of the /common partition.  It does not appear to go down further.  I have over 50 pools, but seem only to be able to list pools with no path  eg  /common = OK,  /common/Myapp will not display.    I am happy to iterate over them, but for that I would need to understand how to get a list to iterate over in the first place.   

`    Would be happy to do this over iControl soap interface instead, if that is easier, but the RESTful interface just seems easier.   

                 Any help or advice greatly appreciated.

                                                                                                         Sc0tt...
  • Example Python code:

     

    try:
        logging.info("Connecting to BIG-IP and pulling statistics...")
        b = bigsuds.BIGIP(hostname=ltm_host, username=user, password=password)
        logging.info("Requesting session...")
        b = b.with_session_id()
    except bigsuds.Connecti , detail:
        logging.critical("Unable to connect to BIG-IP. Details: %s" % pformat(detail))
        sys.exit(1)
    logging.info("Setting recursive query state to enabled...")
    b.System.Session.set_recursive_query_state(state='STATE_ENABLED')
    logging.info("Switching active folder to root...")
    b.System.Session.set_active_folder(folder="/")

6 Replies

  • From withing tmsh, the pool can be retreived as follows:- list ltm pool Myapp_as.app/Myapp_as_pool However, this syntax does not seem to work via the RESTful interface, ie... curl -k -u admin:password -H "Content-Type: application/json" -X GET https://192.168.1.1/mgmt/tm/ltm/pool/Myapp_as.app/Myapp_as_pool |python -m json.tool
  • Hi, Just some further information. The additional pools I am trying to retireve from the RESTful interface are created by iApps, and take the form as follows:- /Common/Myapp_as.app Myapp_as_pool This may be the reason why I cannot retrieve them, so it is probably something fundamental I am missing/doing. thanks Sc0tt....
  • Not sure how to do this with the REST API, but you need to set recursive mode on. Otherwise you'll receive only the current partition and not its subfolders.

     

  • Hi, Thanks for the suggestion, and not aware of how do do this with the REST API, but I also tried the same on the SOAP API, and again I get the same answer, with all the missing servers, so I also don't know how to turn recursive mode on for the SOAP API. Any hints on how to do so, appreciated.

     

  • Example Python code:

     

    try:
        logging.info("Connecting to BIG-IP and pulling statistics...")
        b = bigsuds.BIGIP(hostname=ltm_host, username=user, password=password)
        logging.info("Requesting session...")
        b = b.with_session_id()
    except bigsuds.Connecti , detail:
        logging.critical("Unable to connect to BIG-IP. Details: %s" % pformat(detail))
        sys.exit(1)
    logging.info("Setting recursive query state to enabled...")
    b.System.Session.set_recursive_query_state(state='STATE_ENABLED')
    logging.info("Switching active folder to root...")
    b.System.Session.set_active_folder(folder="/")
  • Hi, Yes, that was the magic. Using the ruby icontrol, and using the example filelist-virtual-servers.rb, here are the code changes

     

    bigip = F5::IControl.new(bigip_address, bigip_user, bigip_pass, ["LocalLB.VirtualServer", "LocalLB.Rule", "System.Session"]).get_interface   
       sapi = bigip["System.Session"]
       puts "recursive query state = ", sapi.get_recursive_query_state.to_s
     sapi.set_recursive_query_state(state='STATE_ENABLED')
     puts "recursive query state = ", sapi.get_recursive_query_state.to_s
    
     The rest of the code is left as is, and this produces the entire list.   

    Also for further reference, used the following links to fill in the background on "folders" with F5.

     

    https://devcentral.f5.com/articles/icontrol-101-24-folders

     

    many thanks