Forum Discussion
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::limit_prefix}_dgl] {
scan $limit_element {%[^ ] %d/%d} limit_uri conn_limit conn_timeout
[...]
}
etc. With a class with ONE element, this chokes, as the $limit_element value is only the value itself, e.g. "200/1", not the attribute name as well. With MORE elements in the list, it works great, and $limit_element is "/login 200/1" . Similarly this looks to be reflected in bigip.conf contents, as extra brackets exist etc.:
class http_request_limit_dgl {
{
"/login" { "200/1" }
"/sample_uri" { "5/10" }
}
}
class t1_http_request_limit_dglxx {
"/login" { "200/1" }
}
Can anyone comment on this?
- hooleylistCirrostratusIf 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
- Chris_PhillipsNimbostratusYes, absolutely. I think the issue I have is how this is at all acceptable..? It's massively inconsistent.
- hooleylistCirrostratusThat does seem a bit buggy. If you are interested in finding out more about you could open a case with Support. If you do, can you reply with the case number so I can follow it?
- Chris_PhillipsNimbostratusYep, that does work, thanks for that. I'll see if I can something raised, that does seem pretty bizarre to me.
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