Forum Discussion

darragh_19954's avatar
darragh_19954
Icon for Nimbostratus rankNimbostratus
Nov 08, 2007

How do I access BIG-IP "Data Group List" class as a list in an iRule?

We are defining a class using the "Data Group List" in the BIG-IP GUI.

 

 

From within an iRule, one typically matches against an element of this list with some code like:

 

 

if { [matchclass $value equals $::ClassList] } { ... }

 

 

However we require each member of this class/list to be a string-encoded record, not a single value to be compared.

 

 

So within the iRule, we want to gain access to the raw list of values in the class, so we can parse each value in a loop and action depending on its breakdown.

 

 

Does anyone know how to do this?

 

 

thanks

 

darragh

1 Reply

  • You can use any of the TCL list commands (llength, lindex, etc) with a data group. For looping through a class called ClassList, you could do the following:

    set count [llength $::ClassList]
    for {set i 0} {$i < $count} {incr i} {
      set val [lindex $::ClassList $i]
      log local0. "ClassList($i) : $val"
    }

    Or you could do it with a foreach loop like this:

    foreach val $::ClassList {
      log local0. "ClassList Item : $val"
    }

    Hope this helps...

    -Joe