Forum Discussion
Irule Switch statment & Datagroup question
- Mar 18, 2016
It selects a single node based on the client source IP. Concretely, if the source IP from the client is "10.10.10.10" the call to class match matches the first record (the record with the key "10.10.0.0/16"). The -value flag tells the class command to return the record value if there is a match (or the empty string if there is no match). So, in this example case, the variable PAN_node is set to "A1" (the value of the matching class record). The switch matches "A1", so the command node 10.29.170.5 executes. This instruct the load-balancing engine to specifically proxy (or forward, depending on the Virtual Server type) to that node.
In Tcl, a switch does not fall through like it does in C. The code block for the first matching case is executed, then the switch terminates (unless '-' is substituted in place of the code block, which is not the case here).
sorry for the typo, the iRule should be like following:
ltm rule Data-rule {
when CLIENT_ACCEPTED {
set A_node [class match -value [IP::client_addr] equals Data1]
switch $A_node {
A1 {node 10.29.170.5}
A2 {node 10.29.170.6}
XA {node 10.29.196.40}
}
}
}
Recent Discussions
Related Content
* 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