v10 class matches_glob type functionality?

Hi,

There is a v9 iRule I’m trying to convert and have CMP compatible. The current functionality required using a global TCL list of the format:

set ::global_list [list *uri_token1 /uri_token2* etc]

I was then looping through the list using string match for each list element against the requested URI.

I’d like to implement this kind of functionality using the v10 class command, but it doesn’t look like there is a way to check if a string matches a glob style pattern in the datagroup. The ‘class get [-nocase] []’ option looks close, but it’s searching the class for an element that matches a pattern--not searching a class for a pattern which matches the string.

Are there any thoughts on implementing a command like:

class matches_glob

where the class would have elements of glob style string patterns like *uri/ or /uri*. The starts_with, contains and ends_with functionality doesn’t quite work here as I want to be able to use a single datagroup and need to support multiple types of matches.

I can open an RFE case based on any info you might be able to provide.

Thanks,

Aaron

I ended up using class element to do this, but it seems like extra work that could be made more efficient (or easier) with a glob_match style option for the class command.

Loop through each class line 
 for {set i 0} {$i < [class size my_dgl]} {incr i} {                        
  
     Use scan to parse the two fields from the class 
    scan [class element -name $i my_dgl] {%[^ ]%s} my_pattern my_value 
  
     Use string match to evaluate the pattern against the string 
    if {[string match -nocase $my_pattern [HTTP::uri]]}{ 
  
        Found a match 
       log local0. "Matched $my_pattern, using $my_value" 
       break 
    } 
 }

Aaron

Hey Colin,

Yeah, I took a look at the class get command, but it’s not quite what I need. I want to have the class contain the patterns and see if the string I supply matches any of those patterns. The current class get command does the opposite. It takes the supplied pattern and sees if any of the class elements match it.

Is this any clearer?

Aaron