Create LTM Pool Members

Problem this snippet solves:

This example shows how to automate pool member creation with tmsh scripting.

Code :

modify script create_pool.tcl {

proc script::help { } {
    tmsh::add_help "Create a pool with contiguous member addresses\n\
          "
}

proc script::run { } {

    if { $tmsh::argc < 4 } {
        puts "Requires three arguments:    "
        exit
    } else {
        set poolname [lindex $tmsh::argv 1]
        set start [lindex $tmsh::argv 2]
        set total [lindex $tmsh::argv 3]
    }
    scan $start "%d.%d.%d.%d:%d" a b c d p
    set members ""
    for {set x 0} {$x < $total} {incr x} {
        set members "$members $a.$b.$c.$d:$p"
        incr d
        if { $d > 255 } {
            set d 0
            incr c
            if { $c > 255 } {
                set c 0
                incr b
                if { $b > 255 } {
                    set b 0
                    incr a
                }
            }
        }
    }
    tmsh::create /ltm pool $poolname members add \{ $members \}
}

}
Published Mar 10, 2015
Version 1.0
  • May be the first line should be "create cli script create_pool.tcl", which will prompt with editor, add the sections "proc script::run" and "proc script::help" accordingly. And to run the script (tmos)run cli script /Common/create_pool.tcl