Forum Discussion

chris_grice_248's avatar
chris_grice_248
Icon for Nimbostratus rankNimbostratus
Jan 25, 2017

iApp tables?

Hi I am working on a simple IAPP to build Virtual Servers, pools etc. One of the drivers behind the iApp is so we can make sure our naming standard is followed.

I am trying to get the iApp to name the pool in this format

{location}_{FQDN}_{port}_pl

The location and FQDN I have got working. My pool port is defined in the below table ` section pool {

    choice pool display "xxlarge" default "Yes" 


optional ( pool == "Yes" ){
        table members {
        editchoice member display "large" tcl {
                package require iapp 1.0.0
                return [iapp::get_items ltm node]
            }

                string memberport display "small" required default "80"
                    validator "PortNumber"


        }

What I would like to do is put the memberport string input into a variable and add that to the name. How do i set a variable that is referenced within a table. I cant put

set plport $::pool__members__memberport
for example.

New to iApps TCL so I hope that makes sense

1 Reply

  • I see a couple of ways to get this information but an underlying question is this: What port will you include in the pool name if the user enters different port numbers on the members? In other words, what if one pool member is at port 80 but another is at port 8080? (This is allowed...) If all members must be on the same port, why not move the port setting completely out of the table into a separate string field that is its own variable?

     

    To access values in a table, you have to loop through the table. I'm guessing there is already code in the Implementation Section to extract the selected nodes' IP addresses and user-specified ports, and build the member list that will be used on the tmsh create command for the pool. After the loop completes, you could extract the port specified on the last member to use in the pool name. Something like this perhaps:

     

    set MemberList ""
    foreach TableRow $::pool__members {
        array set ThisRow [lindex $TableRow 0]
        lappend MemberList "$ThisRow(address):$ThisRow(port)"
    }
    tmsh::create "/ltm pool ${location}_${FQDN}_${ThisRow(port)}_pl members replace-all-with { $MemberList } ..."

    (I'm assuming $location and $FQDN have been set previously.)