Forum Discussion
John
Apr 19, 2011Altostratus
Issue with classes with only one item and [class get datagroupname[
Ok, I'm having an issue with an irule using the [class get ]. If my class is defined with only one item, the class get command will return two items. Is it counting a null value as an item? Tried on 10.2.1 Build 297 final and 10.2.1 Build 496 HF2.
iRule:
when HTTP_REQUEST {
set clientRequestedURI [string tolower [HTTP::uri]]
how many items
log "size = [class size john-test-group]"
iterate through class
foreach {element} [class get john-test-group] {
log "url=$clientRequestedURI element=$element"
}
}
My class from bigip.conf:
class john-test-group {
"item1"
}
Output:
Rule john-test-data-group : size = 1
Rule john-test-data-group : url=/dns.html element=item1
Rule john-test-data-group : url=/dns.html element=
Class with > 2 items (odd that it adds extra "{}" in the bigip.conf):
class john-test-group {
{
"item1"
"item2"
}
}
Rule john-test-data-group : size = 2
Rule john-test-data-group : url=/dns.html element=item1 {}
Rule john-test-data-group : url=/dns.html element=item2 {}
Even with values defined, gives same result, except the value does show up as the second item when class with one item:
class john-test-group {
"item1"
}
Rule john-test-data-group : size = 1
Rule john-test-data-group : url=/dns.html element=item1
Rule john-test-data-group : url=/dns.html element=
class john-test-group {
{
"item1" { "value1" }
"item2" { "value2" }
}
}
Rule john-test-data-group : size = 2
Rule john-test-data-group : url=/dns.html element=item1 value1
Rule john-test-data-group : url=/dns.html element=item2 value2
Second oddity, if the string has spaces, one list item is not enclosed in {} in log:
class john-test-group {
"item1 sub1-1 sub1-2"
}
Rule john-test-data-group : size = 1
Rule john-test-data-group : url=/dns.html element=item1 sub1-1 sub1-2
Rule john-test-data-group : url=/dns.html element=
class john-test-group {
{
"item1 sub1-1 sub1-2"
"item2 sub2-1 sub2-2"
}
}
Rule john-test-data-group : size = 2
Rule john-test-data-group : url=/dns.html element={item1 sub1-1 sub1-2} {}
Rule john-test-data-group : url=/dns.html element={item2 sub2-1 sub2-2} {}
Any ideas?
thanks
john
- hooleylistCirrostratusHi John,
- JohnAltostratushmmm, doesn't seem consistent. a "class size" gives 1, but a "class get" gives 2. So if I want to iterate a list I can't use "class get"? Or I have to put a conditional if count >2, then use get? Or should I be using search?
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