Forum Discussion

BaltoStar_12467's avatar
Mar 13, 2015

data-group format for irule match against simple list

F5 BIG-IP Virtual Edition v11.4.1 (Build 635.0) LTM on ESXi

My iRule needs to match a variable against a simple list of values :

set found_match [class match $lookup_key eq data_group_simple_list]

For simplicity, I'd like to structure my data-group like this :

"key_1",
"key_2",
"key_3",
"key_4",
"key_5",

But because the

[class match]
command apparently was designed for the primary use-case of matching against key-value-pairs ( match key , return value ), I must structure my data-group like this :

"key_1" := "key_1",
"key_2" := "key_2",
"key_3" := "key_3",
"key_4" := "key_4",
"key_5" := "key_5",

Am I understanding this correctly ? Or is there an alternate mechanism that would allow me to format my list in the simple manner ?

Admin browser > System > File Management > Data Group File List > Import...

File Contents = string

For "Key / Value Pair Separator" , if I enter a blank value , I receive error :

0107169a:3: The data group external file (/config/filestore/.stage_d/5955941_d/Common_d/data_group_d/:Common:data-group-test_87302_1) has an invalid format, line: 2.

15 Replies

  • kunjan's avatar
    kunjan
    Icon for Nimbostratus rankNimbostratus

    Hi, you can leave the value field empty can do something like this

    when CLIENT_ACCEPTED {
       if {  [class match $lookup_key eq data_group_simple_list]} {
         pool poola
       } else {
         pool poolb
       }
    }
    

    You can refer to the prebuilt datagroup 'private_net' under iRules tab.

    • ok but how to load a data-group-file in simple list format ? ( please see my amended question )
  • Hi, you can leave the value field empty can do something like this

    when CLIENT_ACCEPTED {
       if {  [class match $lookup_key eq data_group_simple_list]} {
         pool poola
       } else {
         pool poolb
       }
    }
    

    You can refer to the prebuilt datagroup 'private_net' under iRules tab.

    • ok but how to load a data-group-file in simple list format ? ( please see my amended question )
  • kunjan's avatar
    kunjan
    Icon for Nimbostratus rankNimbostratus

    May be you are affected by this. If you are using windows format try converting to unix.

    https://support.f5.com/kb/en-us/products/big-ip_ltm/releasenotes/product/relnote-ltm-11-6-0.print.html

    ID 376894 - External data group files that have been edited on Microsoft Windows platforms can now be imported in their native format. Both Windows style (CRLF) as well as Unix/Linux style (LF) line endings are supported, so there is no longer a need to run these files through utilities to reformat line endings.

    So, you can follow the file content like:

    key_1,

    key_2,

    key_3,

    • ah yes .. loading data-group-file with windows-style line-endings is a familiar error i've encountered on many occasions -- i incorrectly assumed it was due to specifying a blank key-value separator ... so apparently, it's possible to load a "keys only" data-group-file while specifying a key-value separator that's not present
    • Arie's avatar
      Arie
      Icon for Altostratus rankAltostratus
      I think BaltoStar is on 11.4.1, so the new import format is probably not available to him.
  • May be you are affected by this. If you are using windows format try converting to unix.

    https://support.f5.com/kb/en-us/products/big-ip_ltm/releasenotes/product/relnote-ltm-11-6-0.print.html

    ID 376894 - External data group files that have been edited on Microsoft Windows platforms can now be imported in their native format. Both Windows style (CRLF) as well as Unix/Linux style (LF) line endings are supported, so there is no longer a need to run these files through utilities to reformat line endings.

    So, you can follow the file content like:

    key_1,

    key_2,

    key_3,

    • ah yes .. loading data-group-file with windows-style line-endings is a familiar error i've encountered on many occasions -- i incorrectly assumed it was due to specifying a blank key-value separator ... so apparently, it's possible to load a "keys only" data-group-file while specifying a key-value separator that's not present
    • Arie's avatar
      Arie
      Icon for Altostratus rankAltostratus
      I think BaltoStar is on 11.4.1, so the new import format is probably not available to him.
  • this is mine.

    iRules Data Group Formatting Rules by Jason Rahm

    https://devcentral.f5.com/articles/irules-data-group-formatting-rules
     create
    
    [root@ve11c:Active:In Sync] config  cat /var/tmp/data.txt
    "key_1" := "",
    "key_2" := "",
    "key_3 ":= "",
    
    root@(ve11c)(cfg-sync In Sync)(Active)(/Common)(tmos) create sys file data-group test source-path file:///var/tmp/data.txt type string
    Copying file "file:///var/tmp/data.txt" ...
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
      0    45    0    45    0     0  75125      0 --:--:-- --:--:-- --:--:--     0
    
    root@(ve11c)(cfg-sync In Sync)(Active)(/Common)(tmos) create ltm data-group external test_datagroup external-file-name test
    root@(ve11c)(cfg-sync In Sync)(Active)(/Common)(tmos)
    
     verify
    
    root@(ve11c)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm data-group external test_datagroup
    ltm data-group external test_datagroup {
        external-file-name test
        type string
    }
    root@(ve11c)(cfg-sync In Sync)(Active)(/Common)(tmos) list sys file data-group test
    sys file data-group test {
        checksum SHA1:45:7b38f5bbc6a368168b987cca5568216b5308e94a
        create-time 2015-03-14:08:57:26
        created-by root
        last-update-time 2015-03-14:08:57:26
        mode 33152
        revision 1
        size 45
        source-path file:///var/tmp/data.txt
        type string
        updated-by root
    }
    
    • Simon_Conway-Sm's avatar
      Simon_Conway-Sm
      Icon for Nimbostratus rankNimbostratus

      Can this data file format be used to create a list of target hostnames for looking up HTTP::host, i.e. where each hostname entry is a set of dotted names, e.g. "myfunc.mydomain.com"?

       

  • this is mine.

    iRules Data Group Formatting Rules by Jason Rahm

    https://devcentral.f5.com/articles/irules-data-group-formatting-rules
     create
    
    [root@ve11c:Active:In Sync] config  cat /var/tmp/data.txt
    "key_1" := "",
    "key_2" := "",
    "key_3 ":= "",
    
    root@(ve11c)(cfg-sync In Sync)(Active)(/Common)(tmos) create sys file data-group test source-path file:///var/tmp/data.txt type string
    Copying file "file:///var/tmp/data.txt" ...
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
      0    45    0    45    0     0  75125      0 --:--:-- --:--:-- --:--:--     0
    
    root@(ve11c)(cfg-sync In Sync)(Active)(/Common)(tmos) create ltm data-group external test_datagroup external-file-name test
    root@(ve11c)(cfg-sync In Sync)(Active)(/Common)(tmos)
    
     verify
    
    root@(ve11c)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm data-group external test_datagroup
    ltm data-group external test_datagroup {
        external-file-name test
        type string
    }
    root@(ve11c)(cfg-sync In Sync)(Active)(/Common)(tmos) list sys file data-group test
    sys file data-group test {
        checksum SHA1:45:7b38f5bbc6a368168b987cca5568216b5308e94a
        create-time 2015-03-14:08:57:26
        created-by root
        last-update-time 2015-03-14:08:57:26
        mode 33152
        revision 1
        size 45
        source-path file:///var/tmp/data.txt
        type string
        updated-by root
    }
    
    • Simon_Conway-Sm's avatar
      Simon_Conway-Sm
      Icon for Nimbostratus rankNimbostratus

      Can this data file format be used to create a list of target hostnames for looking up HTTP::host, i.e. where each hostname entry is a set of dotted names, e.g. "myfunc.mydomain.com"?

       

  • and this is what kunjan suggested.

    [root@ve11c:Active:In Sync] config  cat /var/tmp/data2.txt
    key_1,
    key_2,
    key_3,
    
    root@(ve11c)(cfg-sync In Sync)(Active)(/Common)(tmos) create sys file data-group test2 source-path file:///var/tmp/data2.txt type string
    Copying file "file:///var/tmp/data2.txt" ...
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
      0    21    0    21    0     0  27096      0 --:--:-- --:--:-- --:--:--     0
    
    root@(ve11c)(cfg-sync In Sync)(Active)(/Common)(tmos)
    root@(ve11c)(cfg-sync In Sync)(Active)(/Common)(tmos) list sys file data-group test2
    sys file data-group test2 {
        checksum SHA1:21:4458a854a85b22dd0dc8df590d5d65c5f4231f79
        create-time 2015-03-14:09:02:19
        created-by root
        last-update-time 2015-03-14:09:02:19
        mode 33152
        revision 1
        size 21
        source-path file:///var/tmp/data2.txt
        type string
        updated-by root
    }