Forum Discussion

hooleylist's avatar
hooleylist
Icon for Cirrostratus rankCirrostratus
Jan 03, 2012

Force reload of external datagroup files?

How can I force a reload of external data group files via tmsh?

On 11.1, I've imported a data group file via the GUI under File Management | Data Group File List | Import. I then edited the file on the file system under /config/filestore/files_d/Common_d/data_group_d/:Common:name_value_external_dg_1. But when I reload the config using 'tmsh load sys config' the data group contents are not updated:


 cat \:Common\:name_value_external_dg_1
"name1" := "value1",
"name2" := "value2",
"name3" := "value3",
"name4" := "value4",
 tmsh load sys config
Loading system configuration...
  /defaults/app_template_base.conf
  /defaults/config_base.conf
  /config/low_profile_base.conf
  /defaults/wam_base.conf
  /usr/share/monitors/base_monitors.conf
  /config/daemon.conf
  /config/profile_base.conf
  /defaults/fullarmor_gpo_base.conf
Loading configuration...
  /config/bigip_base.conf
  /config/bigip_user.conf
  /config/bigip.conf
 tmsh list ltm data-group external name_value* all-properties
ltm data-group external name_value_external_dg {
    app-service none
    description none
    external-file-name name_value_external_dg
    partition Common
    records {
        name1 {
            data value1
        }
        name2 {
            data value2
        }
        name3 {
            data value3
        }
    }
    type string
}

I checked the tmsh help for external data groups, but don't see anything relevant.

Do I need to recreate the data group from scratch using the updated file?

Also, if I wanted to create the data group exclusively from the CLI and/or just tmsh, how could I import the external data group file?

Thanks, Aaron

  • Here are the steps for future reference:

    Create a new external data group from the CLI non-interactively

    1. Create or copy over to LTM a temporary file containing the external data group contents. If copying, make sure the line terminators are \n only not \r\n.

    You can use od to view the unprintable characters in a file:

    
    od -c /var/tmp/dos.file
        0000000   "   n   a   m   e   1   "       :   =       "   v   a   l   u
        0000020   e   1   "   ,  \r  \n   "   n   a   m   e   2   "       :   =
        0000040       "   v   a   l   u   e   2   "   ,  \r  \n   "   n   a   m
        0000060   e   3   "       :   =       "   v   a   l   u   e   3   "   ,

    If the source file was created on Windows, it most likely has \r\n line terminators, so use tr to remove the \r's:

    
    tr -d '\r' < /var/tmp/dos.file > /var/tmp/string_name_value_external_dg.txt

    
    od -c /var/tmp/string_name_value_external_dg.txt
        0000000   "   n   a   m   e   1   "       :   =       "   v   a   l   u
        0000020   e   1   "   ,  \n   "   n   a   m   e   2   "       :   =
        0000040   "   v   a   l   u   e   2   "   ,  \n   "   n   a   m   e   3
        0000060   "       :   =       "   v   a   l   u   e   3   "   ,

    
     cat /var/tmp/string_name_value_external_dg.txt
        "name1" := "value1",
        "name2" := "value2",
        "name3" := "value3",

    2. Create the new external data group file

    
        tmsh create /sys file data-group string_name_value_external_dg_file separator ":=" source-path file:/var/tmp/string_name_value_external_dg.txt type string

    3. Create the external data group referencing the file

    
        tmsh create /ltm data-group external string_name_value_external_dg external-file-name string_name_value_external_dg_file

    4. Save the config from memory to file

    
        tmsh save /sys config

    ----------------------------------------------------------------

    Modify the external data group file

    1. Create a new temporary file containing the updated external data group contents

    
     cat /var/tmp/string_name_value_external_v2_dg.txt
        "name1" := "valueA",
        "name2" := "valueB",
        "name3" := "valueC",

    2. Modify the system file to reference the new content. Note that the new existing system file content is overwritten with the new file content. A new system file is not created.

    
        tmsh modify /sys file data-group string_name_value_external_dg_file source-path file:/var/tmp/string_name_value_external_v2_dg.txt

    3. Save the config from memory to file

    
        tmsh save /sys config

  • Shouldn't this accomplish what you are trying to do?

     

     

    tmsh edit /sys file data-group string_name_value_external_dg_file

     

     

     

    should let you edit the file in VI and ask you if you want to save changes when you are done.

     

     

    Joe M

     

  • Hi Joe,

     

     

    That would work for manual edits, but I was trying to handle scripted updates to the data group using an external file.

     

     

    Aaron
  • In the past i used to cron something like:

     

    tmsh modify /ltm data-group external ext-addresses source-path file:/shared/addresses tmsh save /sys config

     

    Hope it helps, Nicola