Forum Discussion
iApp - error when creating pools
Hi All
Im trying to build out an iapp that creates a number of duplicate objects with minor differences.
my config so far looks like this
presentation
section members { Build a table of pool members message members table pool_members { editchoice addr display "large" tcl { package require iapp 1.1.3 return [iapp::get_items ltm node] } } }
Implementation
iapp::template start set object_name $tmsh::app_name
tmsh::create "/ltm monitor tcp MON-${object_name}_80 adaptive disabled defaults-from tcp description $object_name interval 5 ip-dscp 0 time-until-up 0 timeout 16" tmsh::create "/ltm monitor tcp MON-${object_name}_443 adaptive disabled defaults-from tcp description $object_name interval 5 ip-dscp 0 time-until-up 0 timeout 16"
set servers $::members__pool_members
I am trying to append the port number as I only want the user to input the node addresses ( there will eventually be +10 of the same pools created but with different ports )
set newlist {} set port :80 foreach item $servers { set newitem $item$port lappend newitem lappend newlist $newitem }
tmsh::create "/ltm pool POOL-${object_name}_80 description ${object_name}_80 members add { $newlist } monitor MON-${object_name}_80"
iapp::template stop
When I run this iapp i get the following error.
script did not successfully complete: (one or more configuration identifiers must be provided while executing "tmsh::create "/ltm pool POOL-${object_name}_80 description ${object_name}_80 members add { $newlist } monitor MON-${object_name}_80"" line:26)
noted that if if set the servers list manually (set servers {1.1.1.1 2.2.2.2}) this all works fine and all objects are created correctly.
Im fairly sure the error has to do with the port number not being appended correctly. But cant see why it wouldnt work when the info is grabbed from presentation rather than inputted manually
Any input appreciated.
Thanks
iapp::pool_members will try to do the right thing based on what you give it. If there is a "port" or "port_secure" column in your table, it will use those port values. You can specify a port value to override those with the -port flag (e.g. iapp::pool_members -port 8080 $::members__pool_members). If you specify only IP addresses and omit the -port flag, it will assume port 80.
- Fred_Slater_856Historic F5 Account
It is difficult to read your code in the blog formatting, but I wonder what the purpose of the "lappend newitem" command is? Anyway, one great way to debug iapps is to log ("puts") the contents of your variables and view the result in /var/tmp/scriptd.out. Then you will see exactly what your tmsh::create statement looks like. Alternatively, you can use the on-box tcl package procedure called iapp::conf, which logs every tmsh command to /var/tmp/scriptd.out so you can see the entire tmsh output of your iapp without writing debug code.
- Dmanden_23459
Nimbostratus
Hey Fred
yeah thanks. i tried to edit the article and make it more readable. but it wont let me save that. code actually looks like this.
presentation
section members { Build a table of pool members message members table pool_members { editchoice addr display "large" tcl { package require iapp 1.1.3 return [iapp::get_items ltm node] } } }
Implementation
iapp::template start set object_name $tmsh::app_name tmsh::create "/ltm monitor tcp MON-${object_name}_80 adaptive disabled defaults-from tcp description $object_name interval 5 ip-dscp 0 time-until-up 0 timeout 16" tmsh::create "/ltm monitor tcp MON-${object_name}_443 adaptive disabled defaults-from tcp description $object_name interval 5 ip-dscp 0 time-until-up 0 timeout 16" set servers $::members__pool_members I am trying to append the port number as I only want the user to input the node addresses ( there will eventually be +10 of the same pools created but with different ports ) set newlist {} set port :80 foreach item $servers { set newitem $item$port lappend newitem lappend newlist $newitem } tmsh::create "/ltm pool POOL-${object_name}_80 description ${object_name}_80 members add { $newlist } monitor MON-${object_name}_80" iapp::template stop
The append is meant to add the port to the node details as part of the presentation steps im only capturing the node address ( hope that makes sense )
thanks for the "puts" tip. ill give that go in the meantime
thanks
- Fred_Slater_856Historic F5 Account
Your code assumes that $::members__pool_members is a simple list, but APL tables are not built that way. They look more like:
members__pool_members { column-names { addr } rows { { row { 10.2.4.5 } } } }
So, on the first iteration of your foreach loop, the value of $item would be "column-names".
- Fred_Slater_856Historic F5 Account
Hint: You may want to leverage the pre-written procedure called iapp::pool_members!
- Dmanden_23459
Nimbostratus
Fred, thanks for taking the time to respond.
if I use iapp::pool_members - will it require that I pass it both node address and port number to be valid??
apologies for tall the questions. My first go at an iapp and its sending my head in circles.
thanks Dennis
- Fred_Slater_856Historic F5 Account
iapp::pool_members will try to do the right thing based on what you give it. If there is a "port" or "port_secure" column in your table, it will use those port values. You can specify a port value to override those with the -port flag (e.g. iapp::pool_members -port 8080 $::members__pool_members). If you specify only IP addresses and omit the -port flag, it will assume port 80.
- Dmanden_23459
Nimbostratus
Thanks Fred
Ill give that a go instead and hopefully get it working
appreciate the help
-Dennis
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com