Forum Discussion
Kalyan_Reddy_Da
Nimbostratus
Jul 20, 2010Irule with if-elseif to change to Switch-glob
Irule with if-elseif to change to Switch-glob
Please help me if anyone know how to change this if-else-if irule to switch-glob.
when HTTP_REQUEST {
if {([HTT...
hoolio
Cirrostratus
Jul 20, 2010Catch can only ever return 0 or 1 based on whether the command it's executing returns an error or not, so I don't think there is any advantage to using switch. But if you wanted to, you could do this:
set pool_name p_test_$TEST
switch [catch { pool $pool_name } ] {
0 {
No error, so the pool was already assigned and you don't have to do anything more
}
1 {
Error, so do something else
Execute some commands
}
}
Note that catch will run the command in the braces. So you don't have to call the pool command again. You could simplify your original rule like this:
set pool_name p_test_$TEST
if { [catch { pool $pool_name } ] } {
Error assigning pool $pool_name, so do something else
}
Aaron
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
