For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

uni's avatar
uni
Icon for Altocumulus rankAltocumulus
Feb 04, 2014

Parse datagroup values as a list

I have a datagroup which I am testing each element of:

foreach item [class names my-dg] {
     if { [string match -nocase $item $teststring] } {

Unfortunately, if the datagroup elements have asterisks in them your config won't load if mcpd does a forceload or you are updating the software (even though you can enter these entries through the GUI, or through tmsh if they are escaped with a "\").

Anyway, I need to rewrite the rule, so I thought I'd just put all the names as values and have an arbitrary name such as a sequence number.

Can someone suggest a simple way to load the datagroup values as a list, so I can just loop through with a foreach, or some other efficient method of checking each value?

1 Reply

  • Use class get. It'll produce a list of the keys and values, or rather a list of lists.

    when HTTP_REQUEST {
        set mylist [class get biglist]
    
        foreach x $mylist {
            log local0. "[lindex $x 0] : [lindex $x 1]"
        }
    }