Forum Discussion

mikegray_198028's avatar
Apr 08, 2016

iapp help for autopopulate

Please see iapp which we are using for auto populate pool member based on DNS look up. This is working perfectly. As per the iapp newly created nodes are using default monitor. I want modify the code to set node monitor to none for all nodes while auto populating using the below iapp

 

set hostnames {}
            foreach row $::pool__hostnames {
                array set columns [lindex $row 0]
                lappend hostnames $columns(hostname)
            }

            set dc [expr { [info exists ::pool__dc] ? $::pool__dc : {} }]

            set script_map [list HOSTNAMES $hostnames NS $::pool__nameserver TYPE $::pool__type NAME $::pool__name PORT $::pool__port DC $dc]

            set script_template {
                tmsh::stateless enabled
                set type TYPE
                set members {}
                foreach hostname { HOSTNAMES} {
                    set ips [exec dig +short @NS $hostname]
                    foreach ip $ips {
                        if { $type eq "ltm" } { 
                            lappend members $ip:PORT
                        } else {
                            tmsh::create gtm server $ip \
                                addresses replace-all-with \{ \
                                    $ip\{ device-name $ip \} \
                                \} \
                                datacenter DC \
                                product generic-host \
                                virtual-servers replace-all-with \{ \
                                    $ip \{ destination $ip:http \} \
                                \}
                            lappend members $ip:[string map { . _ } $ip]
                        }
                    }
                }
                tmsh::create TYPE pool NAME members replace-all-with \{ $members \}
            }
            set icall_script [string map $script_map $script_template]
            tmsh::create sys icall script pool-update-dns \
                definition \{ $icall_script \}
            tmsh::create sys icall handler periodic pool-update-dns \
                interval $::pool__interval script pool-update-dns
No RepliesBe the first to reply