Forum Discussion
dlg_23340
Nov 18, 2011Cirrus
[class exists $redir_class]
Hello, all. I have an irule that needs to check if a class exists, then if it does, pull a record from it. If not, it should do nothing. in this case, the value contained in redir_class does not ex...
George_Watkins_
Nov 18, 2011Historic F5 Account
Hi David,
It looks like you're almost there. One thing that I think may be throwing you off is the logging messages. The curly braces around your log commands will prevent variable substitution and command execution. Here is the iRule and datagroup I used to test with.
ltm data-group internal /Common/test_vars {
records {
/var1 {
data 4
}
/var2 {
data 8
}
}
type string
}
ltm rule /Common/test_vars_class_exists_2156869 {
when HTTP_REQUEST {
set redir_class test_vars
if { [class exists $redir_class] } {
log local0. " [class match -value -- [HTTP::uri] starts_with $redir_class]"
} else {
log local0. " class $redir_class does not exist"
}
}
}
Here are the results I got while testing various URIs:
http://test-http-vs/var1 => Nov 18 07:35:42 tmm info tmm[14987]: Rule /Common/test_vars_class_exists_2156869 : 4
http://test-http-vs/var2 => Nov 18 07:35:49 tmm info tmm[14987]: Rule /Common/test_vars_class_exists_2156869 : 8
http://test-http-vs/foo1 => Nov 18 07:35:55 tmm info tmm[14987]: Rule /Common/test_vars_class_exists_2156869 :
-George
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