this may not be optimized. anyway, what it does is to combine all pool members and send traffic to them in round robin fashion.
by the way, cmp is disabled (cmp-enabled no) to make test easier.
configuration
root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm virtual bar
ltm virtual bar {
cmp-enabled no
destination 172.28.24.10:80
ip-protocol tcp
mask 255.255.255.255
profiles {
http { }
tcp { }
}
rules {
qux
}
source 0.0.0.0/0
source-address-translation {
type automap
}
vs-index 3
}
root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm rule qux
ltm rule qux {
return next index
proc getnext { cur max } {
set t [expr { $cur + 1}]
if { $t >= $max } {
return 0
} else {
return $t
}
}
when RULE_INIT {
pool names
set static::pools "foo1 foo2"
create list of pool members
set static::list ""
foreach static::apool $static::pools {
set static::list [concat $static::list [eval "members -list $static::apool"]]
}
total number of pool members
set static::len [llength $static::list]
pool member counter
set static::c 0
}
when HTTP_REQUEST {
flag to prevent indefinite loop
set loop 0
pickup online (up) pool member
to simplify coding, monitor is done on node level instead of pool/pool member level
while { ([LB::status node [lindex [lindex $static::list $static::c] 0]] ne "up") and ($loop <= 1) } {
set static::c [call getnext $static::c $static::len]
if { $static::c == 0 } { incr loop }
}
no pool member is available, so return 500
if { $loop > 1 } {
HTTP::respond 500
return
}
pool member is available, so send to pool member
node [lindex [lindex $static::list $static::c] 0] [lindex [lindex $static::list $static::c] 1]
increase counter
set static::c [call getnext $static::c $static::len]
}
when HTTP_RESPONSE {
log for verification
log local0. "server [IP::server_addr]:[TCP::server_port]"
}
}
root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm pool foo1
ltm pool foo1 {
members {
200.200.200.101:80 {
address 200.200.200.101
}
200.200.200.111:80 {
address 200.200.200.111
}
}
}
root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm pool foo2
ltm pool foo2 {
members {
172.28.24.1:80 {
address 172.28.24.1
}
}
}
test
[root@ve11a:Active:In Sync] config tail -f /var/log/ltm
Nov 25 23:56:37 ve11a info tmm[14890]: Rule /Common/qux : server 200.200.200.111:80
Nov 25 23:56:37 ve11a info tmm[14890]: Rule /Common/qux : server 200.200.200.101:80
Nov 25 23:56:37 ve11a info tmm[14890]: Rule /Common/qux : server 172.28.24.1:80
Nov 25 23:56:37 ve11a info tmm[14890]: Rule /Common/qux : server 200.200.200.111:80
Nov 25 23:56:37 ve11a info tmm[14890]: Rule /Common/qux : server 200.200.200.101:80
Nov 25 23:56:37 ve11a info tmm[14890]: Rule /Common/qux : server 172.28.24.1:80
Nov 25 23:56:37 ve11a info tmm[14890]: Rule /Common/qux : server 200.200.200.111:80
Nov 25 23:56:37 ve11a info tmm[14890]: Rule /Common/qux : server 200.200.200.101:80
Nov 25 23:56:37 ve11a info tmm[14890]: Rule /Common/qux : server 172.28.24.1:80
Nov 25 23:56:37 ve11a info tmm[14890]: Rule /Common/qux : server 200.200.200.111:80