Forum Discussion
Maciej_Waliszko
Nimbostratus
May 08, 2016irule - syntax error, what is wrong with my irule?
Hello,
I am trying to write a simple irule but I am getting error. I have no clue why. Can anybody have a look at it and explain me what I am doing wrong? Thank you.
when HTTP_REQUEST {
...
Stanislas_Piro2
Cumulonimbus
May 09, 2016Hi,
this irule may help you to manage pool assignment in a array:
when RULE_INIT {
array set static::V1_P_NSIVM {
"212.222.10.211%1" V1_P_NSIVMQ1
"212.222.10.212%1" V1_P_NSIVMQ2
"212.222.10.213%1" V1_P_NSIVMQ3
}
}
when HTTP_REQUEST {
if {[info exists static::V1_P_NSIVM([IP::client_addr])] && ([active_members $static::V1_P_NSIVM([IP::client_addr])] == 1 )} {
pool $static::V1_P_NSIVM([IP::client_addr])
}
else pool V1_P_NSIVMQ1-3
}
}
Or if you create a pool with only one member, you can assign pool member in the irule instead (with this irule, the pool V1_P_NSIVMQ1-3 may be assigned to the VS):
when RULE_INIT {
array set static::V1_P_NSIVM {
"212.222.10.211%1" {1.1.1.1 80}
"212.222.10.212%1" {1.1.1.2 80}
"212.222.10.213%1" {1.1.1.3 80}
}
}
when HTTP_REQUEST {
set default_pool [LB::server pool]
if {[info exists static::V1_P_NSIVM([IP::client_addr])]} {
set member(ip) [lindex $static::V1_P_NSIVM([IP::client_addr]) 0]
set member(port) [lindex $static::V1_P_NSIVM([IP::client_addr]) 1]
if { [LB::status pool $default_pool member $member(ip) $member(port)] eq "up" }} {
pool $default_pool member $member(ip) $member(port)
}
unset member
}
unset default_pool
}
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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