Forum Discussion
Juha__Ranta_106
Nimbostratus
Jun 28, 2005How to iterate over DataGroup List elements ?
Hi,
How can I iterate / access elements of a datagroup ?
I have following 'string data group list' called 'my_str_class':
--- /config/bigip.conf ---
...
class my_str_class {
"http://server-a"
"http://server-b"
}
...
--- /config/bigip.conf ----
I want to iterate over this data group list, but iRule:
...
foreach i $::my_str_class {
do something with each element $i
(http-response redirect 'Location:' -header rewrite ..)
}
...
gives the following Tcl error msg:
- list element in braces followed by "" instead of space
If I print the data group with cmd 'log LOCAL0.debug $::my_str_class'
it looks like this:
{http://server-a} {http://server-b}
---
Could you Please include more examples to BIG-IP 9 iRule documentation.
PS: documentation for 'matchclass' is also missing, although I think
figured out how to use it.
- I didn't write the logic behind the data groups but it seems that it is internally represented by a string. By adding the TCL split command to create a true TCL list, foreach should work. I'll verify if this is something we need to fix or if it's by design.
... foreach i [split $::my_str_class] { log local0. $i } ...
- unRuleY_95363Historic F5 AccountThank you for pointing this out. A problem was discovered in accessing a class/DataGroup as a Tcl list.
- Juha__Ranta_106
Nimbostratus
Could you implement a version of matchclass that would return the matchingset location [HTTP::header "Location"]; set matchidx [matchclass $location starts_with $::my_str_class];
- unRuleY_95363Historic F5 AccountCould you implement a version of matchclass that would return the matching value in 'class' instead returning numeric value (0, 1, ..)?
- brad_11480
Nimbostratus
This is an old thread and perhaps the information is out of date (I hope it is).
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