Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Answers

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.

0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

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) \}\}
}
0
Comments on this Answer
Comment made 12-Aug-2014 by Fred Slater
(Wiki formatting did not show it, but the "array set" and "tmsh::modify" commands must be on separate lines.)
0
Comment made 02-May-2018 by Ryan 498

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?

0
Comment made 03-May-2018 by Fred Slater

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

0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

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 }}

0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

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.

0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

You may need to escape the braces. ... records add \{ $::x__y_table__key \{ data $::x__y_table__value \}\}

0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

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...

0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

It Works!!!

thanks so much!

E.

0
Comments on this Answer
Comment made 13-Aug-2014 by Fred Slater
Great! Happy to help.
0