Forum Discussion
Lee_56244
Jul 16, 2012Nimbostratus
Datagroup/Class Containing List of Pools Configured on v10.x LTM
I have a configuration that requires iRule to select the pool based on the pool's name.
Is there a datagroup/class containing a list of pools automatically available? if so, what is the name? When does it get updated?
If there is not, what would be the best way to automate creation and maintenance of a class containing a list of pools?
thanks!
- nitassEmployeeIs there a datagroup/class containing a list of pools automatically available? if so, what is the name? When does it get updated?i do not think there is. not sure if running bigpipe or tmsh periodically, i.e. cron, to configure data group containing all pool name is a good approach.
- hooleylistCirrostratusHere's a lightly tested script I wrote for writing the virtual server IP:ports to a data group. You could modify this to write the pool names to a data group.
To use this script: 1. Access tmsh by typing 'tmsh' at the BIG-IP command line 2. Delete the pre-existing script text by typing: '100 dd' 3. Change to paste mode by typing: ':set paste' 4. Change to insert mode by typing 'i' 5. Paste in the script below starting with the line 'create script...' 6. Save the script by typing: 'escape', ':x' and then 'y' to confirm' 7. From the bash shell, set the tmsh global-setting to return the virtual server ports as numbers instead of service names using the following command: tmsh modify cli global-settings service number 8. Save the configuration to disk by typing 'save sys config' 9. Create a shell script to call the tmsh script 10. Create an external monitor which calls the shell script. 11. Create a dummy pool to associate the monitor with 12. Assign the external monitor to a dummy pool with an interval of the time in seconds you want to run this script. create script /Common/write_virtuals_to_dg.tcl { Write each virtual server destination IP:port to a string data group These are the equivalent tmsh commands to create/modify a string data group: create ltm data-group internal vs_ip_ports_dg type string records replace-all-with { 1.1.1.1:80 { data "vs1" } } modify ltm data-group internal vs_ip_ports_dg records replace-all-with { 1.1.1.1:80 { data "vs1" } } proc script::init {} { Write debug to stdout? 2=verbose, 1=minimal, 0=none. set ::debug 1 if { $::debug } {puts "[string repeat x 100]\n\nRunning script [lindex $tmsh::argv 0]\n"} Name of data group to write VS IP:ports to set ::vs_ip_ports_dg "vs_ip_ports_dg" Check if data group already exists if { [catch {tmsh::get_config /ltm data-group internal $::vs_ip_ports_dg } result] } { if { $::debug } {puts "Creating new empty data group $::vs_ip_ports_dg\n"} tmsh::create /ltm data-group internal $::vs_ip_ports_dg type string } else { if { $::debug } {puts "Data group $::vs_ip_ports_dg exists\n"} } } proc script::run {} { Set tmsh to use service numbers instead of names tmsh::modify cli global-settings service number Initialize a variable to save the VS IP:port destinations Example command for replacing data-group contents: modify ltm data-group internal vs_ip_ports_dg records replace-all-with { 1.1.1.1:80 { data "vs1" } 2.2.2.2:80 { data "vs2" }} set tmsh_modify_cmd "/ltm data-group internal $::vs_ip_ports_dg records replace-all-with { " Loop through each VS destination if { $::debug > 1} {puts "List of virtual servers and their destination IP:ports"} foreach {virtual} [tmsh::get_config /ltm virtual] { if { $::debug>1} {puts "[tmsh::get_name $virtual]: [tmsh::get_field_value $virtual destination]"} append tmsh_modify_cmd "[tmsh::get_field_value $virtual destination] { data [tmsh::get_name $virtual] } " } Add the closing curly brace append tmsh_modify_cmd "}" Run the modify command to update the data group if { $::debug } { puts "Running command: tmsh::modify $tmsh_modify_cmd" } tmsh::modify $tmsh_modify_cmd } }
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects