Forum Discussion
Chris_Phillips
Feb 23, 2012Nimbostratus
single vs multi element classes in irules
Howdy,
I wrote a bit of code on 10.2.0 which looped through a class and used scan to extract three variables:
foreach limit_element [class get ${static::lim...
hooleylist
Feb 23, 2012Cirrostratus
If you need to loop through the datagroup to perform an operation with the key or value, you can use a class loop:
Save a class name to search through
set class_name t1_http_request_limit_dglxx2
Save a search ID for the datagroup
set id [class startsearch $class_name]
Loop through the class row by row
while {[class anymore $class_name $id]}{
set element [class nextelement $class_name $id]
log local0. "\[class nextelement $class_name $id\]: $element"
Perform some operation against the current datagroup key and/or value
scan $element {%[^ ] %d/%d} a b c
log local0. "scanned $element: $a, $b, $c"
}
Clean up the search
class donesearch $class_name $id
This works for a single line or multiple line data group. I think the reason your original rule isn't working as expected is that the name and value returned using class get against a single line data group is interpreted as a two element TCL list: {name} {value}, whereas a multiple line data group is interpreted as {name1 value1} {name2 value2}.
Aaron
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