Forum Discussion

Eldad_162351's avatar
Eldad_162351
Icon for Nimbostratus rankNimbostratus
Aug 10, 2014
Solved

iApp to modify data-group

hello,

 

im trying to add a set of key and value from iApp to a data-group belonged to iRule. my iApp template:

 

section x { table y_table { string key string value } }

 

text { x "section x" x.y_table.key "Input1: " x.y_table.value "Input2: " }

 

also, i have an tmsh command which works through command line: tmsh modify ltm data-group internal my_datagroup records add {"key" {data "value"}}

 

now what im trying to do is to make the input from the iapp to modify the data-group

 

any help appriciated.

 

thanks ahead.

 

  • I led you astray. The following is corrected, and works if your data-group already exists. If it doesn't exist yet, use tmsh::create. It appears that the exec is not necessary.

    foreach row $::x__y_table {
       array set columns [join $row]
       tmsh::modify ltm data-group internal /Common/my_datagroup records add \{ $columns(key) \{ data $columns(value) \}\}
    }
    

10 Replies

  • Fred_Slater_856's avatar
    Fred_Slater_856
    Historic F5 Account

    Datagroups are shared resources which cannot be "owned" by an iApp, but you can fool the iApp into configuring datagroups by forking a shell. Put this in your iApp implementation:

    exec tmsh modify ltm data-group internal /Common/my_datagroup records add { $::x__y_table__key { data $::x__y_table__value }}

  • Hey,

     

    thanks for the answer Fred, but trying to run this causes a script run error with: Syntax Error: records: required brace is missing "{"

     

    not sure what im doing wrong...

     

    thanks. E.

     

  • Fred_Slater_856's avatar
    Fred_Slater_856
    Historic F5 Account

    You may need to escape the braces.

    ... records add \{ $::x__y_table__key \{ data $::x__y_table__value \}\}

  • looks like im doing something wrong...

     

    now im getting the error:

     

    ::x__y_table__key no such variable

     

    i tried to set a new variables for the key and value before the exec and call them from the exec but still same error.

     

    thanks for all your support, really appriciated since im new to the F5 dev...

     

  • Fred_Slater_856's avatar
    Fred_Slater_856
    Historic F5 Account

    I led you astray. The following is corrected, and works if your data-group already exists. If it doesn't exist yet, use tmsh::create. It appears that the exec is not necessary.

    foreach row $::x__y_table {
       array set columns [join $row]
       tmsh::modify ltm data-group internal /Common/my_datagroup records add \{ $columns(key) \{ data $columns(value) \}\}
    }
    
    • Fred_Slater_856's avatar
      Fred_Slater_856
      Historic F5 Account
      (Wiki formatting did not show it, but the "array set" and "tmsh::modify" commands must be on separate lines.)
    • Ryan77777's avatar
      Ryan77777
      Icon for Altocumulus rankAltocumulus

      When you delete the iApp, how does the entry get removed from the datagroup? Is there a way to program that into iApp as part of the decomm process?

       

    • Fred_Slater_856's avatar
      Fred_Slater_856
      Historic F5 Account

      Is doesn't get removed, and no, unfortunately the iApp framework has no hooks for decomm code.